本文整理汇总了PHP中WP_Customize_Manager::remove_setting方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Customize_Manager::remove_setting方法的具体用法?PHP WP_Customize_Manager::remove_setting怎么用?PHP WP_Customize_Manager::remove_setting使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Customize_Manager
的用法示例。
在下文中一共展示了WP_Customize_Manager::remove_setting方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: goran_customize_register
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function goran_customize_register($wp_customize)
{
$wp_customize->remove_setting('edin_menu_style');
$wp_customize->remove_control('edin_menu_style');
$wp_customize->remove_setting('edin_featured_image_remove_filter');
$wp_customize->remove_control('edin_featured_image_remove_filter');
$wp_customize->remove_setting('edin_search_header');
$wp_customize->remove_control('edin_search_header');
/* Top Area Content */
$wp_customize->add_setting('goran_top_area_content', array('default' => '', 'sanitize_callback' => 'wp_kses_post'));
$wp_customize->add_control('goran_top_area_content', array('label' => __('Top Area Content', 'sequential'), 'section' => 'edin_theme_options', 'priority' => 3, 'type' => 'textarea'));
}
示例2: maybe_selective_refresh
/**
* Using the Previously created CSS element, we not just re-create it every setting change
*
* @since 4.2
*
* @return void
*/
public function maybe_selective_refresh()
{
// Only try to apply selective refresh if it's active
if (!isset($this->manager->selective_refresh)) {
return;
}
foreach ($this->settings as $name) {
$setting = $this->manager->get_setting($name);
// Skip if we don't have that setting then skip it
if (is_null($setting)) {
continue;
}
// Skip if we already have that
if (!is_null($this->manager->selective_refresh->get_partial($name))) {
continue;
}
// Remove the Setting
// We need this because settings are protected on the WP_Customize_Manager
$this->manager->remove_setting($name);
// Change the Transport
$setting->transport = 'postMessage';
// Re-add the setting
// We need this because settings are protected on the WP_Customize_Manager
$this->manager->add_setting($setting);
// Add the Partial
$this->manager->selective_refresh->add_partial($name, array('selector' => '#tribe_events_pro_customizer_css', 'render_callback' => array($this, 'print_css_template')));
}
}
示例3: register
/**
* This hooks into 'customize_register' (available as of WP 3.4) and allows
* you to add new sections and controls to the Theme Customize screen.
*
* Note: To enable instant preview, we have to actually write a bit of custom
* javascript. See live_preview() for more.
*
* @see add_action('customize_register',$func)
* @param \WP_Customize_Manager $wp_customize
*/
public static function register($wp_customize)
{
// Remove sections and native settings will not be used in theme
// Remove setcions
$wp_customize->remove_section('title_tagline');
$wp_customize->remove_section('background_image');
$wp_customize->remove_section('front_page');
// Remove setting
$wp_customize->remove_setting('background_color');
// New settings to the top section (native section [header_image ])
// Logo
$wp_customize->add_setting('logo', array('type' => 'theme_mod', 'capability' => 'edit_theme_options', 'sanitize_callback' => array($this, 'horizon_theme_sanitize_image'), 'transport' => 'refresh'));
$wp_customize->add_control(new WP_Customize_Upload_Control($wp_customize, 'logo', array('label' => __('Site Logo top', 'horizon-theme'), 'section' => 'header_image', 'settings' => 'logo', 'priority' => 10)));
// New settings for colors section (native section [colors])
// Primary Color
$wp_customize->add_setting('primary_color', array('default' => '#ffffff', 'sanitize_callback' => 'sanitize_hex_color', 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'transport' => 'refresh'));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'primary_color', array('label' => __('Primary Color', 'horizon-theme'), 'section' => 'colors', 'settings' => 'primary_color', 'priority' => 10)));
// Secondary Color
$wp_customize->add_setting('secondary_color', array('default' => '#aac54b', 'sanitize_callback' => 'sanitize_hex_color', 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'transport' => 'refresh'));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'secondary_color', array('label' => __('Secondary Color', 'horizon-theme'), 'section' => 'colors', 'settings' => 'secondary_color', 'priority' => 12)));
// Dark Color
$wp_customize->add_setting('dark_color', array('default' => 'rgba(41, 44, 46, 0.9)', 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'transport' => 'refresh'));
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'dark_color', array('label' => __('Dark Color', 'horizon-theme'), 'section' => 'colors', 'settings' => 'dark_color', 'type' => 'text')));
// Ligth Gray
$wp_customize->add_setting('light_gray', array('default' => '#9f9f9f', 'sanitize_callback' => 'sanitize_hex_color', 'type' => 'theme_mod', 'capability' => 'edit_theme_options', 'transport' => 'refresh'));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'light_gray', array('label' => __('Ligth Gray', 'horizon-theme'), 'section' => 'colors', 'settings' => 'light_gray', 'priority' => 16)));
}
示例4: setSetting
/**
* Handle a setting entry
*
* @param $id
* @param array $data
* @param null $section_id
*/
public function setSetting($id, array $data, $section_id = null)
{
$setting_data = $this->getSettingData($data);
if (is_null($section_id) && isset($data['section'])) {
$section_id = $data['section'];
}
if (isset($data['control_type']) && $data['control_type'] == 'select' && (empty($data['sanitize_callback']) || $data['sanitize_callback'] == '')) {
$data['sanitize_callback'] = sanitize_select_generator(isset($data['choices']) ? $data['choices'] : array(), isset($data['default']) ? $data['default'] : null);
}
$item = $this->customizer->get_setting($id);
if ($item) {
foreach ($data as $var => $val) {
if (array_key_exists($var, $setting_data)) {
$item->{$var} = $val;
} elseif ($var == 'setting_type') {
$item->type = $val;
}
if (!empty($section_id)) {
$item->section = $section_id;
}
}
if (isset($data['delete']) && $data['delete'] === true) {
$this->customizer->remove_setting($id);
}
} else {
$control_item = $this->customizer->get_control($id);
if (empty($control_item)) {
$this->customizer->add_setting(new WP_Customize_Setting($this->customizer, $id, $setting_data));
}
if (!is_null($section_id)) {
$this->setControl($id, $section_id, $data);
}
}
}
示例5: array
/**
* Temporarily remove widget settings and controls from the Manager so that
* they won't be serialized at once in _wpCustomizeSettings. This greatly
* reduces the peak memory usage.
*
* This is only relevant in WordPress versions older than 4.4-alpha-33636-src,
* with the changes introduced in Trac #33898.
*
* @link https://core.trac.wordpress.org/ticket/33898
*/
function defer_serializing_data_until_shutdown()
{
$this->customize_controls = array();
$controls = $this->manager->controls();
foreach ($controls as $control) {
if ($control instanceof \WP_Widget_Form_Customize_Control || $control instanceof \WP_Widget_Area_Customize_Control) {
$this->customize_controls[$control->id] = $control;
$this->manager->remove_control($control->id);
}
}
/*
* Note: There is currently a Core dependency issue where the control for WP_Widget_Area_Customize_Control
* must be processed after the control for WP_Widget_Form_Customize_Control, as otherwise the sidebar
* does not initialize properly (specifically in regards to the reorder-toggle button. So this is why
* we are including the WP_Widget_Area_Customize_Controls among those which are deferred.
*/
$this->customize_settings = array();
$settings = $this->manager->settings();
foreach ($settings as $setting) {
if (preg_match('/^(widget_.+?\\[\\d+\\]|sidebars_widgets\\[.+?\\])$/', $setting->id)) {
$this->customize_settings[$setting->id] = $setting;
$this->manager->remove_setting($setting->id);
}
}
// We have to use shutdown because no action is triggered after _wpCustomizeSettings is written.
add_action('shutdown', array($this, 'export_data_with_peak_memory_usage_minimized'), 10);
add_action('shutdown', array($this, 'fixup_widget_control_params_for_dom_deferral'), 11);
}
示例6: stormbringer_customize_register
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function stormbringer_customize_register($wp_customize)
{
$wp_customize->get_setting('blogname')->transport = 'postMessage';
$wp_customize->get_setting('blogdescription')->transport = 'postMessage';
$wp_customize->get_setting('header_textcolor')->transport = 'postMessage';
// Favicon *******************
$wp_customize->add_section('favicon', array('title' => __('Favicon', 'stormbringer'), 'priority' => 10));
// Theme Color
$wp_customize->add_setting('favicon_theme_color', array('default' => '#333', 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_hex_color'));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'favicon_theme_color', array('label' => __('Theme Color', 'stormbringer'), 'section' => 'favicon', 'settings' => 'favicon_theme_color', 'priority' => 10)));
// Mask Color
$wp_customize->add_setting('favicon_mask_color', array('default' => '#333', 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_hex_color'));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'favicon_mask_color', array('label' => __('Mask Color', 'stormbringer'), 'section' => 'favicon', 'settings' => 'favicon_mask_color', 'priority' => 10)));
// Tile Color
$wp_customize->add_setting('favicon_tile_color', array('default' => '#333', 'transport' => 'refresh', 'sanitize_callback' => 'sanitize_hex_color'));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'favicon_tile_color', array('label' => __('Tile Color', 'stormbringer'), 'section' => 'favicon', 'settings' => 'favicon_tile_color', 'priority' => 10)));
// Favicons folder
$wp_customize->add_setting('favicon_folder', ['default' => 'root']);
$wp_customize->add_control('favicon_folder', array('label' => __('Folder', 'stormbringer'), 'section' => 'favicon', 'description' => __('Use http://realfavicongenerator.net to generate the favicons', 'stormbringer'), 'settings' => 'favicon_folder', 'type' => 'radio', 'choices' => array('root' => __('Relative to the root folder /', 'stormbringer'), 'theme' => __('Relative to the theme folder', 'stormbringer') . ': ' . get_stylesheet_directory_uri() . '/img/favicon/')));
// Libraries ****************************
$wp_customize->add_section('libraries', array('title' => __('External Libraries'), 'priority' => 10));
// library
if (current_theme_supports('libraries')) {
$libraries = get_theme_support('libraries')[0];
foreach ($libraries as $librarie_name => $librarie_key) {
$wp_customize->add_setting('libraries_' . $librarie_name . '', array('default' => '1'));
$wp_customize->add_control('libraries_' . $librarie_name . '', array('section' => 'libraries', 'default' => '1', 'label' => $librarie_name, 'type' => 'checkbox', 'std' => '1'));
}
}
// Title Tagline ****************************
$wp_customize->remove_setting('site_icon');
// Lang
$wp_customize->add_setting('lang', array('default' => '', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field'));
$wp_customize->add_control('lang', array('section' => 'title_tagline', 'label' => __('Site Language'), 'type' => 'text'));
// Misc ****************************
$wp_customize->add_section('misc', array('title' => __('Misc.', 'stormbringer'), 'priority' => 10));
// Excerpt Length
$wp_customize->add_setting('excerpt_length', array('default' => '50', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field'));
$wp_customize->add_control('excerpt_length', array('section' => 'misc', 'label' => __('Excerpt Length', 'stormbringer'), 'type' => 'text'));
// Google Fonts
$wp_customize->add_setting('google_fonts', array('default' => '', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field'));
$wp_customize->add_control('google_fonts', array('section' => 'misc', 'description' => 'Example: [\'Montserrat:400\',\'Dancing Script:400\']', 'label' => __('Google Fonts', 'stormbringer'), 'type' => 'text'));
// Typekit
$wp_customize->add_setting('typekit_id', array('default' => '', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field'));
$wp_customize->add_control('typekit_id', array('section' => 'misc', 'label' => __('Typekit ID', 'stormbringer'), 'type' => 'text'));
// Addthis
$wp_customize->add_setting('addthis_id', array('default' => '', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field'));
$wp_customize->add_control('addthis_id', array('section' => 'misc', 'label' => __('Addthis ID', 'stormbringer'), 'type' => 'text'));
// category bottom description
$wp_customize->add_setting('cuztom', array('default' => 0));
$wp_customize->add_control('cuztom', array('section' => 'misc', 'label' => __('Load Cuztom library', 'stormbringer'), 'type' => 'checkbox'));
// Bootstrap ****************************
$wp_customize->add_section('bootstrap', array('title' => __('Bootstrap', 'stormbringer'), 'priority' => 0));
// Preprocessor
$wp_customize->add_setting('bootstrap_preprocessor', ['default' => 'scss']);
$wp_customize->add_control('bootstrap_preprocessor', array('label' => __('Preprocessor', 'stormbringer'), 'section' => 'bootstrap', 'settings' => 'bootstrap_preprocessor', 'type' => 'radio', 'choices' => array('scss' => __('Scss', 'stormbringer'), 'less' => __('Less', 'stormbringer'))));
}
示例7: goran_customize_register
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function goran_customize_register($wp_customize)
{
$wp_customize->remove_setting('edin_menu_style');
$wp_customize->remove_control('edin_menu_style');
$wp_customize->remove_setting('edin_featured_image_remove_filter');
$wp_customize->remove_control('edin_featured_image_remove_filter');
$wp_customize->remove_setting('edin_search_header');
$wp_customize->remove_control('edin_search_header');
$wp_customize->get_setting('site_logo')->transport = 'refresh';
/* Adds textarea support to the theme customizer */
class Goran_WP_Customize_Control_Textarea extends WP_Customize_Control
{
public $type = 'textarea';
public function render_content()
{
?>
<label>
<span class="customize-control-title"><?php
echo esc_html($this->label);
?>
</span>
<textarea cols="20" rows="5" style="width:100%;" <?php
$this->link();
?>
><?php
echo esc_textarea($this->value());
?>
</textarea>
</label>
<?php
}
}
/* Top Area Content */
$wp_customize->add_setting('goran_top_area_content', array('default' => '', 'sanitize_callback' => 'wp_kses_post'));
$wp_customize->add_control(new Goran_WP_Customize_Control_Textarea($wp_customize, 'goran_top_area_content', array('label' => __('Top Area Content', 'goran'), 'section' => 'edin_theme_options', 'priority' => 3, 'type' => 'textarea')));
}
示例8: register
/**
* This hooks into 'customize_register' (available as of WP 3.4) and allows
* you to add new sections and controls to the Theme Customize screen.
*
* Note: To enable instant preview, we have to actually write a bit of custom
* javascript. See live_preview() for more.
*
* @see add_action('customize_register',$func)
* @param \WP_Customize_Manager $wp_customize
*/
public static function register($wp_customize)
{
/**
* Failsafe is safe
*/
if (!isset($wp_customize)) {
return;
}
// Remove sections and native settings will not be used in theme
// Remove setcions
//$wp_customize->remove_section( 'title_tagline' );
$wp_customize->remove_section('background_image');
// Remove setting
$wp_customize->remove_setting('background_color');
self::register_options_for_header_image($wp_customize);
self::register_pages_title_section($wp_customize);
self::register_options_section($wp_customize);
}
示例9: moscow_customize_register
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function moscow_customize_register($wp_customize)
{
$wp_customize->get_section('title_tagline')->priority = '9';
$wp_customize->get_section('header_image')->panel = 'moscow_header_panel';
$wp_customize->get_section('header_image')->priority = '12';
$wp_customize->get_setting('blogname')->transport = 'postMessage';
$wp_customize->get_setting('blogdescription')->transport = 'postMessage';
$wp_customize->get_setting('header_textcolor')->transport = 'postMessage';
$wp_customize->get_control('background_color')->priority = '11';
$wp_customize->remove_setting('header_textcolor');
$default_bulletin_background = get_template_directory_uri() . "/img/default-bulletin-background.jpg";
// Titles
class Moscow_Info extends WP_Customize_Control
{
public $type = 'info';
public $label = '';
public function render_content()
{
?>
<p style="margin-top:30px;border:1px solid;padding:5px;color:#333;text-transform:uppercase;font-weight:600;"><?php
echo esc_html($this->label);
?>
</p>
<?php
}
}
/* HEADER AREA PANEL
------------------------------*/
$wp_customize->add_panel('moscow_header_panel', array('priority' => 10, 'capability' => 'edit_theme_options', 'title' => __('Header Area', 'moscow')));
/* HEADER TYPE
------------------------------*/
$wp_customize->add_section('moscow_header_type', array('title' => __('Header Type', 'moscow'), 'priority' => 10, 'panel' => 'moscow_header_panel', 'description' => __('You can select your header type from here. After that, continue below to the next tab "Header Bulletin" and configure it.', 'moscow')));
// Front page header type
$wp_customize->add_setting('front_header_type', array('default' => 'bulletin', 'sanitize_callback' => 'moscow_sanitize_header'));
$wp_customize->add_control('front_header_type', array('type' => 'radio', 'label' => __('Front page header type', 'moscow'), 'section' => 'moscow_header_type', 'description' => __('Select the header type for your front page', 'moscow'), 'choices' => array('bulletin' => __('Bulletin', 'moscow'), 'image' => __('Image', 'moscow'), 'nothing' => __('Nothing (only menu)', 'moscow'))));
// Site header type
$wp_customize->add_setting('site_header_type', array('default' => 'image', 'sanitize_callback' => 'moscow_sanitize_header'));
$wp_customize->add_control('site_header_type', array('type' => 'radio', 'label' => __('Site header type', 'moscow'), 'section' => 'moscow_header_type', 'description' => __('Select the header type for all pages except the front page', 'moscow'), 'choices' => array('bulletin' => __('Bulletin', 'moscow'), 'image' => __('Image', 'moscow'), 'nothing' => __('Nothing (only menu)', 'moscow'))));
/* HEADER BULLETIN
------------------------------*/
$wp_customize->add_section('moscow_bulletin', array('title' => __('Header Bulletin', 'moscow'), 'description' => __('You can add a background image to the bulletin. Make sure you select where to display your bulletin from the "Header Type" tab found above. You can also add a button or two (scroll down to find the options).', 'moscow'), 'priority' => 11, 'panel' => 'moscow_header_panel'));
// Bulletin height
$wp_customize->add_setting('bulletin_height', array('sanitize_callback' => 'absint', 'default' => '60'));
$wp_customize->add_control('bulletin_height', array('type' => 'number', 'priority' => 12, 'section' => 'moscow_bulletin', 'label' => __('Bulletin height (% of window height) [default: 60%]', 'moscow'), 'input_attrs' => array('min' => 5, 'max' => 100, 'step' => 5)));
// Bulletin background image
$wp_customize->add_setting('moscow_options[info]', array('type' => 'info_control', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_attr'));
$wp_customize->add_control(new Moscow_Info($wp_customize, 'bulletin_background_label', array('label' => __('Background', 'moscow'), 'section' => 'moscow_bulletin', 'settings' => 'moscow_options[info]', 'priority' => 13)));
$wp_customize->add_setting('bulletin_image', array('sanitize_callback' => 'esc_url_raw', 'default' => $default_bulletin_background));
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'bulletin_image', array('label' => __('Bulletin background image', 'moscow'), 'type' => 'image', 'section' => 'moscow_bulletin', 'settings' => 'bulletin_image', 'priority' => 14)));
// Bulletin background size
$wp_customize->add_setting('bulletin_bg_size', array('default' => 'cover', 'sanitize_callback' => 'moscow_sanitize_bg_size'));
$wp_customize->add_control('bulletin_bg_size', array('type' => 'radio', 'priority' => 15, 'label' => __('Bulletin background size', 'moscow'), 'section' => 'moscow_bulletin', 'choices' => array('cover' => __('Cover', 'moscow'), 'contain' => __('Contain', 'moscow'), 'auto' => __('Auto', 'moscow'))));
// Bulletin background repeat
$wp_customize->add_setting('bulletin_bg_repeat', array('default' => 'no-repeat', 'sanitize_callback' => 'moscow_sanitize_bg_repeat'));
$wp_customize->add_control('bulletin_bg_repeat', array('type' => 'radio', 'priority' => 16, 'label' => __('Bulletin background repeat', 'moscow'), 'section' => 'moscow_bulletin', 'choices' => array('no-repeat' => __('No Repeat', 'moscow'), 'repeat' => __('Repeat', 'moscow'), 'repeat-x' => __('Repeat-X', 'moscow'), 'repeat-y' => __('Repeat-Y', 'moscow'))));
// Title
$wp_customize->add_setting('moscow_options[info]', array('type' => 'info_control', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_attr'));
$wp_customize->add_control(new Moscow_Info($wp_customize, 'bulletin_title_label', array('label' => __('Title', 'moscow'), 'section' => 'moscow_bulletin', 'settings' => 'moscow_options[info]', 'priority' => 17)));
$wp_customize->add_setting('bulletin_title', array('default' => __('Welcome to moscow', 'moscow'), 'sanitize_callback' => 'moscow_sanitize_text'));
$wp_customize->add_control('bulletin_title', array('label' => __('Title for bulletin', 'moscow'), 'section' => 'moscow_bulletin', 'type' => 'text', 'priority' => 18));
// Subtitle
$wp_customize->add_setting('bulletin_subtitle', array('default' => __('Feel free to look around', 'moscow'), 'sanitize_callback' => 'moscow_sanitize_text'));
$wp_customize->add_control('bulletin_subtitle', array('label' => __('Subtitle for bulletin', 'moscow'), 'section' => 'moscow_bulletin', 'type' => 'text', 'priority' => 19));
// Bulletin button
$wp_customize->add_setting('moscow_options[info]', array('type' => 'info_control', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'esc_attr'));
$wp_customize->add_control(new Moscow_Info($wp_customize, 'bulletin_button_label', array('label' => __('Button', 'moscow'), 'section' => 'moscow_bulletin', 'settings' => 'moscow_options[info]', 'priority' => 20)));
// Button 1
$wp_customize->add_setting('bulletin_button_1_text', array('default' => __('Click to begin', 'moscow'), 'sanitize_callback' => 'moscow_sanitize_text'));
$wp_customize->add_control('bulletin_button_1_text', array('label' => __('Button 1 text', 'moscow'), 'section' => 'moscow_bulletin', 'type' => 'text', 'priority' => 21));
$wp_customize->add_setting('bulletin_button_1_url', array('default' => '#', 'sanitize_callback' => 'esc_url_raw'));
$wp_customize->add_control('bulletin_button_1_url', array('label' => __('Button 1 URL', 'moscow'), 'section' => 'moscow_bulletin', 'type' => 'text', 'priority' => 22));
// Button 2
$wp_customize->add_setting('bulletin_button_2_text', array('default' => __('Click to begin', 'moscow'), 'sanitize_callback' => 'moscow_sanitize_text'));
$wp_customize->add_control('bulletin_button_2_text', array('label' => __('Button 2 text', 'moscow'), 'section' => 'moscow_bulletin', 'type' => 'text', 'priority' => 23));
$wp_customize->add_setting('bulletin_button_2_url', array('default' => '#', 'sanitize_callback' => 'esc_url_raw'));
$wp_customize->add_control('bulletin_button_2_url', array('label' => __('Button 2 URL', 'moscow'), 'section' => 'moscow_bulletin', 'type' => 'text', 'priority' => 24));
/* HEADER IMAGE
------------------------------*/
// Header background size
$wp_customize->add_setting('header_bg_size', array('default' => 'cover', 'sanitize_callback' => 'moscow_sanitize_bg_size'));
$wp_customize->add_control('header_bg_size', array('type' => 'radio', 'priority' => 10, 'label' => __('Header background size', 'moscow'), 'section' => 'header_image', 'choices' => array('cover' => __('Cover', 'moscow'), 'contain' => __('Contain', 'moscow'), 'auto' => __('Auto', 'moscow'))));
// Header background repeat
$wp_customize->add_setting('header_bg_repeat', array('default' => 'no-repeat', 'sanitize_callback' => 'moscow_sanitize_bg_repeat'));
$wp_customize->add_control('header_bg_repeat', array('type' => 'radio', 'priority' => 11, 'label' => __('Header background repeat', 'moscow'), 'section' => 'header_image', 'choices' => array('no-repeat' => __('No Repeat', 'moscow'), 'repeat' => __('Repeat', 'moscow'), 'repeat-x' => __('Repeat-X', 'moscow'), 'repeat-y' => __('Repeat-Y', 'moscow'))));
// Header height
$wp_customize->add_setting('header_height', array('sanitize_callback' => 'absint', 'default' => '20'));
$wp_customize->add_control('header_height', array('type' => 'number', 'priority' => 12, 'section' => 'header_image', 'label' => __('Header height (% of window height) [default: 20%]', 'moscow'), 'input_attrs' => array('min' => 5, 'max' => 100, 'step' => 5)));
/* COLORS
------------------------------*/
// Primary color
$wp_customize->add_setting('primary_color', array('default' => '#E62B1E', 'sanitize_callback' => 'sanitize_hex_color'));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'primary_color', array('label' => __('Primary color', 'moscow'), 'section' => 'colors', 'settings' => 'primary_color', 'priority' => 10)));
// Quiet link color
$wp_customize->add_setting('quiet_link_color', array('default' => '#000000', 'sanitize_callback' => 'sanitize_hex_color'));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'quiet_link_color', array('label' => __('Quiet link color', 'moscow'), 'section' => 'colors', 'settings' => 'quiet_link_color', 'priority' => 12)));
//.........这里部分代码省略.........
示例10: store_customize_register
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function store_customize_register($wp_customize)
{
$wp_customize->get_setting('blogname')->transport = 'postMessage';
$wp_customize->get_setting('blogdescription')->transport = 'postMessage';
//Logo Settings
$wp_customize->add_section('title_tagline', array('title' => __('Title, Tagline & Logo', 'store'), 'priority' => 30));
$wp_customize->add_setting('store_logo', array('default' => '', 'sanitize_callback' => 'esc_url_raw'));
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'store_logo', array('label' => 'Upload Logo', 'section' => 'title_tagline', 'settings' => 'store_logo', 'priority' => 5)));
$wp_customize->add_setting('store_logo_resize', array('default' => 100, 'sanitize_callback' => 'store_sanitize_positive_number'));
$wp_customize->add_control('store_logo_resize', array('label' => __('Resize & Adjust Logo', 'store'), 'section' => 'title_tagline', 'settings' => 'store_logo_resize', 'priority' => 6, 'type' => 'range', 'active_callback' => 'store_logo_enabled', 'input_attrs' => array('min' => 30, 'max' => 200, 'step' => 5)));
function store_logo_enabled($control)
{
$option = $control->manager->get_setting('store_logo');
return $option->value() == true;
}
//Replace Header Text Color with, separate colors for Title and Description
//Override store_site_titlecolor
$wp_customize->remove_control('display_header_text');
$wp_customize->remove_setting('header_textcolor');
$wp_customize->add_setting('store_site_titlecolor', array('default' => '#FFFFFF', 'sanitize_callback' => 'sanitize_hex_color'));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'store_site_titlecolor', array('label' => __('Site Title Color', 'store'), 'section' => 'colors', 'settings' => 'store_site_titlecolor', 'type' => 'color')));
$wp_customize->add_setting('store_header_desccolor', array('default' => '#FFFFFF', 'sanitize_callback' => 'sanitize_hex_color'));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'store_header_desccolor', array('label' => __('Site Tagline Color', 'store'), 'section' => 'colors', 'settings' => 'store_header_desccolor', 'type' => 'color')));
//Settings for Nav Area
$wp_customize->add_setting('store_disable_nav_desc', array('default' => false, 'sanitize_callback' => 'store_sanitize_checkbox'));
$wp_customize->add_control('store_disable_nav_desc', array('label' => __('Disable Description of Menu Items', 'store'), 'section' => 'nav', 'settings' => 'store_disable_nav_desc', 'type' => 'checkbox'));
//Settings For Logo Area
$wp_customize->add_setting('store_hide_title_tagline', array('sanitize_callback' => 'store_sanitize_checkbox'));
$wp_customize->add_control('store_hide_title_tagline', array('settings' => 'store_hide_title_tagline', 'label' => __('Hide Title and Tagline.', 'store'), 'section' => 'title_tagline', 'type' => 'checkbox'));
function store_title_visible($control)
{
$option = $control->manager->get_setting('store_hide_title_tagline');
return $option->value() == false;
}
//SLIDER
// SLIDER PANEL
$wp_customize->add_panel('store_slider_panel', array('priority' => 35, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => 'Main Slider'));
$wp_customize->add_section('store_sec_slider_options', array('title' => 'Enable/Disable', 'priority' => 0, 'panel' => 'store_slider_panel'));
$wp_customize->add_setting('store_main_slider_enable', array('sanitize_callback' => 'store_sanitize_checkbox'));
$wp_customize->add_control('store_main_slider_enable', array('settings' => 'store_main_slider_enable', 'label' => __('Enable Slider on HomePage.', 'store'), 'section' => 'store_sec_slider_options', 'type' => 'checkbox'));
$wp_customize->add_setting('store_main_slider_count', array('default' => '0', 'sanitize_callback' => 'store_sanitize_positive_number'));
// Select How Many Slides the User wants, and Reload the Page.
$wp_customize->add_control('store_main_slider_count', array('settings' => 'store_main_slider_count', 'label' => __('No. of Slides(Min:0, Max: 10)', 'store'), 'section' => 'store_sec_slider_options', 'type' => 'number', 'description' => __('Save the Settings, and Reload this page to Configure the Slides.', 'store')));
for ($i = 1; $i <= 10; $i++) {
//Create the settings Once, and Loop through it.
static $x = 0;
$wp_customize->add_section('store_slide_sec' . $i, array('title' => 'Slide ' . $i, 'priority' => $i, 'panel' => 'store_slider_panel', 'active_callback' => 'store_show_slide_sec'));
$wp_customize->add_setting('store_slide_img' . $i, array('sanitize_callback' => 'esc_url_raw'));
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'store_slide_img' . $i, array('label' => '', 'section' => 'store_slide_sec' . $i, 'settings' => 'store_slide_img' . $i)));
$wp_customize->add_setting('store_slide_title' . $i, array('sanitize_callback' => 'sanitize_text_field'));
$wp_customize->add_control('store_slide_title' . $i, array('settings' => 'store_slide_title' . $i, 'label' => __('Slide Title', 'store'), 'section' => 'store_slide_sec' . $i, 'type' => 'text'));
$wp_customize->add_setting('store_slide_desc' . $i, array('sanitize_callback' => 'sanitize_text_field'));
$wp_customize->add_control('store_slide_desc' . $i, array('settings' => 'store_slide_desc' . $i, 'label' => __('Slide Description', 'store'), 'section' => 'store_slide_sec' . $i, 'type' => 'text'));
$wp_customize->add_setting('store_slide_CTA_button' . $i, array('sanitize_callback' => 'sanitize_text_field'));
$wp_customize->add_control('store_slide_CTA_button' . $i, array('settings' => 'store_slide_CTA_button' . $i, 'label' => __('Custom Call to Action Button Text(Optional)', 'store'), 'section' => 'store_slide_sec' . $i, 'type' => 'text'));
$wp_customize->add_setting('store_slide_url' . $i, array('sanitize_callback' => 'esc_url_raw'));
$wp_customize->add_control('store_slide_url' . $i, array('settings' => 'store_slide_url' . $i, 'label' => __('Target URL', 'store'), 'section' => 'store_slide_sec' . $i, 'type' => 'url'));
}
//active callback to see if the slide section is to be displayed or not
function store_show_slide_sec($control)
{
$option = $control->manager->get_setting('store_main_slider_count');
global $x;
if ($x < $option->value()) {
$x++;
return true;
}
}
if (class_exists('woocommerce')) {
// CREATE THE fcp PANEL
$wp_customize->add_panel('store_fcp_panel', array('priority' => 40, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => 'Featured Product Showcase', 'description' => ''));
//SQUARE BOXES
$wp_customize->add_section('store_fc_boxes', array('title' => 'Square Boxes', 'priority' => 10, 'panel' => 'store_fcp_panel'));
$wp_customize->add_setting('store_box_enable', array('sanitize_callback' => 'store_sanitize_checkbox'));
$wp_customize->add_control('store_box_enable', array('settings' => 'store_box_enable', 'label' => __('Enable Square Boxes & Posts Slider.', 'store'), 'section' => 'store_fc_boxes', 'type' => 'checkbox'));
$wp_customize->add_setting('store_box_title', array('sanitize_callback' => 'sanitize_text_field'));
$wp_customize->add_control('store_box_title', array('settings' => 'store_box_title', 'label' => __('Title for the Boxes', 'store'), 'section' => 'store_fc_boxes', 'type' => 'text'));
$wp_customize->add_setting('store_box_cat', array('sanitize_callback' => 'store_sanitize_product_category'));
$wp_customize->add_control(new WP_Customize_Product_Category_Control($wp_customize, 'store_box_cat', array('label' => __('Product Category.', 'store'), 'settings' => 'store_box_cat', 'section' => 'store_fc_boxes')));
//SLIDER
$wp_customize->add_section('store_fc_slider', array('title' => __('3D Cube Products Slider', 'store'), 'priority' => 10, 'panel' => 'store_fcp_panel', 'description' => 'This is the Posts Slider, displayed left to the square boxes.'));
$wp_customize->add_setting('store_slider_title', array('sanitize_callback' => 'sanitize_text_field'));
$wp_customize->add_control('store_slider_title', array('settings' => 'store_slider_title', 'label' => __('Title for the Slider', 'store'), 'section' => 'store_fc_slider', 'type' => 'text'));
$wp_customize->add_setting('store_slider_count', array('sanitize_callback' => 'store_sanitize_positive_number'));
$wp_customize->add_control('store_slider_count', array('settings' => 'store_slider_count', 'label' => __('No. of Posts(Min:3, Max: 10)', 'store'), 'section' => 'store_fc_slider', 'type' => 'range', 'input_attrs' => array('min' => 3, 'max' => 10, 'step' => 1, 'class' => 'test-class test', 'style' => 'color: #0a0')));
$wp_customize->add_setting('store_slider_cat', array('sanitize_callback' => 'store_sanitize_product_category'));
$wp_customize->add_control(new WP_Customize_Product_Category_Control($wp_customize, 'store_slider_cat', array('label' => __('Category For Slider.', 'store'), 'settings' => 'store_slider_cat', 'section' => 'store_fc_slider')));
//COVERFLOW
$wp_customize->add_section('store_fc_coverflow', array('title' => __('Top CoverFlow Slider', 'store'), 'priority' => 5, 'panel' => 'store_fcp_panel'));
$wp_customize->add_setting('store_coverflow_enable', array('sanitize_callback' => 'store_sanitize_checkbox'));
$wp_customize->add_control('store_coverflow_enable', array('settings' => 'store_coverflow_enable', 'label' => __('Enable', 'store'), 'section' => 'store_fc_coverflow', 'type' => 'checkbox'));
$wp_customize->add_setting('store_coverflow_cat', array('sanitize_callback' => 'store_sanitize_product_category'));
$wp_customize->add_control(new WP_Customize_Product_Category_Control($wp_customize, 'store_coverflow_cat', array('label' => __('Category For Image Grid', 'store'), 'settings' => 'store_coverflow_cat', 'section' => 'store_fc_coverflow')));
$wp_customize->add_setting('store_coverflow_pc', array('sanitize_callback' => 'store_sanitize_positive_number'));
$wp_customize->add_control('store_coverflow_pc', array('settings' => 'store_coverflow_pc', 'label' => __('Max No. of Posts in the Grid. Min: 5.', 'store'), 'section' => 'store_fc_coverflow', 'type' => 'number', 'default' => '0'));
//.........这里部分代码省略.........
示例11: semifolio_customize_register
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function semifolio_customize_register($wp_customize)
{
$wp_customize->get_setting('blogname')->transport = 'postMessage';
$wp_customize->get_setting('blogdescription')->transport = 'postMessage';
/**
* Remove setting & control
*/
$wp_customize->remove_setting('display_header_text');
$wp_customize->remove_control('display_header_text');
$wp_customize->remove_section('color');
$wp_customize->remove_setting('header_textcolor');
$wp_customize->remove_control('header_textcolor');
/**
* Textarea customize control class.
*/
if (class_exists('WP_Customize_Control')) {
class Semifolio_Customize_Textarea_Control extends WP_Customize_Control
{
public $type = 'textarea';
public function render_content()
{
?>
<label>
<span class="customize-control-title"><?php
echo esc_html($this->label);
?>
</span>
<textarea rows= "5" style="width:100%;"<?php
$this->link();
?>
><?php
echo esc_textarea($this->value());
?>
</textarea>
</label>
<?php
}
}
}
/**
* Text attribute customize control class.
*/
if (class_exists('WP_Customize_Control')) {
class Semifolio_Customize_Info_Control extends WP_Customize_Control
{
public $type = 'info';
public function render_content()
{
?>
<label>
<span class="customize-control-title"><?php
echo esc_html($this->label);
?>
</span>
<span <?php
$this->link();
?>
><?php
echo esc_attr($this->value());
?>
</span>
</label>
<?php
}
}
}
/*----------------------------------------------------------------------------------------*/
/* Blog Options.
/*----------------------------------------------------------------------------------------*/
$wp_customize->add_section('semifolio_blog_options', array('title' => __('Blog Options', 'semifolio'), 'description' => '', 'priority' => 1));
// Display Popular Post
$wp_customize->add_setting('semifolio_display_popular_post_setting', array('default' => 0, 'capability' => 'edit_theme_options', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'semifolio_sanitize_checkbox'));
$wp_customize->add_control('popular_post', array('label' => __('Do You want to display popular post?', 'semifolio'), 'section' => 'semifolio_blog_options', 'settings' => 'semifolio_display_popular_post_setting', 'type' => 'checkbox', 'priority' => 1));
// Display Slideshow
$wp_customize->add_setting('semifolio_display_portfolio_setting', array('default' => 0, 'capability' => 'edit_theme_options', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'semifolio_sanitize_checkbox'));
$wp_customize->add_control('portfolio_post', array('settings' => 'semifolio_display_portfolio_setting', 'label' => __('Do You want to display portfolio post?', 'semifolio'), 'section' => 'semifolio_blog_options', 'type' => 'checkbox', 'priority' => 2));
// Post Type Portfolio
$wp_customize->add_setting('semifolio_posttype_portfolio', array('default' => 'page', 'capability' => 'edit_theme_options', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'semifolio_sanitize_text_attribute'));
$wp_customize->add_control(new Semifolio_Customize_Textarea_Control($wp_customize, 'posttype_portfolio', array('label' => __('Input post type just for custom post portfolio, separated by commas if use more than one of post type. This support post type from plugin installed. Example: ( default blog: "post", "page" )', 'semifolio'), 'section' => 'semifolio_blog_options', 'settings' => 'semifolio_posttype_portfolio', 'type' => 'textarea', 'priority' => 3)));
/*----------------------------------------------------------------------------------------*/
/* Layout Options Section
/*----------------------------------------------------------------------------------------*/
$wp_customize->add_section('semifolio_layout_options', array('title' => __('Layout Options', 'semifolio'), 'description' => '', 'priority' => 2));
// Display Favicon
$wp_customize->add_setting('semifolio_display_favicon_icon', array('default' => 0, 'capability' => 'edit_theme_options', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'semifolio_sanitize_checkbox'));
$wp_customize->add_control('display_favicon_icon', array('settings' => 'semifolio_display_favicon_icon', 'label' => __('Do you want to display favicon?', 'semifolio'), 'section' => 'semifolio_layout_options', 'type' => 'checkbox', 'priority' => 1));
// Upload Favicon Icon
$wp_customize->add_setting('semifolio_upload_favicon_icon', array('capability' => 'edit_theme_options', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'esc_url_raw'));
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'upload_favicon_icon', array('label' => __('Upload Favicon:', 'semifolio'), 'section' => 'semifolio_layout_options', 'settings' => 'semifolio_upload_favicon_icon', 'priority' => 2)));
// Upload Header Ads Image
$wp_customize->add_setting('semifolio_upload_header_ads', array('capability' => 'edit_theme_options', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'esc_url_raw'));
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'upload_header_ads', array('label' => __('Upload Header Ads Image:', 'semifolio'), 'section' => 'semifolio_layout_options', 'settings' => 'semifolio_upload_header_ads', 'priority' => 3)));
// Header Ads URL
$wp_customize->add_setting('semifolio_header_ads_url', array('default' => '', 'capability' => 'edit_theme_options', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'semifolio_sanitize_text_attribute'));
$wp_customize->add_control(new Semifolio_Customize_Textarea_Control($wp_customize, 'header_ads_url', array('label' => __('Input Full URL Header Ads', 'semifolio'), 'section' => 'semifolio_layout_options', 'settings' => 'semifolio_header_ads_url', 'type' => 'textarea', 'priority' => 4)));
//.........这里部分代码省略.........
示例12: array
/**
* @ticket 34597
*/
function test_add_setting_honoring_dynamic() {
$manager = new WP_Customize_Manager();
$setting_id = 'dynamic';
$setting = $manager->add_setting( $setting_id );
$this->assertEquals( 'WP_Customize_Setting', get_class( $setting ) );
$this->assertObjectNotHasAttribute( 'custom', $setting );
$manager->remove_setting( $setting_id );
add_filter( 'customize_dynamic_setting_class', array( $this, 'return_dynamic_customize_setting_class' ), 10, 3 );
add_filter( 'customize_dynamic_setting_args', array( $this, 'return_dynamic_customize_setting_args' ), 10, 2 );
$setting = $manager->add_setting( $setting_id );
$this->assertEquals( 'Test_Dynamic_Customize_Setting', get_class( $setting ) );
$this->assertObjectHasAttribute( 'custom', $setting );
$this->assertEquals( 'foo', $setting->custom );
}
示例13: decode_customize_register
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
public static function decode_customize_register($wp_customize)
{
$wp_customize->get_setting('blogname')->transport = 'postMessage';
$wp_customize->get_setting('blogdescription')->transport = 'postMessage';
$wp_customize->get_setting('header_textcolor')->transport = 'postMessage';
$wp_customize->get_setting('background_color')->transport = 'postMessage';
/**
* Remove old, now unused theme modifications so that conflicts do not occur.
* One of these work, sometimes. Hopefully this will clear old settings.
*/
remove_theme_mod('youtube_username');
remove_theme_mod('show_site_navigation');
remove_theme_mod('show_social_icons');
remove_theme_mod('enable_comments');
remove_theme_mod('linkedin_username');
remove_theme_mod('yelp_userid');
remove_theme_mod('steam_user');
remove_theme_mod('steam_group');
remove_theme_mod('show_all_post_types');
$wp_customize->remove_setting('youtube_username');
$wp_customize->remove_setting('show_site_navigation');
$wp_customize->remove_setting('show_social_icons');
$wp_customize->remove_setting('enable_comments');
$wp_customize->remove_setting('yelp_userid');
$wp_customize->remove_setting('steam_user');
$wp_customize->remove_setting('steam_group');
$wp_customize->remove_setting('show_all_post_types');
/**
* Header Options
*/
$wp_customize->add_section('decode_header_options', array('title' => __('Header Options', 'decode'), 'priority' => 32));
$wp_customize->add_setting('favicon_image', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('show_site_title', array('default' => true, 'sanitize_callback' => 'decode_sanitize_boolean'));
$wp_customize->add_setting('show_site_description', array('default' => true, 'sanitize_callback' => 'decode_sanitize_boolean'));
$wp_customize->add_setting('show_header_menu', array('default' => true, 'sanitize_callback' => 'decode_sanitize_boolean'));
$wp_customize->add_setting('html_description', array('default' => '', 'transport' => 'postMessage', 'sanitize_callback' => 'decode_sanitize_html'));
$wp_customize->add_control(new Decode_Customize_Favicon_Image_Control($wp_customize, 'favicon_image', array('label' => __('Favicon Image (must be a PNG)', 'decode'), 'section' => 'decode_header_options', 'settings' => 'favicon_image', 'priority' => 1)));
$wp_customize->add_control('show_site_title', array('label' => __('Show Site Title', 'decode'), 'section' => 'decode_header_options', 'type' => 'checkbox', 'priority' => 2));
$wp_customize->add_control('show_site_description', array('label' => __('Show Site Description', 'decode'), 'section' => 'decode_header_options', 'type' => 'checkbox', 'priority' => 3));
$wp_customize->add_control('show_header_menu', array('label' => __('Show Header Menu', 'decode'), 'section' => 'decode_header_options', 'type' => 'checkbox', 'priority' => 4));
$wp_customize->add_control('html_description', array('label' => __('HTML for description, if you wish to replace your blog description with HTML markup', 'decode'), 'section' => 'decode_header_options', 'active_callback' => 'decode_description_is_displayed', 'type' => 'text', 'priority' => 5));
/**
* Sidebar Options
*/
$wp_customize->add_section('decode_sidebar_options', array('title' => __('Sidebar Options', 'decode'), 'priority' => 33));
$wp_customize->add_setting('show_sidebar', array('default' => true, 'transport' => 'refresh', 'sanitize_callback' => 'decode_sanitize_boolean'));
$wp_customize->add_setting('sidebar_position', array('default' => 'left', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('sidebar_button_position', array('default' => 'left', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('constant_sidebar', array('default' => 'closing', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_control('show_sidebar', array('label' => __('Enable Sidebar', 'decode'), 'section' => 'decode_sidebar_options', 'type' => 'checkbox', 'priority' => 1));
$wp_customize->add_control('sidebar_position', array('label' => __('Sidebar Position', 'decode'), 'section' => 'decode_sidebar_options', 'active_callback' => 'decode_sidebar_is_enabled', 'type' => 'radio', 'choices' => array('left' => __('Left', 'decode'), 'right' => __('Right', 'decode')), 'priority' => 2));
$wp_customize->add_control('sidebar_button_position', array('label' => __('Sidebar Button Position', 'decode'), 'section' => 'decode_sidebar_options', 'active_callback' => 'decode_sidebar_is_enabled', 'type' => 'radio', 'choices' => array('left' => __('Left', 'decode'), 'right' => __('Right', 'decode')), 'priority' => 3));
$wp_customize->add_control('constant_sidebar', array('label' => __('Always Visible Sidebar', 'decode'), 'section' => 'decode_sidebar_options', 'active_callback' => 'decode_plus_electric_slide_sidebar_is_not_enabled', 'type' => 'radio', 'choices' => array('constant' => _x('Always open', 'Sidebar option', 'decode'), 'closing' => _x('Closed by default', 'Sidebar option', 'decode')), 'priority' => 4));
/**
* Social Options
*/
$wp_customize->add_section('decode_social_options', array('title' => __('Social Options', 'decode'), 'priority' => 35));
$wp_customize->add_setting('show_header_social_icons', array('default' => false, 'sanitize_callback' => 'decode_sanitize_boolean'));
$wp_customize->add_setting('show_footer_social_icons', array('default' => false, 'sanitize_callback' => 'decode_sanitize_boolean'));
$wp_customize->add_setting('open_links_in_new_tab', array('default' => false, 'sanitize_callback' => 'decode_sanitize_boolean'));
$wp_customize->add_setting('twitter_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('facebook_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('google_plus_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('ello_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('adn_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('sina_weibo_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('myspace_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('diaspora_id', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('vk_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('dribbble_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('behance_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('linkedin_profile_url', array('default' => '', 'sanitize_callback' => 'esc_url_raw'));
$wp_customize->add_setting('pinterest_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('fancy_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('etsy_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('pinboard_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('delicious_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('instagram_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('vsco_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('500px_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('flickr_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('deviantart_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('bandcamp_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('soundcloud_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('itunes_link', array('default' => '', 'sanitize_callback' => 'esc_url_raw'));
$wp_customize->add_setting('rdio_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('spotify_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('lastfm_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('vine_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('vimeo_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('youtube_url', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('kickstarter_url', array('default' => '', 'sanitize_callback' => 'esc_url_raw'));
$wp_customize->add_setting('gittip_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('goodreads_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
$wp_customize->add_setting('tumblr_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
//.........这里部分代码省略.........
示例14: store_customize_register
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function store_customize_register($wp_customize)
{
$wp_customize->get_setting('blogname')->transport = 'postMessage';
$wp_customize->get_setting('blogdescription')->transport = 'postMessage';
//Logo Settings
$wp_customize->add_section('title_tagline', array('title' => __('Title, Tagline & Logo', 'store'), 'priority' => 30));
$wp_customize->add_setting('store_logo', array('default' => '', 'sanitize_callback' => 'esc_url_raw'));
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'store_logo', array('label' => 'Upload Logo', 'section' => 'title_tagline', 'settings' => 'store_logo', 'priority' => 5)));
$wp_customize->add_setting('store_logo_resize', array('default' => 100, 'sanitize_callback' => 'store_sanitize_positive_number'));
$wp_customize->add_control('store_logo_resize', array('label' => __('Resize & Adjust Logo', 'store'), 'section' => 'title_tagline', 'settings' => 'store_logo_resize', 'priority' => 6, 'type' => 'range', 'active_callback' => 'store_logo_enabled', 'input_attrs' => array('min' => 30, 'max' => 200, 'step' => 5)));
function store_logo_enabled($control)
{
$option = $control->manager->get_setting('store_logo');
return $option->value() == true;
}
//Replace Header Text Color with, separate colors for Title and Description
//Override store_site_titlecolor
$wp_customize->remove_control('display_header_text');
$wp_customize->remove_setting('header_textcolor');
$wp_customize->add_setting('store_site_titlecolor', array('default' => '#FFFFFF', 'sanitize_callback' => 'sanitize_hex_color'));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'store_site_titlecolor', array('label' => __('Site Title Color', 'store'), 'section' => 'colors', 'settings' => 'store_site_titlecolor', 'type' => 'color')));
$wp_customize->add_setting('store_header_desccolor', array('default' => '#FFFFFF', 'sanitize_callback' => 'sanitize_hex_color'));
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'store_header_desccolor', array('label' => __('Site Tagline Color', 'store'), 'section' => 'colors', 'settings' => 'store_header_desccolor', 'type' => 'color')));
//Settings for Nav Area
$wp_customize->add_setting('store_disable_nav_desc', array('default' => false, 'sanitize_callback' => 'store_sanitize_checkbox'));
$wp_customize->add_control('store_disable_nav_desc', array('label' => __('Disable Description of Menu Items', 'store'), 'section' => 'nav', 'settings' => 'store_disable_nav_desc', 'type' => 'checkbox'));
//Settings For Logo Area
$wp_customize->add_setting('store_hide_title_tagline', array('sanitize_callback' => 'store_sanitize_checkbox'));
$wp_customize->add_control('store_hide_title_tagline', array('settings' => 'store_hide_title_tagline', 'label' => __('Hide Title and Tagline.', 'store'), 'section' => 'title_tagline', 'type' => 'checkbox'));
function store_title_visible($control)
{
$option = $control->manager->get_setting('store_hide_title_tagline');
return $option->value() == false;
}
if (class_exists('woocommerce')) {
// CREATE THE fcp PANEL
$wp_customize->add_panel('store_fcp_panel', array('priority' => 40, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => 'Featured Product Showcase', 'description' => ''));
//SQUARE BOXES
$wp_customize->add_section('store_fc_boxes', array('title' => 'Square Boxes', 'priority' => 10, 'panel' => 'store_fcp_panel'));
$wp_customize->add_setting('store_box_enable', array('sanitize_callback' => 'store_sanitize_checkbox'));
$wp_customize->add_control('store_box_enable', array('settings' => 'store_box_enable', 'label' => __('Enable Square Boxes & Posts Slider.', 'store'), 'section' => 'store_fc_boxes', 'type' => 'checkbox'));
$wp_customize->add_setting('store_box_title', array('sanitize_callback' => 'sanitize_text_field'));
$wp_customize->add_control('store_box_title', array('settings' => 'store_box_title', 'label' => __('Title for the Boxes', 'store'), 'section' => 'store_fc_boxes', 'type' => 'text'));
$wp_customize->add_setting('store_box_cat', array('sanitize_callback' => 'store_sanitize_product_category'));
$wp_customize->add_control(new WP_Customize_Product_Category_Control($wp_customize, 'store_box_cat', array('label' => __('Product Category.', 'store'), 'settings' => 'store_box_cat', 'section' => 'store_fc_boxes')));
//SLIDER
$wp_customize->add_section('store_fc_slider', array('title' => __('3D Cube Products Slider', 'store'), 'priority' => 10, 'panel' => 'store_fcp_panel', 'description' => 'This is the Posts Slider, displayed left to the square boxes.'));
$wp_customize->add_setting('store_slider_title', array('sanitize_callback' => 'sanitize_text_field'));
$wp_customize->add_control('store_slider_title', array('settings' => 'store_slider_title', 'label' => __('Title for the Slider', 'store'), 'section' => 'store_fc_slider', 'type' => 'text'));
$wp_customize->add_setting('store_slider_count', array('sanitize_callback' => 'store_sanitize_positive_number'));
$wp_customize->add_control('store_slider_count', array('settings' => 'store_slider_count', 'label' => __('No. of Posts(Min:3, Max: 10)', 'store'), 'section' => 'store_fc_slider', 'type' => 'range', 'input_attrs' => array('min' => 3, 'max' => 10, 'step' => 1, 'class' => 'test-class test', 'style' => 'color: #0a0')));
$wp_customize->add_setting('store_slider_cat', array('sanitize_callback' => 'store_sanitize_product_category'));
$wp_customize->add_control(new WP_Customize_Product_Category_Control($wp_customize, 'store_slider_cat', array('label' => __('Category For Slider.', 'store'), 'settings' => 'store_slider_cat', 'section' => 'store_fc_slider')));
//COVERFLOW
$wp_customize->add_section('store_fc_coverflow', array('title' => __('Top CoverFlow Slider', 'store'), 'priority' => 5, 'panel' => 'store_fcp_panel'));
$wp_customize->add_setting('store_coverflow_enable', array('sanitize_callback' => 'store_sanitize_checkbox'));
$wp_customize->add_control('store_coverflow_enable', array('settings' => 'store_coverflow_enable', 'label' => __('Enable', 'store'), 'section' => 'store_fc_coverflow', 'type' => 'checkbox'));
$wp_customize->add_setting('store_coverflow_cat', array('sanitize_callback' => 'store_sanitize_product_category'));
$wp_customize->add_control(new WP_Customize_Product_Category_Control($wp_customize, 'store_coverflow_cat', array('label' => __('Category For Image Grid', 'store'), 'settings' => 'store_coverflow_cat', 'section' => 'store_fc_coverflow')));
$wp_customize->add_setting('store_coverflow_pc', array('sanitize_callback' => 'store_sanitize_positive_number'));
$wp_customize->add_control('store_coverflow_pc', array('settings' => 'store_coverflow_pc', 'label' => __('Max No. of Posts in the Grid. Min: 5.', 'store'), 'section' => 'store_fc_coverflow', 'type' => 'number', 'default' => '0'));
}
//end class exists woocommerce
// Layout and Design
$wp_customize->add_panel('store_design_panel', array('priority' => 40, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __('Design & Layout', 'store')));
$wp_customize->add_section('store_design_options', array('title' => __('Blog Layout', 'store'), 'priority' => 0, 'panel' => 'store_design_panel'));
$wp_customize->add_setting('store_blog_layout', array('sanitize_callback' => 'store_sanitize_blog_layout'));
function store_sanitize_blog_layout($input)
{
if (in_array($input, array('grid', 'grid_2_column', 'store', 'store_3_column'))) {
return $input;
} else {
return '';
}
}
$wp_customize->add_control('store_blog_layout', array('label' => __('Select Layout', 'store'), 'settings' => 'store_blog_layout', 'section' => 'store_design_options', 'type' => 'select', 'choices' => array('grid' => __('Standard Blog Layout', 'store'), 'store' => __('Store Theme Layout', 'store'), 'store_3_column' => __('Store Theme Layout (3 Columns)', 'store'), 'grid_2_column' => __('Grid - 2 Column', 'store'))));
$wp_customize->add_section('store_sidebar_options', array('title' => __('Sidebar Layout', 'store'), 'priority' => 0, 'panel' => 'store_design_panel'));
$wp_customize->add_setting('store_disable_sidebar', array('sanitize_callback' => 'store_sanitize_checkbox'));
$wp_customize->add_control('store_disable_sidebar', array('settings' => 'store_disable_sidebar', 'label' => __('Disable Sidebar Everywhere.', 'store'), 'section' => 'store_sidebar_options', 'type' => 'checkbox', 'default' => false));
$wp_customize->add_setting('store_disable_sidebar_home', array('sanitize_callback' => 'store_sanitize_checkbox'));
$wp_customize->add_control('store_disable_sidebar_home', array('settings' => 'store_disable_sidebar_home', 'label' => __('Disable Sidebar on Home/Blog.', 'store'), 'section' => 'store_sidebar_options', 'type' => 'checkbox', 'active_callback' => 'store_show_sidebar_options', 'default' => false));
$wp_customize->add_setting('store_disable_sidebar_front', array('sanitize_callback' => 'store_sanitize_checkbox'));
$wp_customize->add_control('store_disable_sidebar_front', array('settings' => 'store_disable_sidebar_front', 'label' => __('Disable Sidebar on Front Page.', 'store'), 'section' => 'store_sidebar_options', 'type' => 'checkbox', 'active_callback' => 'store_show_sidebar_options', 'default' => false));
$wp_customize->add_setting('store_sidebar_width', array('default' => 4, 'sanitize_callback' => 'store_sanitize_positive_number'));
$wp_customize->add_control('store_sidebar_width', array('settings' => 'store_sidebar_width', 'label' => __('Sidebar Width', 'store'), 'description' => __('Min: 25%, Default: 33%, Max: 40%', 'store'), 'section' => 'store_sidebar_options', 'type' => 'range', 'active_callback' => 'store_show_sidebar_options', 'input_attrs' => array('min' => 3, 'max' => 5, 'step' => 1, 'class' => 'sidebar-width-range', 'style' => 'color: #0a0')));
/* Active Callback Function */
function store_show_sidebar_options($control)
{
$option = $control->manager->get_setting('store_disable_sidebar');
return $option->value() == false;
}
class Store_Custom_CSS_Control extends WP_Customize_Control
{
public $type = 'textarea';
public function render_content()
//.........这里部分代码省略.........
示例15: slaves_customize_register
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function slaves_customize_register($wp_customize)
{
$wp_customize->get_setting('blogname')->transport = 'postMessage';
$wp_customize->get_setting('blogdescription')->transport = 'postMessage';
$wp_customize->remove_setting('display_header_text');
$wp_customize->remove_control('display_header_text');
$wp_customize->remove_section('color');
$wp_customize->remove_setting('header_textcolor');
$wp_customize->remove_control('header_textcolor');
/**
* Textarea customize control class.
*/
if (class_exists('WP_Customize_Control')) {
class Slaves_Customize_Textarea_Control extends WP_Customize_Control
{
public $type = 'textarea';
public function render_content()
{
?>
<label>
<span class="customize-control-title"><?php
echo esc_html($this->label);
?>
</span>
<textarea rows= "5" style="width:100%;"<?php
$this->link();
?>
><?php
echo esc_textarea($this->value());
?>
</textarea>
</label>
<?php
}
}
}
/**
* Text attribute customize control class.
*/
if (class_exists('WP_Customize_Control')) {
class Slaves_Customize_Info_Control extends WP_Customize_Control
{
public $type = 'info';
public function render_content()
{
?>
<label>
<span class="customize-control-title"><?php
echo esc_html($this->label);
?>
</span>
<span <?php
$this->link();
?>
><?php
echo esc_attr($this->value());
?>
</span>
</label>
<?php
}
}
}
/*----------------------------------------------------------------------------------------*/
/* Slaves Options.
/*----------------------------------------------------------------------------------------*/
$wp_customize->add_section('slaves_options', array('title' => __('Slaves Default Options', 'slaves'), 'description' => '', 'priority' => 1));
// Column Layout
$wp_customize->add_setting('slaves_column_option', array('default' => 2, 'capability' => 'edit_theme_options', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'slaves_sanitize_column_layout'));
$wp_customize->add_control('column_layout', array('label' => __('Select Column Layout for the page of the home, archive, category, search & tag.', 'slaves'), 'section' => 'slaves_options', 'settings' => 'slaves_column_option', 'type' => 'radio', 'choices' => array('1' => 'Two column', '2' => 'Three column'), 'priority' => 1));
// Display Favicon
$wp_customize->add_setting('slaves_display_favicon_icon', array('default' => 0, 'capability' => 'edit_theme_options', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'slaves_sanitize_checkbox'));
$wp_customize->add_control('display_favicon_icon', array('settings' => 'slaves_display_favicon_icon', 'label' => __('Do you want to display favicon?', 'slaves'), 'section' => 'slaves_options', 'type' => 'checkbox', 'priority' => 2));
// Upload Favicon Icon
$wp_customize->add_setting('slaves_upload_favicon_icon', array('capability' => 'edit_theme_options', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'esc_url_raw'));
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'upload_favicon_icon', array('label' => __('Upload Favicon:', 'slaves'), 'section' => 'slaves_options', 'settings' => 'slaves_upload_favicon_icon', 'priority' => 3)));
// Welcome Message Title
$wp_customize->add_setting('slaves_welcome_title', array('default' => '', 'capability' => 'edit_theme_options', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'slaves_sanitize_text_attribute'));
$wp_customize->add_control(new Slaves_Customize_Textarea_Control($wp_customize, 'welcome_title', array('label' => __('Input text of the title welcome message.', 'slaves'), 'section' => 'slaves_options', 'settings' => 'slaves_welcome_title', 'type' => 'textarea', 'priority' => 4)));
// Welcome Message Text
$wp_customize->add_setting('slaves_welcome_message', array('default' => '', 'capability' => 'edit_theme_options', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'slaves_sanitize_text_attribute'));
$wp_customize->add_control(new Slaves_Customize_Textarea_Control($wp_customize, 'welcome_message', array('label' => __('Input of the welcome message.', 'slaves'), 'section' => 'slaves_options', 'settings' => 'slaves_welcome_message', 'type' => 'textarea', 'priority' => 5)));
// Display Posts Featured Images
$wp_customize->add_setting('slaves_display_featured_images', array('default' => 0, 'capability' => 'edit_theme_options', 'type' => 'option', 'transport' => 'refresh', 'sanitize_callback' => 'slaves_sanitize_checkbox'));
$wp_customize->add_control('display_featured_images', array('settings' => 'slaves_display_featured_images', 'label' => __('Do You want to display posts featured images?', 'slaves'), 'section' => 'slaves_options', 'type' => 'checkbox', 'priority' => 6));
// Display Footer Widget
$wp_customize->add_setting('slaves_display_footer_widget', array('default' => 0, 'capability' => 'edit_theme_options', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'slaves_sanitize_checkbox'));
$wp_customize->add_control('display_footer_widget', array('settings' => 'slaves_display_footer_widget', 'label' => __('Do You want to display Footer Widget?', 'slaves'), 'section' => 'slaves_options', 'type' => 'checkbox', 'priority' => 7));
}