remove_setting() публичный Метод

Remove a customize setting.
С версии: 3.4.0
public remove_setting ( string $id )
$id string Customize Setting ID.
Пример #1
0
/**
 * 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
0
 /**
  * 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
0
 /**
  * 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)));
 }
 /**
  * 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);
         }
     }
 }
 /**
  * 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
0
/**
 * 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
0
/**
 * 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
0
 /**
  * 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
0
/**
 * 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)));
    // Bulletin text color
    $wp_customize->add_setting('bulletin_text_color', array('default' => '#FFFFFF', 'sanitize_callback' => 'sanitize_hex_color'));
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'bulletin_text_color', array('label' => __('Bulletin text color', 'moscow'), 'section' => 'colors', 'settings' => 'bulletin_text_color', 'priority' => 13)));
    // Body text color
    $wp_customize->add_setting('body_text_color', array('default' => '#000000', 'sanitize_callback' => 'sanitize_hex_color'));
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'body_text_color', array('label' => __('Body text color', 'moscow'), 'section' => 'colors', 'settings' => 'body_text_color', 'priority' => 14)));
    // Footer background color
    $wp_customize->add_setting('footer_bg_color', array('default' => '#000000', 'sanitize_callback' => 'sanitize_hex_color'));
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'footer_bg_color', array('label' => __('Footer background color', 'moscow'), 'section' => 'colors', 'settings' => 'footer_bg_color', 'priority' => 15)));
    // Footer text color
    $wp_customize->add_setting('footer_text_color', array('default' => '#7C7C7C', 'sanitize_callback' => 'sanitize_hex_color'));
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'footer_text_color', array('label' => __('Footer text color', 'moscow'), 'section' => 'colors', 'settings' => 'footer_text_color', 'priority' => 16)));
}
Пример #10
0
/**
 * 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'));
    }
    //end class exists woocommerce
    //Extra Panel for Users, who dont have WooCommerce
    // CREATE THE fcp PANEL
    $wp_customize->add_panel('store_a_fcp_panel', array('priority' => 40, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => 'Featured Posts Showcase', 'description' => ''));
    //SQUARE BOXES
    $wp_customize->add_section('store_a_fc_boxes', array('title' => 'Square Boxes', 'priority' => 10, 'panel' => 'store_a_fcp_panel'));
    $wp_customize->add_setting('store_a_box_enable', array('sanitize_callback' => 'store_sanitize_checkbox'));
    $wp_customize->add_control('store_a_box_enable', array('settings' => 'store_a_box_enable', 'label' => __('Enable Square Boxes & Posts Slider.', 'store'), 'section' => 'store_a_fc_boxes', 'type' => 'checkbox'));
    $wp_customize->add_setting('store_a_box_title', array('sanitize_callback' => 'sanitize_text_field'));
    $wp_customize->add_control('store_a_box_title', array('settings' => 'store_a_box_title', 'label' => __('Title for the Boxes', 'store'), 'section' => 'store_a_fc_boxes', 'type' => 'text'));
    $wp_customize->add_setting('store_a_box_cat', array('sanitize_callback' => 'store_sanitize_product_category'));
    $wp_customize->add_control(new WP_Customize_Category_Control($wp_customize, 'store_a_box_cat', array('label' => __('Posts Category.', 'store'), 'settings' => 'store_a_box_cat', 'section' => 'store_a_fc_boxes')));
    //SLIDER
    $wp_customize->add_section('store_a_fc_slider', array('title' => __('3D Cube Products Slider', 'store'), 'priority' => 10, 'panel' => 'store_a_fcp_panel', 'description' => 'This is the Posts Slider, displayed left to the square boxes.'));
    $wp_customize->add_setting('store_a_slider_title', array('sanitize_callback' => 'sanitize_text_field'));
    $wp_customize->add_control('store_a_slider_title', array('settings' => 'store_a_slider_title', 'label' => __('Title for the Slider', 'store'), 'section' => 'store_a_fc_slider', 'type' => 'text'));
    $wp_customize->add_setting('store_a_slider_count', array('sanitize_callback' => 'store_sanitize_positive_number'));
    $wp_customize->add_control('store_a_slider_count', array('settings' => 'store_a_slider_count', 'label' => __('No. of Posts(Min:3, Max: 10)', 'store'), 'section' => 'store_a_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_a_slider_cat', array('sanitize_callback' => 'store_sanitize_product_category'));
    $wp_customize->add_control(new WP_Customize_Category_Control($wp_customize, 'store_a_slider_cat', array('label' => __('Category For Slider.', 'store'), 'settings' => 'store_a_slider_cat', 'section' => 'store_a_fc_slider')));
    //COVERFLOW
    $wp_customize->add_section('store_a_fc_coverflow', array('title' => __('Top CoverFlow Slider', 'store'), 'priority' => 5, 'panel' => 'store_a_fcp_panel'));
    $wp_customize->add_setting('store_a_coverflow_title', array('sanitize_callback' => 'sanitize_text_field'));
    $wp_customize->add_control('store_a_coverflow_title', array('settings' => 'store_a_coverflow_title', 'label' => __('Title for the Coverflow', 'store'), 'section' => 'store_a_fc_coverflow', 'type' => 'text'));
    $wp_customize->add_setting('store_a_coverflow_enable', array('sanitize_callback' => 'store_sanitize_checkbox'));
    $wp_customize->add_control('store_a_coverflow_enable', array('settings' => 'store_a_coverflow_enable', 'label' => __('Enable', 'store'), 'section' => 'store_a_fc_coverflow', 'type' => 'checkbox'));
    $wp_customize->add_setting('store_a_coverflow_cat', array('sanitize_callback' => 'store_sanitize_category'));
    $wp_customize->add_control(new WP_Customize_Category_Control($wp_customize, 'store_a_coverflow_cat', array('label' => __('Category For Image Grid', 'store'), 'settings' => 'store_a_coverflow_cat', 'section' => 'store_a_fc_coverflow')));
    $wp_customize->add_setting('store_a_coverflow_pc', array('sanitize_callback' => 'store_sanitize_positive_number'));
    $wp_customize->add_control('store_a_coverflow_pc', array('settings' => 'store_a_coverflow_pc', 'label' => __('Max No. of Posts in the Grid. Min: 5.', 'store'), 'section' => 'store_a_fc_coverflow', 'type' => 'number', 'default' => '0'));
    // 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()
        {
            ?>
	            <label>
	                <span class="customize-control-title"><?php 
            echo esc_html($this->label);
            ?>
</span>
	                <textarea rows="8" style="width:100%;" <?php 
            $this->link();
            ?>
><?php 
            echo esc_textarea($this->value());
            ?>
</textarea>
	            </label>
	        <?php 
        }
    }
    $wp_customize->add_section('store_custom_codes', array('title' => __('Custom CSS', 'store'), 'description' => __('Enter your Custom CSS to Modify design.', 'store'), 'priority' => 11, 'panel' => 'store_design_panel'));
    $wp_customize->add_setting('store_custom_css', array('default' => '', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'wp_filter_nohtml_kses', 'sanitize_js_callback' => 'wp_filter_nohtml_kses'));
    $wp_customize->add_control(new Store_Custom_CSS_Control($wp_customize, 'store_custom_css', array('section' => 'store_custom_codes', 'settings' => 'store_custom_css')));
    function store_sanitize_text($input)
    {
        return wp_kses_post(force_balance_tags($input));
    }
    $wp_customize->add_section('store_custom_footer', array('title' => __('Custom Footer Text', 'store'), 'description' => __('Enter your Own Copyright Text.', 'store'), 'priority' => 11, 'panel' => 'store_design_panel'));
    $wp_customize->add_setting('store_footer_text', array('default' => '', 'sanitize_callback' => 'sanitize_text_field'));
    $wp_customize->add_control('store_footer_text', array('section' => 'store_custom_footer', 'settings' => 'store_footer_text', 'type' => 'text'));
    //Select the Default Theme Skin
    $wp_customize->add_section('store_skin_options', array('title' => __('Choose Skin', 'store'), 'priority' => 39));
    $wp_customize->add_setting('store_skin', array('default' => 'default', 'sanitize_callback' => 'store_sanitize_skin'));
    $skins = array('default' => __('Default(blue)', 'store'), 'orange' => __('Orange', 'store'), 'brown' => __('Brown', 'store'), 'green' => __('Green', 'store'), 'grayscale' => __('GrayScale', 'store'));
    $wp_customize->add_control('store_skin', array('settings' => 'store_skin', 'section' => 'store_skin_options', 'type' => 'select', 'choices' => $skins));
    function store_sanitize_skin($input)
    {
        if (in_array($input, array('default', 'orange', 'brown', 'green', 'grayscale'))) {
            return $input;
        } else {
            return '';
        }
    }
    //Fonts
    $wp_customize->add_section('store_typo_options', array('title' => __('Google Web Fonts', 'store'), 'priority' => 41, 'description' => __('Defaults: Lato, Open Sans.', 'store')));
    $font_array = array('Raleway', 'Khula', 'Open Sans', 'Droid Sans', 'Droid Serif', 'Roboto', 'Roboto Condensed', 'Lato', 'Bree Serif', 'Oswald', 'Slabo', 'Lora', 'Source Sans Pro', 'PT Sans', 'Ubuntu', 'Lobster', 'Arimo', 'Bitter', 'Noto Sans');
    $fonts = array_combine($font_array, $font_array);
    $wp_customize->add_setting('store_title_font', array('default' => 'Lato', 'sanitize_callback' => 'store_sanitize_gfont'));
    function store_sanitize_gfont($input)
    {
        if (in_array($input, array('Raleway', 'Khula', 'Open Sans', 'Droid Sans', 'Droid Serif', 'Roboto', 'Roboto Condensed', 'Lato', 'Bree Serif', 'Oswald', 'Slabo', 'Lora', 'Source Sans Pro', 'PT Sans', 'Ubuntu', 'Lobster', 'Arimo', 'Bitter', 'Noto Sans'))) {
            return $input;
        } else {
            return '';
        }
    }
    $wp_customize->add_control('store_title_font', array('label' => __('Title', 'store'), 'settings' => 'store_title_font', 'section' => 'store_typo_options', 'type' => 'select', 'choices' => $fonts));
    $wp_customize->add_setting('store_body_font', array('default' => 'Open Sans', 'sanitize_callback' => 'store_sanitize_gfont'));
    $wp_customize->add_control('store_body_font', array('label' => __('Body', 'store'), 'settings' => 'store_body_font', 'section' => 'store_typo_options', 'type' => 'select', 'choices' => $fonts));
    // Social Icons
    $wp_customize->add_section('store_social_section', array('title' => __('Social Icons', 'store'), 'priority' => 44));
    $social_networks = array('none' => __('-', 'store'), 'facebook' => __('Facebook', 'store'), 'twitter' => __('Twitter', 'store'), 'google-plus' => __('Google Plus', 'store'), 'instagram' => __('Instagram', 'store'), 'rss' => __('RSS Feeds', 'store'), 'vine' => __('Vine', 'store'), 'vimeo-square' => __('Vimeo', 'store'), 'youtube' => __('Youtube', 'store'), 'flickr' => __('Flickr', 'store'));
    $social_count = count($social_networks);
    for ($x = 1; $x <= $social_count - 3; $x++) {
        $wp_customize->add_setting('store_social_' . $x, array('sanitize_callback' => 'store_sanitize_social', 'default' => 'none'));
        $wp_customize->add_control('store_social_' . $x, array('settings' => 'store_social_' . $x, 'label' => __('Icon ', 'store') . $x, 'section' => 'store_social_section', 'type' => 'select', 'choices' => $social_networks));
        $wp_customize->add_setting('store_social_url' . $x, array('sanitize_callback' => 'esc_url_raw'));
        $wp_customize->add_control('store_social_url' . $x, array('settings' => 'store_social_url' . $x, 'description' => __('Icon ', 'store') . $x . __(' Url', 'store'), 'section' => 'store_social_section', 'type' => 'url', 'choices' => $social_networks));
    }
    function store_sanitize_social($input)
    {
        $social_networks = array('none', 'facebook', 'twitter', 'google-plus', 'instagram', 'rss', 'vine', 'vimeo-square', 'youtube', 'flickr');
        if (in_array($input, $social_networks)) {
            return $input;
        } else {
            return '';
        }
    }
    $wp_customize->add_section('store_sec_upgrade', array('title' => __('Store Theme - Help & Support', 'store'), 'priority' => 45));
    $wp_customize->add_setting('store_upgrade', array('sanitize_callback' => 'esc_textarea'));
    $wp_customize->add_control(new WP_Customize_Upgrade_Control($wp_customize, 'store_upgrade', array('label' => __('Thank You', 'store'), 'description' => __('Thank You for Choosing Store Theme by Rohitink.com. Store is a Powerful Wordpress theme which also supports WooCommerce in the best possible way. It is "as we say" the last theme you would ever need. It has all the basic and advanced features needed to run a gorgeous looking site. For any Help related to this theme, please visit  <a href="https://rohitink.com/2015/05/21/store-woocommerce-theme/">Store Help & Support</a>.', 'store'), 'section' => 'store_sec_upgrade', 'settings' => 'store_upgrade')));
    /* Sanitization Functions Common to Multiple Settings go Here, Specific Sanitization Functions are defined along with add_setting() */
    function store_sanitize_checkbox($input)
    {
        if ($input == 1) {
            return 1;
        } else {
            return '';
        }
    }
    function store_sanitize_positive_number($input)
    {
        if ($input >= 0 && is_numeric($input)) {
            return $input;
        } else {
            return '';
        }
    }
    function store_sanitize_category($input)
    {
        if (term_exists(get_cat_name($input), 'category')) {
            return $input;
        } else {
            return '';
        }
    }
    function store_sanitize_product_category($input)
    {
        if (get_term($input, 'product_cat')) {
            return $input;
        } else {
            return '';
        }
    }
}
Пример #11
0
/**
 * 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)));
    // Display Footer Widget
    $wp_customize->add_setting('semifolio_display_footer_widget', array('default' => 0, 'capability' => 'edit_theme_options', 'type' => 'option', 'transport' => 'postMessage', 'sanitize_callback' => 'semifolio_sanitize_checkbox'));
    $wp_customize->add_control('display_footer_widget', array('settings' => 'semifolio_display_footer_widget', 'label' => __('Do You want to display Footer Widget?', 'semifolio'), 'section' => 'semifolio_layout_options', 'type' => 'checkbox', 'priority' => 5));
    // Footer Tagline
    $wp_customize->add_setting('semifolio_footer_tagline', array('default' => '' . __('Change the tagline about your site, which will display on the bottom section of the footer. This section supports html tags if desired. The text is wrapped in a paragraph element for formatting. <a href="' . esc_url(__('http://generasite.tk/', 'semifolio')) . '">Upgrade Now!</a>', 'semifolio') . '', 'transport' => 'postMessage', 'sanitize_callback' => 'semifolio_sanitize_text_attribute'));
    $wp_customize->add_control(new Semifolio_Customize_Info_Control($wp_customize, 'footer_tagline', array('label' => __('Footer Bottom Tagline', 'semifolio'), 'section' => 'semifolio_layout_options', 'settings' => 'semifolio_footer_tagline', 'type' => 'info', 'priority' => 6)));
    /*----------------------------------------------------------------------------------------*/
    /* Images Resize Section 
    /*----------------------------------------------------------------------------------------*/
    $wp_customize->add_section('semifolio_images_resize_section', array('title' => __('Images Resize', 'semifolio'), 'description' => 'Semifolio PRO Support Only!', 'priority' => 3));
    // PRO Options
    $wp_customize->add_setting('semifolio_images_resize', array('default' => '' . __('Allows you to change the size of images in posts on every page of your blog. <a href="' . esc_url(__('http://generasite.tk/', 'semifolio')) . '">Upgrade Now!</a>', 'semifolio') . '', 'transport' => 'postMessage', 'sanitize_callback' => 'semifolio_sanitize_text_attribute'));
    $wp_customize->add_control(new Semifolio_Customize_Info_Control($wp_customize, 'images_resize', array('label' => __('Semifolio PRO Options!', 'semifolio'), 'section' => 'semifolio_images_resize_section', 'settings' => 'semifolio_images_resize', 'type' => 'info')));
    /*----------------------------------------------------------------------------------------*/
    /* Background Color Section 
    /*----------------------------------------------------------------------------------------*/
    $wp_customize->add_section('semifolio_background_color_section', array('title' => __('Background Color', 'semifolio'), 'description' => 'Semifolio PRO Support Only!', 'priority' => 4));
    // PRO Options
    $wp_customize->add_setting('semifolio_background_color', array('default' => '' . __('Allows you to change the background in each area on your blog page. <a href="' . esc_url(__('http://generasite.tk/', 'semifolio')) . '">Upgrade Now!</a>', 'semifolio') . '', 'transport' => 'postMessage', 'sanitize_callback' => 'semifolio_sanitize_text_attribute'));
    $wp_customize->add_control(new Semifolio_Customize_Info_Control($wp_customize, 'background_color', array('label' => __('Semifolio PRO Options!', 'semifolio'), 'section' => 'semifolio_background_color_section', 'settings' => 'semifolio_background_color', 'type' => 'info')));
    /*----------------------------------------------------------------------------------------*/
    /* Text & Links Color Section
    /*----------------------------------------------------------------------------------------*/
    $wp_customize->add_section('semifolio_text_color_section', array('title' => __('Texts & Links Color', 'semifolio'), 'description' => 'Semifolio PRO Support Only!', 'priority' => 5));
    // PRO Options
    $wp_customize->add_setting('semifolio_text_color', array('default' => '' . __('With this option, you can change the color of text and links in almost all parts of the area of the blog, or align with the background that you change. <a href="' . esc_url(__('http://generasite.tk/', 'semifolio')) . '">Upgrade Now!</a>', 'semifolio') . '', 'transport' => 'postMessage', 'sanitize_callback' => 'semifolio_sanitize_text_attribute'));
    $wp_customize->add_control(new Semifolio_Customize_Info_Control($wp_customize, 'text_color', array('label' => __('Semifolio PRO Options!', 'semifolio'), 'section' => 'semifolio_text_color_section', 'settings' => 'semifolio_text_color', 'type' => 'info')));
    /*----------------------------------------------------------------------------------------*/
    /* Tracking Code, Script & CSS Section
    /*----------------------------------------------------------------------------------------*/
    $wp_customize->add_section('semifolio_code_section', array('title' => __('Tracking Code, Script & CSS', 'semifolio'), 'description' => 'Semifolio PRO Support Only!', 'priority' => 6));
    // PRO Options
    $wp_customize->add_setting('semifolio_tracking_code', array('default' => '' . __('Add your site in Google Webmaster by attaching a tracking code, analitycs, and tagmanager. You can also add code your own scripts and css, that will added into header and footer. <a href="' . esc_url(__('http://generasite.tk/', 'semifolio')) . '">Upgrade Now!</a>', 'semifolio') . '', 'transport' => 'postMessage', 'sanitize_callback' => 'semifolio_sanitize_text_attribute'));
    $wp_customize->add_control(new Semifolio_Customize_Info_Control($wp_customize, 'tracking_code', array('label' => __('Semifolio PRO Options!', 'semifolio'), 'section' => 'semifolio_code_section', 'settings' => 'semifolio_tracking_code', 'type' => 'info')));
}
Пример #12
0
	/**
	 * @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
0
 /**
  * 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'));
     $wp_customize->add_setting('medium_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
     $wp_customize->add_setting('svbtle_url', array('default' => '', 'sanitize_callback' => 'esc_url_raw'));
     $wp_customize->add_setting('wordpress_url', array('default' => '', 'sanitize_callback' => 'esc_url_raw'));
     $wp_customize->add_setting('stackoverflow_userid', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
     $wp_customize->add_setting('reddit_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
     $wp_customize->add_setting('github_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
     $wp_customize->add_setting('bitbucket_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
     $wp_customize->add_setting('runkeeper_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
     $wp_customize->add_setting('strava_userid', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
     $wp_customize->add_setting('foursquare_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
     $wp_customize->add_setting('yelp_url', array('default' => '', 'sanitize_callback' => 'esc_url_raw'));
     $wp_customize->add_setting('slideshare_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
     $wp_customize->add_setting('researchgate_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
     $wp_customize->add_setting('youversion_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
     $wp_customize->add_setting('psn_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
     $wp_customize->add_setting('xbox_live_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
     $wp_customize->add_setting('steam_url', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
     $wp_customize->add_setting('twitch_url', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
     $wp_customize->add_setting('skype_username', array('default' => '', 'sanitize_callback' => 'decode_sanitize_string'));
     $wp_customize->add_setting('email_address', array('default' => '', 'sanitize_callback' => 'sanitize_email'));
     $wp_customize->add_setting('website_link', array('default' => '', 'sanitize_callback' => 'esc_url_raw'));
     $wp_customize->add_setting('show_rss_icon', array('default' => false, 'sanitize_callback' => 'decode_sanitize_boolean'));
     $wp_customize->add_control('show_header_social_icons', array('label' => __('Show Social Icons', 'decode') . ' ' . __('in Header', 'decode'), 'section' => 'decode_social_options', 'type' => 'checkbox', 'priority' => 1));
     $wp_customize->add_control('show_footer_social_icons', array('label' => __('Show Social Icons', 'decode') . ' ' . __('in Footer', 'decode'), 'section' => 'decode_social_options', 'type' => 'checkbox', 'priority' => 2));
     $wp_customize->add_control('open_links_in_new_tab', array('label' => __('Open Links in New Tab/Window', 'decode'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'checkbox', 'priority' => 3));
     $wp_customize->add_control('twitter_username', array('label' => sprintf(__('%s Username', 'decode'), 'Twitter'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 4));
     $wp_customize->add_control('facebook_username', array('label' => sprintf(__('%s Username', 'decode'), 'Facebook'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 5));
     $wp_customize->add_control('google_plus_username', array('label' => sprintf(__('%s Username', 'decode'), 'Google+'), 'description' => __(' (or the long number in your profile URL)', 'decode'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 6));
     $wp_customize->add_control('ello_username', array('label' => sprintf(__('%s Username', 'decode'), 'Ello'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 7));
     $wp_customize->add_control('adn_username', array('label' => sprintf(__('%s Username', 'decode'), 'App.net'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 8));
     $wp_customize->add_control('sina_weibo_username', array('label' => sprintf(__('%s Username', 'decode'), 'Sina Weibo'), 'description' => __(' (or the long number in your profile URL)', 'decode'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 9));
     $wp_customize->add_control('myspace_username', array('label' => sprintf(__('%s Username', 'decode'), 'MySpace'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 10));
     $wp_customize->add_control('diaspora_id', array('label' => sprintf(__('%s Username', 'decode'), 'Diaspora'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 11));
     $wp_customize->add_control('vk_username', array('label' => sprintf(__('%s Username', 'decode'), 'VK'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 12));
     $wp_customize->add_control('dribbble_username', array('label' => sprintf(__('%s Username', 'decode'), 'Dribbble'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 13));
     $wp_customize->add_control('behance_username', array('label' => sprintf(__('%s Username', 'decode'), 'Behance'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 14));
     $wp_customize->add_control('linkedin_profile_url', array('label' => sprintf(__('%s Profile URL', 'decode'), 'LinkedIn'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 15));
     $wp_customize->add_control('pinterest_username', array('label' => sprintf(__('%s Username', 'decode'), 'Pinterest'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 16));
     $wp_customize->add_control('fancy_username', array('label' => sprintf(__('%s Username', 'decode'), 'Fancy'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 17));
     $wp_customize->add_control('etsy_username', array('label' => sprintf(__('%s Username', 'decode'), 'Etsy'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 18));
     $wp_customize->add_control('pinboard_username', array('label' => sprintf(__('%s Username', 'decode'), 'Pinboard'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 19));
     $wp_customize->add_control('delicious_username', array('label' => sprintf(__('%s Username', 'decode'), 'Delicious'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 20));
     $wp_customize->add_control('instagram_username', array('label' => sprintf(__('%s Username', 'decode'), 'Instagram'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 21));
     $wp_customize->add_control('vsco_username', array('label' => sprintf(__('%s Username', 'decode'), 'VSCO Grid'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 22));
     $wp_customize->add_control('500px_username', array('label' => sprintf(__('%s Username', 'decode'), '500px'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 23));
     $wp_customize->add_control('flickr_username', array('label' => sprintf(__('%s Username', 'decode'), 'Flickr'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 24));
     $wp_customize->add_control('deviantart_username', array('label' => sprintf(__('%s Username', 'decode'), 'DeviantART'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 25));
     $wp_customize->add_control('bandcamp_username', array('label' => sprintf(__('%s Site URL', 'decode'), 'Bandcamp'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 26));
     $wp_customize->add_control('soundcloud_username', array('label' => sprintf(__('%s Username', 'decode'), 'Soundcloud'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 27));
     $wp_customize->add_control('itunes_link', array('label' => sprintf(__('%s Link', 'decode'), 'iTunes'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 28));
     $wp_customize->add_control('rdio_username', array('label' => sprintf(__('%s Username', 'decode'), 'Rdio'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 29));
     $wp_customize->add_control('spotify_username', array('label' => sprintf(__('%s Username', 'decode'), 'Spotify'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 30));
     $wp_customize->add_control('lastfm_username', array('label' => sprintf(__('%s Username', 'decode'), 'Last.fm'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 31));
     $wp_customize->add_control('vine_username', array('label' => sprintf(__('%s Username', 'decode'), 'Vine'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 32));
     $wp_customize->add_control('vimeo_username', array('label' => sprintf(__('%s Username', 'decode'), 'Vimeo'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 33));
     $wp_customize->add_control('youtube_url', array('label' => sprintf(__('%s Link', 'decode'), 'YouTube'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 34));
     $wp_customize->add_control('kickstarter_url', array('label' => sprintf(__('%s Site URL', 'decode'), 'Kickstarter'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 35));
     $wp_customize->add_control('gittip_username', array('label' => sprintf(__('%s Username', 'decode'), 'Gittip'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 36));
     $wp_customize->add_control('goodreads_username', array('label' => sprintf(__('%s Username', 'decode'), 'Goodreads'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 37));
     $wp_customize->add_control('tumblr_username', array('label' => sprintf(__('%s Site URL', 'decode'), 'Tumblr'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 38));
     $wp_customize->add_control('medium_username', array('label' => sprintf(__('%s Username', 'decode'), 'Medium'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 39));
     $wp_customize->add_control('svbtle_url', array('label' => sprintf(__('%s Site URL', 'decode'), 'Svbtle'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 40));
     $wp_customize->add_control('wordpress_url', array('label' => sprintf(__('%s Site URL', 'decode'), 'WordPress'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 41));
     $wp_customize->add_control('stackoverflow_userid', array('label' => sprintf(__('%s User ID', 'decode'), 'Stack Overflow'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 42));
     $wp_customize->add_control('reddit_username', array('label' => sprintf(__('%s Username', 'decode'), 'Reddit'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 43));
     $wp_customize->add_control('github_username', array('label' => sprintf(__('%s Username', 'decode'), 'GitHub'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 44));
     $wp_customize->add_control('bitbucket_username', array('label' => sprintf(__('%s Username', 'decode'), 'Bitbucket'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 45));
     $wp_customize->add_control('runkeeper_username', array('label' => sprintf(__('%s Username', 'decode'), 'Runkeeper'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 46));
     $wp_customize->add_control('strava_userid', array('label' => sprintf(__('%s User ID', 'decode'), 'Strava'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 47));
     $wp_customize->add_control('foursquare_username', array('label' => sprintf(__('%s Username', 'decode'), 'Foursquare'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 48));
     $wp_customize->add_control('yelp_url', array('label' => sprintf(__('%s Profile URL', 'decode'), 'Yelp'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 49));
     $wp_customize->add_control('slideshare_username', array('label' => sprintf(__('%s Username', 'decode'), 'SlideShare'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 50));
     $wp_customize->add_control('researchgate_username', array('label' => sprintf(__('%s Username', 'decode'), 'Research Gate'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 51));
     $wp_customize->add_control('youversion_username', array('label' => sprintf(__('%s Username', 'decode'), 'YouVersion'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 52));
     $wp_customize->add_control('psn_username', array('label' => sprintf(__('%s Username', 'decode'), 'Playstation Network'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 53));
     $wp_customize->add_control('xbox_live_username', array('label' => sprintf(__('%s Username', 'decode'), 'Xbox Live'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 54));
     $wp_customize->add_control('steam_url', array('label' => sprintf(__('%s Profile URL', 'decode'), 'Steam'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 55));
     $wp_customize->add_control('twitch_url', array('label' => sprintf(__('%s Profile URL', 'decode'), 'Twitch'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 56));
     $wp_customize->add_control('skype_username', array('label' => sprintf(__('%s Username', 'decode'), 'Skype'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 57));
     $wp_customize->add_control('email_address', array('label' => __('Email Address', 'decode'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 58));
     $wp_customize->add_control('website_link', array('label' => sprintf(__('%s Link', 'decode'), 'Website'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'text', 'priority' => 59));
     $wp_customize->add_control('show_rss_icon', array('label' => __('RSS Feed', 'decode'), 'section' => 'decode_social_options', 'active_callback' => 'decode_social_icons_are_enabled', 'type' => 'checkbox', 'priority' => 60));
     /**
      * Reading Options
      */
     $wp_customize->add_section('decode_content_options', array('title' => __('Content Options', 'decode'), 'priority' => 37, 'description' => sprintf(_x('These options change the display of %s\'s content', '(blog name)\'s content.', 'decode'), get_bloginfo('name', 'display'))));
     $wp_customize->add_setting('latin_extended_font', array('default' => false, 'sanitize_callback' => 'decode_sanitize_boolean'));
     $wp_customize->add_setting('use_excerpts', array('default' => false, 'sanitize_callback' => 'decode_sanitize_boolean'));
     $wp_customize->add_setting('use_excerpts_on_archives', array('default' => true, 'sanitize_callback' => 'decode_sanitize_boolean'));
     $wp_customize->add_setting('show_featured_images_on_excerpts', array('default' => false, 'sanitize_callback' => 'decode_sanitize_boolean'));
     $wp_customize->add_setting('show_featured_images_on_singles', array('default' => false, 'sanitize_callback' => 'decode_sanitize_boolean'));
     $wp_customize->add_setting('show_tags', array('default' => false, 'sanitize_callback' => 'decode_sanitize_boolean'));
     $wp_customize->add_setting('show_categories', array('default' => false, 'sanitize_callback' => 'decode_sanitize_boolean'));
     $wp_customize->add_setting('show_author_section', array('default' => false, 'sanitize_callback' => 'decode_sanitize_boolean'));
     $wp_customize->add_setting('entry_date_position', array('default' => 'below', 'sanitize_callback' => 'decode_sanitize_string'));
     $wp_customize->add_setting('show_entry_date_on_excerpts', array('default' => false, 'sanitize_callback' => 'decode_sanitize_boolean'));
     $wp_customize->add_setting('show_allowed_tags', array('default' => false, 'sanitize_callback' => 'decode_sanitize_boolean'));
     $wp_customize->add_setting('show_page_headers', array('default' => true, 'sanitize_callback' => 'decode_sanitize_boolean'));
     $wp_customize->add_setting('link_post_title_arrow', array('default' => false, 'sanitize_callback' => 'decode_sanitize_boolean'));
     $wp_customize->add_setting('show_theme_info', array('default' => true, 'sanitize_callback' => 'decode_sanitize_boolean'));
     $wp_customize->add_setting('site_colophon', array('default' => '', 'sanitize_callback' => 'decode_sanitize_html', 'transport' => 'postMessage'));
     $wp_customize->add_control('latin_extended_font', array('label' => __('Load Latin Extended character set. This will increase page load times.', 'decode'), 'section' => 'decode_content_options', 'type' => 'checkbox', 'priority' => 1));
     $wp_customize->add_control('use_excerpts', array('label' => __('Use entry excerpts instead of full text on site home. Excludes sticky posts.', 'decode'), 'section' => 'decode_content_options', 'type' => 'checkbox', 'priority' => 2));
     $wp_customize->add_control('use_excerpts_on_archives', array('label' => __('Use entry excerpts on archive, category, and author pages.', 'decode'), 'section' => 'decode_content_options', 'type' => 'checkbox', 'priority' => 3));
     $wp_customize->add_control('show_featured_images_on_excerpts', array('label' => __('Display posts\' featured images when excerpts are shown.', 'decode'), 'section' => 'decode_content_options', 'type' => 'checkbox', 'priority' => 4));
     $wp_customize->add_control('show_featured_images_on_singles', array('label' => __('Display a post\'s featured image on its individual page.', 'decode'), 'section' => 'decode_content_options', 'type' => 'checkbox', 'priority' => 5));
     $wp_customize->add_control('show_tags', array('label' => __('Show tags on front page (tags will be shown on post\'s individual page)', 'decode'), 'section' => 'decode_content_options', 'type' => 'checkbox', 'priority' => 6));
     $wp_customize->add_control('show_categories', array('label' => __('Show categories on front page (categories will be shown on post\'s individual page)', 'decode'), 'section' => 'decode_content_options', 'type' => 'checkbox', 'priority' => 7));
     $wp_customize->add_control('show_author_section', array('label' => __('Show author\'s name, profile image, and bio after posts', 'decode'), 'section' => 'decode_content_options', 'type' => 'checkbox', 'priority' => 8));
     $wp_customize->add_control('entry_date_position', array('label' => __('Entry Date Position', 'decode'), 'section' => 'decode_content_options', 'type' => 'radio', 'choices' => array('above' => __('Above Header', 'decode'), 'below' => __('Below Header', 'decode')), 'priority' => 9));
     $wp_customize->add_control('show_entry_date_on_excerpts', array('label' => __('Show entry date for post excepts on the main page', 'decode'), 'section' => 'decode_content_options', 'type' => 'checkbox', 'priority' => 10));
     $wp_customize->add_control('show_allowed_tags', array('label' => __('Show allowed HTML tags on comment form', 'decode'), 'section' => 'decode_content_options', 'type' => 'checkbox', 'priority' => 11));
     $wp_customize->add_control('show_page_headers', array('label' => __('Show Page Headers', 'decode'), 'section' => 'decode_content_options', 'type' => 'checkbox', 'priority' => 12));
     $wp_customize->add_control('link_post_title_arrow', array('label' => __('Add an arrow before the title of a link post', 'decode'), 'section' => 'decode_content_options', 'type' => 'checkbox', 'priority' => 13));
     $wp_customize->add_control('show_theme_info', array('label' => __('Show Theme Info (display a line of text about the theme and its creator at the bottom of pages)', 'decode'), 'section' => 'decode_content_options', 'type' => 'checkbox', 'priority' => 14));
     $wp_customize->add_control(new Decode_Customize_Textarea_Control($wp_customize, 'site_colophon', array('label' => __('Text (colophon, copyright, credits, etc.) for the footer of the site', 'decode'), 'section' => 'decode_content_options', 'settings' => 'site_colophon', 'type' => 'textarea', 'priority' => 15)));
     /**
      * Other Options
      */
     $wp_customize->add_section('decode_other_options', array('title' => __('Other Options', 'decode'), 'description' => __('Custom CSS is longer recommended. This feature may be removed in a future update. To continue using your tweaks, copy and paste your CSS into a custom CSS plugin such as <a href="http://jetpack.me/install/">Jetpack</a>. Get help <a href="http://jetpack.me/support/custom-css/">here</a>.', 'decode'), 'priority' => 38));
     $wp_customize->add_setting('custom_css', array('default' => '', 'capability' => 'edit_themes', 'sanitize_callback' => 'wp_filter_nohtml_kses', 'sanitize_js_callback' => 'wp_filter_nohtml_kses'));
     $wp_customize->add_setting('add_custom_post_types', array('default' => '', 'sanitize_callback' => 'decode_sanitize_setting'));
     $wp_customize->add_control(new Decode_Customize_Textarea_Control($wp_customize, 'custom_css', array('label' => __('Custom CSS', 'decode'), 'section' => 'decode_other_options', 'settings' => 'custom_css', 'type' => 'textarea', 'priority' => 1, 'input_attrs' => array('spellcheck' => 'false'))));
     $wp_customize->add_control('add_custom_post_types', array('label' => __('Show the following post types on home blog page. (Separate with commas)', 'decode'), 'section' => 'decode_other_options', 'type' => 'text', 'priority' => 2));
     /**
      * Color Options
      */
     $wp_customize->add_setting('accent_color', array('default' => '#00B0CC', 'sanitize_callback' => 'sanitize_hex_color'));
     $wp_customize->add_setting('secondary_accent_color', array('default' => '#008094', 'sanitize_callback' => 'sanitize_hex_color'));
     $wp_customize->add_setting('text_color', array('default' => '#444444', 'sanitize_callback' => 'sanitize_hex_color'));
     $wp_customize->add_setting('secondary_text_color', array('default' => '#808080', 'sanitize_callback' => 'sanitize_hex_color'));
     $wp_customize->add_setting('accent_color_icons', array('default' => false, 'sanitize_callback' => 'decode_sanitize_boolean'));
     $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'accent_color', array('label' => __('Accent Color', 'decode'), 'description' => __('The main color used for links, borders, buttons, and more.', 'decode'), 'section' => 'colors', 'settings' => 'accent_color', 'priority' => 1)));
     $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'secondary_accent_color', array('label' => __('Active Link Color', 'decode'), 'description' => __('The color for currently clicked links.<br>(Try using a darker color than the Accent Color.)', 'decode'), 'section' => 'colors', 'settings' => 'secondary_accent_color', 'priority' => 2)));
     $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'text_color', array('label' => __('Text Color', 'decode'), 'description' => __('The main text color.', 'decode'), 'section' => 'colors', 'settings' => 'text_color', 'priority' => 3)));
     $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'secondary_text_color', array('label' => __('Secondary Text Color', 'decode'), 'description' => __('Text color used for text of secondary importance.<br>(Try using a lighter color than the main Text Color.)', 'decode'), 'section' => 'colors', 'settings' => 'secondary_text_color', 'priority' => 4)));
     $wp_customize->add_control('accent_color_icons', array('label' => __('Use accent color instead of text color for icons', 'decode'), 'section' => 'colors', 'type' => 'checkbox'));
 }
Пример #14
0
/**
 * 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()
        {
            ?>
	            <label>
	                <span class="customize-control-title"><?php 
            echo esc_html($this->label);
            ?>
</span>
	                <textarea rows="8" style="width:100%;" <?php 
            $this->link();
            ?>
><?php 
            echo esc_textarea($this->value());
            ?>
</textarea>
	            </label>
	        <?php 
        }
    }
    $wp_customize->add_section('store_custom_codes', array('title' => __('Custom CSS', 'store'), 'description' => __('Enter your Custom CSS to Modify design.', 'store'), 'priority' => 11, 'panel' => 'store_design_panel'));
    $wp_customize->add_setting('store_custom_css', array('default' => '', 'capability' => 'edit_theme_options', 'sanitize_callback' => 'wp_filter_nohtml_kses', 'sanitize_js_callback' => 'wp_filter_nohtml_kses'));
    $wp_customize->add_control(new Store_Custom_CSS_Control($wp_customize, 'store_custom_css', array('section' => 'store_custom_codes', 'settings' => 'store_custom_css')));
    function store_sanitize_text($input)
    {
        return wp_kses_post(force_balance_tags($input));
    }
    $wp_customize->add_section('store_custom_footer', array('title' => __('Custom Footer Text', 'store'), 'description' => __('Enter your Own Copyright Text.', 'store'), 'priority' => 11, 'panel' => 'store_design_panel'));
    $wp_customize->add_setting('store_footer_text', array('default' => '', 'sanitize_callback' => 'sanitize_text_field'));
    $wp_customize->add_control('store_footer_text', array('section' => 'store_custom_footer', 'settings' => 'store_footer_text', 'type' => 'text'));
    $wp_customize->add_section('store_typo_options', array('title' => __('Google Web Fonts', 'store'), 'priority' => 41));
    $font_array = array('Raleway', 'Khula', 'Open Sans', 'Droid Sans', 'Droid Serif', 'Roboto', 'Roboto Condensed', 'Lato', 'Bree Serif', 'Oswald', 'Slabo', 'Lora', 'Source Sans Pro', 'PT Sans', 'Ubuntu', 'Lobster', 'Arimo', 'Bitter', 'Noto Sans');
    $fonts = array_combine($font_array, $font_array);
    $wp_customize->add_setting('store_title_font', array('default' => 'Raleway', 'sanitize_callback' => 'store_sanitize_gfont'));
    function store_sanitize_gfont($input)
    {
        if (in_array($input, array('Raleway', 'Khula', 'Open Sans', 'Droid Sans', 'Droid Serif', 'Roboto', 'Roboto Condensed', 'Lato', 'Bree Serif', 'Oswald', 'Slabo', 'Lora', 'Source Sans Pro', 'PT Sans', 'Ubuntu', 'Lobster', 'Arimo', 'Bitter', 'Noto Sans'))) {
            return $input;
        } else {
            return '';
        }
    }
    $wp_customize->add_control('store_title_font', array('label' => __('Title', 'store'), 'settings' => 'store_title_font', 'section' => 'store_typo_options', 'type' => 'select', 'choices' => $fonts));
    $wp_customize->add_setting('store_body_font', array('default' => 'Khula', 'sanitize_callback' => 'store_sanitize_gfont'));
    $wp_customize->add_control('store_body_font', array('label' => __('Body', 'store'), 'settings' => 'store_body_font', 'section' => 'store_typo_options', 'type' => 'select', 'choices' => $fonts));
    // Social Icons
    $wp_customize->add_section('store_social_section', array('title' => __('Social Icons', 'store'), 'priority' => 44));
    $social_networks = array('none' => __('-', 'store'), 'facebook' => __('Facebook', 'store'), 'twitter' => __('Twitter', 'store'), 'google-plus' => __('Google Plus', 'store'), 'instagram' => __('Instagram', 'store'), 'rss' => __('RSS Feeds', 'store'), 'vine' => __('Vine', 'store'), 'vimeo-square' => __('Vimeo', 'store'), 'youtube' => __('Youtube', 'store'), 'flickr' => __('Flickr', 'store'));
    $social_count = count($social_networks);
    for ($x = 1; $x <= $social_count - 3; $x++) {
        $wp_customize->add_setting('store_social_' . $x, array('sanitize_callback' => 'store_sanitize_social', 'default' => 'none'));
        $wp_customize->add_control('store_social_' . $x, array('settings' => 'store_social_' . $x, 'label' => __('Icon ', 'store') . $x, 'section' => 'store_social_section', 'type' => 'select', 'choices' => $social_networks));
        $wp_customize->add_setting('store_social_url' . $x, array('sanitize_callback' => 'esc_url_raw'));
        $wp_customize->add_control('store_social_url' . $x, array('settings' => 'store_social_url' . $x, 'description' => __('Icon ', 'store') . $x . __(' Url', 'store'), 'section' => 'store_social_section', 'type' => 'url', 'choices' => $social_networks));
    }
    function store_sanitize_social($input)
    {
        $social_networks = array('none', 'facebook', 'twitter', 'google-plus', 'instagram', 'rss', 'vine', 'vimeo-square', 'youtube', 'flickr');
        if (in_array($input, $social_networks)) {
            return $input;
        } else {
            return '';
        }
    }
    /* Sanitization Functions Common to Multiple Settings go Here, Specific Sanitization Functions are defined along with add_setting() */
    function store_sanitize_checkbox($input)
    {
        if ($input == 1) {
            return 1;
        } else {
            return '';
        }
    }
    function store_sanitize_positive_number($input)
    {
        if ($input >= 0 && is_numeric($input)) {
            return $input;
        } else {
            return '';
        }
    }
    function store_sanitize_category($input)
    {
        if (term_exists(get_cat_name($input), 'category')) {
            return $input;
        } else {
            return '';
        }
    }
    function store_sanitize_product_category($input)
    {
        if (get_term($input, 'product_cat')) {
            return $input;
        } else {
            return '';
        }
    }
}
Пример #15
0
/**
 * 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));
}
Пример #16
0
/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function freak_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', 'freak'), 'priority' => 30));
    $wp_customize->add_setting('freak_logo', array('default' => '', 'sanitize_callback' => 'esc_url_raw'));
    $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'freak_logo', array('label' => 'Upload Logo', 'section' => 'title_tagline', 'settings' => 'freak_logo', 'priority' => 5)));
    $wp_customize->add_setting('freak_logo_resize', array('default' => 100, 'sanitize_callback' => 'freak_sanitize_positive_number'));
    $wp_customize->add_control('freak_logo_resize', array('label' => __('Resize & Adjust Logo', 'freak'), 'section' => 'title_tagline', 'settings' => 'freak_logo_resize', 'priority' => 6, 'type' => 'range', 'active_callback' => 'freak_logo_enabled', 'input_attrs' => array('min' => 30, 'max' => 200, 'step' => 5)));
    function freak_logo_enabled($control)
    {
        $option = $control->manager->get_setting('freak_logo');
        return $option->value() == true;
    }
    //Replace Header Text Color with, separate colors for Title and Description
    //Override freak_site_titlecolor
    $wp_customize->remove_control('display_header_text');
    $wp_customize->remove_setting('header_textcolor');
    $wp_customize->add_setting('freak_site_titlecolor', array('default' => '#FFFFFF', 'sanitize_callback' => 'sanitize_hex_color'));
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'freak_site_titlecolor', array('label' => __('Site Title Color', 'freak'), 'section' => 'colors', 'settings' => 'freak_site_titlecolor', 'type' => 'color')));
    $wp_customize->add_setting('freak_header_desccolor', array('default' => '#c4c4c4', 'sanitize_callback' => 'sanitize_hex_color'));
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'freak_header_desccolor', array('label' => __('Site Tagline Color', 'freak'), 'section' => 'colors', 'settings' => 'freak_header_desccolor', 'type' => 'color')));
    //Header Settings
    $wp_customize->add_panel('freak_header_panel', array('priority' => 35, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => 'Header Settings'));
    $wp_customize->add_section('header_image', array('title' => __('Header Image', 'freak'), 'panel' => 'freak_header_panel', 'priority' => 30));
    //Parallax Settings
    $wp_customize->add_section('freak_header_parallax', array('title' => __('Parallax Settings', 'freak'), 'panel' => 'freak_header_panel', 'priority' => 30));
    $wp_customize->add_setting('freak_parallax_disable', array('default' => false, 'sanitize_callback' => 'freak_sanitize_checkbox'));
    $wp_customize->add_control('freak_parallax_disable', array('label' => __('Disable Parallax Effect.', 'freak'), 'section' => 'freak_header_parallax', 'settings' => 'freak_parallax_disable', 'type' => 'checkbox'));
    //Callback Functions to Check if Parallax is Enabled or Disabled.
    function freak_parallax_enabled($control)
    {
        $option = $control->manager->get_setting('freak_parallax_disable');
        return $option->value() == false;
    }
    function freak_parallax_disabled($control)
    {
        $option = $control->manager->get_setting('freak_parallax_disable');
        return $option->value() == true;
    }
    $wp_customize->add_setting('freak_parallax_strength', array('default' => 0.2, 'sanitize_callback' => 'freak_sanitize_positive_number'));
    $wp_customize->add_control('freak_parallax_strength', array('label' => __('Parallax Effect Strength', 'freak'), 'description' => __('Min: 0.05, Max: 1, Default: 0.2', 'freak'), 'section' => 'freak_header_parallax', 'settings' => 'freak_parallax_strength', 'priority' => 6, 'type' => 'range', 'active_callback' => 'freak_parallax_enabled', 'input_attrs' => array('min' => 0.05, 'max' => 1, 'step' => 0.05)));
    //General Settings
    $wp_customize->add_section('freak_header_basic', array('title' => __('General Settings', 'freak'), 'panel' => 'freak_header_panel', 'priority' => 30));
    $wp_customize->add_setting('freak_himg_align', array('default' => true, 'sanitize_callback' => 'freak_sanitize_himg_align'));
    /* Sanitization Function */
    function freak_sanitize_himg_align($input)
    {
        if (in_array($input, array('center', 'left', 'right'))) {
            return $input;
        } else {
            return '';
        }
    }
    $wp_customize->add_control('freak_himg_align', array('label' => __('Header Image Alignment', 'freak'), 'section' => 'freak_header_basic', 'settings' => 'freak_himg_align', 'active_callback' => 'freak_parallax_disabled', 'type' => 'select', 'choices' => array('center' => __('Center', 'freak'), 'left' => __('Left', 'freak'), 'right' => __('Right', 'freak'))));
    //Filter Enabled By Default
    $wp_customize->add_setting('freak_himg_darkbg', array('default' => true, 'sanitize_callback' => 'freak_sanitize_checkbox'));
    $wp_customize->add_control('freak_himg_darkbg', array('label' => __('Add a Dark Filter to make the text Above the Image More Clear and Easy to Read.', 'freak'), 'section' => 'freak_header_basic', 'settings' => 'freak_himg_darkbg', 'type' => 'checkbox'));
    //Resize Header
    $wp_customize->add_setting('freak_header_size', array('default' => 3, 'sanitize_callback' => 'freak_sanitize_positive_number'));
    $wp_customize->add_control('freak_header_size', array('label' => __('Header Size for Home Page.', 'freak'), 'section' => 'freak_header_basic', 'settings' => 'freak_header_size', 'priority' => 5, 'type' => 'range', 'input_attrs' => array('min' => 1, 'max' => 3, 'step' => 1)));
    $wp_customize->add_setting('freak_header_size_other', array('default' => 3, 'sanitize_callback' => 'freak_sanitize_positive_number'));
    $wp_customize->add_control('freak_header_size_other', array('label' => __('Header Size for Posts,pages & Archives', 'freak'), 'description' => __('Use this option if you want a Different Header Size for All Pages, except the Home Page.', 'freak'), 'section' => 'freak_header_basic', 'settings' => 'freak_header_size_other', 'priority' => 5, 'type' => 'range', 'input_attrs' => array('min' => 1, 'max' => 3, 'step' => 1)));
    $wp_customize->add_setting('freak_topsearch_disable', array('default' => false, 'sanitize_callback' => 'freak_sanitize_checkbox'));
    $wp_customize->add_control('freak_topsearch_disable', array('label' => __('Hide Search Bar.', 'freak'), 'section' => 'freak_header_basic', 'settings' => 'freak_topsearch_disable', 'type' => 'checkbox'));
    //Settings For Logo Area
    $wp_customize->add_setting('freak_hide_title_tagline', array('sanitize_callback' => 'freak_sanitize_checkbox'));
    $wp_customize->add_control('freak_hide_title_tagline', array('settings' => 'freak_hide_title_tagline', 'label' => __('Hide Title and Tagline.', 'freak'), 'section' => 'title_tagline', 'type' => 'checkbox'));
    function freak_title_visible($control)
    {
        $option = $control->manager->get_setting('freak_hide_title_tagline');
        return $option->value() == false;
    }
    // SLIDER PANEL
    $wp_customize->add_panel('freak_slider_panel', array('priority' => 35, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => 'Main Slider'));
    $wp_customize->add_section('freak_sec_slider_options', array('title' => __('Enable/Disable', 'freak'), 'priority' => 0, 'panel' => 'freak_slider_panel'));
    $wp_customize->add_setting('freak_main_slider_enable', array('sanitize_callback' => 'freak_sanitize_checkbox'));
    $wp_customize->add_control('freak_main_slider_enable', array('settings' => 'freak_main_slider_enable', 'label' => __('Enable Slider.', 'freak'), 'section' => 'freak_sec_slider_options', 'type' => 'checkbox'));
    $wp_customize->add_setting('freak_main_slider_count', array('default' => '0', 'sanitize_callback' => 'freak_sanitize_positive_number'));
    // Select How Many Slides the User wants, and Reload the Page.
    $wp_customize->add_control('freak_main_slider_count', array('settings' => 'freak_main_slider_count', 'label' => __('No. of Slides(Min:0, Max: 10)', 'freak'), 'section' => 'freak_sec_slider_options', 'type' => 'number', 'description' => __('Save the Settings, and Reload this page to Configure the Slides.', 'freak')));
    if (get_theme_mod('freak_main_slider_count') > 0) {
        $slides = get_theme_mod('freak_main_slider_count');
        for ($i = 1; $i <= $slides; $i++) {
            //Create the settings Once, and Loop through it.
            $wp_customize->add_setting('freak_slide_img' . $i, array('sanitize_callback' => 'esc_url_raw'));
            $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'freak_slide_img' . $i, array('label' => '', 'section' => 'freak_slide_sec' . $i, 'settings' => 'freak_slide_img' . $i)));
            $wp_customize->add_section('freak_slide_sec' . $i, array('title' => __('Slide ', 'freak') . $i, 'priority' => $i, 'panel' => 'freak_slider_panel'));
            $wp_customize->add_setting('freak_slide_title' . $i, array('sanitize_callback' => 'sanitize_text_field'));
            $wp_customize->add_control('freak_slide_title' . $i, array('settings' => 'freak_slide_title' . $i, 'label' => __('Slide Title', 'freak'), 'section' => 'freak_slide_sec' . $i, 'type' => 'text'));
            $wp_customize->add_setting('freak_slide_desc' . $i, array('sanitize_callback' => 'sanitize_text_field'));
            $wp_customize->add_control('freak_slide_desc' . $i, array('settings' => 'freak_slide_desc' . $i, 'label' => __('Slide Description', 'freak'), 'section' => 'freak_slide_sec' . $i, 'type' => 'text'));
            $wp_customize->add_setting('freak_slide_url' . $i, array('sanitize_callback' => 'esc_url_raw'));
            $wp_customize->add_control('freak_slide_url' . $i, array('settings' => 'freak_slide_url' . $i, 'label' => __('Target URL', 'freak'), 'section' => 'freak_slide_sec' . $i, 'type' => 'url'));
        }
    }
    //IMAGE GRID
    $wp_customize->add_section('freak_fc_grid', array('title' => __('Featured Posts', 'freak'), 'priority' => 36));
    $wp_customize->add_setting('freak_grid_enable', array('sanitize_callback' => 'freak_sanitize_checkbox'));
    $wp_customize->add_control('freak_grid_enable', array('settings' => 'freak_grid_enable', 'label' => __('Enable', 'freak'), 'section' => 'freak_fc_grid', 'type' => 'checkbox'));
    $wp_customize->add_setting('freak_grid_title', array('sanitize_callback' => 'sanitize_text_field'));
    $wp_customize->add_control('freak_grid_title', array('settings' => 'freak_grid_title', 'label' => __('Title for the Grid', 'freak'), 'section' => 'freak_fc_grid', 'type' => 'text'));
    $wp_customize->add_setting('freak_grid_cat', array('sanitize_callback' => 'freak_sanitize_category'));
    $wp_customize->add_control(new WP_Customize_Category_Control($wp_customize, 'freak_grid_cat', array('label' => __('Category For Image Grid', 'freak'), 'settings' => 'freak_grid_cat', 'section' => 'freak_fc_grid')));
    $wp_customize->add_setting('freak_grid_rows', array('sanitize_callback' => 'freak_sanitize_positive_number'));
    $wp_customize->add_control('freak_grid_rows', array('settings' => 'freak_grid_rows', 'label' => __('Max No. of Posts in the Grid. Enter 0 to Disable the Grid.', 'freak'), 'section' => 'freak_fc_grid', 'type' => 'number', 'default' => '0'));
    // Layout and Design
    $wp_customize->add_panel('freak_design_panel', array('priority' => 40, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __('Design & Layout', 'freak')));
    $wp_customize->add_section('freak_static_bar_options', array('title' => __('Static Bar', 'freak'), 'priority' => 0, 'panel' => 'freak_design_panel'));
    $wp_customize->add_setting('freak_disable_static_bar', array('sanitize_callback' => 'freak_sanitize_checkbox'));
    $wp_customize->add_control('freak_disable_static_bar', array('settings' => 'freak_disable_static_bar', 'label' => __('Disable Static Bar.', 'freak'), 'section' => 'freak_static_bar_options', 'type' => 'checkbox', 'default' => false));
    $wp_customize->add_setting('freak_disable_static_bar_mobile', array('sanitize_callback' => 'freak_sanitize_checkbox'));
    $wp_customize->add_control('freak_disable_static_bar_mobile', array('settings' => 'freak_disable_static_bar_mobile', 'label' => __('Disable Static Menu on Mobiles.', 'freak'), 'section' => 'freak_static_bar_options', 'type' => 'checkbox', 'description' => __('Desktop Static Bar Converts to a Sliding Responsive Menu on Phones', 'freak'), 'default' => false));
    $wp_customize->add_section('freak_design_options', array('title' => __('Blog Layout', 'freak'), 'priority' => 0, 'panel' => 'freak_design_panel'));
    $wp_customize->add_setting('freak_blog_layout', array('sanitize_callback' => 'freak_sanitize_blog_layout'));
    function freak_sanitize_blog_layout($input)
    {
        if (in_array($input, array('grid', 'freak'))) {
            return $input;
        } else {
            return '';
        }
    }
    $wp_customize->add_control('freak_blog_layout', array('label' => __('Select Layout', 'freak'), 'settings' => 'freak_blog_layout', 'section' => 'freak_design_options', 'type' => 'select', 'choices' => array('freak' => __('Freak Layout', 'freak'), 'grid' => __('Basic Blog Layout', 'freak'))));
    $wp_customize->add_section('freak_sidebar_options', array('title' => __('Sidebar Layout', 'freak'), 'priority' => 0, 'panel' => 'freak_design_panel'));
    $wp_customize->add_setting('freak_disable_sidebar', array('sanitize_callback' => 'freak_sanitize_checkbox'));
    $wp_customize->add_control('freak_disable_sidebar', array('settings' => 'freak_disable_sidebar', 'label' => __('Disable Sidebar Everywhere.', 'freak'), 'section' => 'freak_sidebar_options', 'type' => 'checkbox', 'default' => false));
    $wp_customize->add_setting('freak_disable_sidebar_home', array('sanitize_callback' => 'freak_sanitize_checkbox'));
    $wp_customize->add_control('freak_disable_sidebar_home', array('settings' => 'freak_disable_sidebar_home', 'label' => __('Disable Sidebar on Home/Blog.', 'freak'), 'section' => 'freak_sidebar_options', 'type' => 'checkbox', 'active_callback' => 'freak_show_sidebar_options', 'default' => false));
    $wp_customize->add_setting('freak_disable_sidebar_front', array('sanitize_callback' => 'freak_sanitize_checkbox'));
    $wp_customize->add_control('freak_disable_sidebar_front', array('settings' => 'freak_disable_sidebar_front', 'label' => __('Disable Sidebar on Front Page.', 'freak'), 'section' => 'freak_sidebar_options', 'type' => 'checkbox', 'active_callback' => 'freak_show_sidebar_options', 'default' => false));
    $wp_customize->add_setting('freak_sidebar_width', array('default' => 4, 'sanitize_callback' => 'freak_sanitize_positive_number'));
    $wp_customize->add_control('freak_sidebar_width', array('settings' => 'freak_sidebar_width', 'label' => __('Sidebar Width', 'freak'), 'description' => __('Min: 25%, Default: 33%, Max: 40%', 'freak'), 'section' => 'freak_sidebar_options', 'type' => 'range', 'active_callback' => 'freak_show_sidebar_options', 'input_attrs' => array('min' => 3, 'max' => 5, 'step' => 1, 'class' => 'sidebar-width-range', 'style' => 'color: #0a0')));
    /* Active Callback Function */
    function freak_show_sidebar_options($control)
    {
        $option = $control->manager->get_setting('freak_disable_sidebar');
        return $option->value() == false;
    }
    class Freak_Custom_CSS_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="8" style="width:100%;" <?php 
            $this->link();
            ?>
><?php 
            echo esc_textarea($this->value());
            ?>
</textarea>
	            </label>
	        <?php 
        }
    }
    $wp_customize->add_section('freak_custom_codes', array('title' => __('Custom CSS', 'freak'), 'description' => __('Enter your Custom CSS to Modify design.', 'freak'), 'priority' => 11, 'panel' => 'freak_design_panel'));
    $wp_customize->add_setting('freak_custom_css', array('default' => '', 'sanitize_callback' => 'freak_sanitize_text'));
    $wp_customize->add_control(new Freak_Custom_CSS_Control($wp_customize, 'freak_custom_css', array('section' => 'freak_custom_codes', 'settings' => 'freak_custom_css')));
    function freak_sanitize_text($input)
    {
        return wp_kses_post(force_balance_tags($input));
    }
    $wp_customize->add_section('freak_custom_footer', array('title' => __('Custom Footer Text', 'freak'), 'description' => __('Enter your Own Copyright Text.', 'freak'), 'priority' => 11, 'panel' => 'freak_design_panel'));
    $wp_customize->add_setting('freak_footer_text', array('default' => '', 'sanitize_callback' => 'sanitize_text_field'));
    $wp_customize->add_control('freak_footer_text', array('section' => 'freak_custom_footer', 'settings' => 'freak_footer_text', 'type' => 'text'));
    $wp_customize->add_section('freak_typo_options', array('title' => __('Google Web Fonts', 'freak'), 'priority' => 41));
    $font_array = array('Roboto Slab', 'Bitter', 'Raleway', 'Khula', 'Open Sans', 'Droid Sans', 'Droid Serif', 'Roboto', 'Roboto Condensed', 'Lato', 'Bree Serif', 'Oswald', 'Slabo', 'Lora', 'Source Sans Pro', 'PT Sans', 'Ubuntu', 'Lobster', 'Arimo', 'Bitter', 'Noto Sans');
    $fonts = array_combine($font_array, $font_array);
    $wp_customize->add_setting('freak_title_font', array('default' => 'Bitter', 'sanitize_callback' => 'freak_sanitize_gfont'));
    function freak_sanitize_gfont($input)
    {
        if (in_array($input, array('Roboto Slab', 'Bitter', 'Raleway', 'Khula', 'Open Sans', 'Droid Sans', 'Droid Serif', 'Roboto', 'Roboto Condensed', 'Lato', 'Bree Serif', 'Oswald', 'Slabo', 'Lora', 'Source Sans Pro', 'PT Sans', 'Ubuntu', 'Lobster', 'Arimo', 'Bitter', 'Noto Sans'))) {
            return $input;
        } else {
            return '';
        }
    }
    $wp_customize->add_control('freak_title_font', array('label' => __('Title', 'freak'), 'settings' => 'freak_title_font', 'section' => 'freak_typo_options', 'type' => 'select', 'choices' => $fonts));
    $wp_customize->add_setting('freak_body_font', array('default' => 'Roboto Slab', 'sanitize_callback' => 'freak_sanitize_gfont'));
    $wp_customize->add_control('freak_body_font', array('label' => __('Body', 'freak'), 'settings' => 'freak_body_font', 'section' => 'freak_typo_options', 'type' => 'select', 'choices' => $fonts));
    // Social Icons
    $wp_customize->add_section('freak_social_section', array('title' => __('Social Icons', 'freak'), 'priority' => 44));
    $social_networks = array('none' => __('-', 'freak'), 'facebook' => __('Facebook', 'freak'), 'twitter' => __('Twitter', 'freak'), 'google-plus' => __('Google Plus', 'freak'), 'instagram' => __('Instagram', 'freak'), 'rss' => __('RSS Feeds', 'freak'), 'vimeo' => __('Vimeo', 'freak'), 'youtube' => __('Youtube', 'freak'));
    $social_count = count($social_networks);
    for ($x = 1; $x <= $social_count - 3; $x++) {
        $wp_customize->add_setting('freak_social_' . $x, array('sanitize_callback' => 'freak_sanitize_social', 'default' => 'none'));
        $wp_customize->add_control('freak_social_' . $x, array('settings' => 'freak_social_' . $x, 'label' => __('Icon ', 'freak') . $x, 'section' => 'freak_social_section', 'type' => 'select', 'choices' => $social_networks));
        $wp_customize->add_setting('freak_social_url' . $x, array('sanitize_callback' => 'esc_url_raw'));
        $wp_customize->add_control('freak_social_url' . $x, array('settings' => 'freak_social_url' . $x, 'description' => __('Icon ', 'freak') . $x . __(' Url', 'freak'), 'section' => 'freak_social_section', 'type' => 'url', 'choices' => $social_networks));
    }
    function freak_sanitize_social($input)
    {
        $social_networks = array('none', 'facebook', 'twitter', 'google-plus', 'instagram', 'rss', 'vimeo', 'youtube');
        if (in_array($input, $social_networks)) {
            return $input;
        } else {
            return '';
        }
    }
    $wp_customize->add_section('freak_sec_upgrade', array('title' => __('Discover freak Pro', 'freak'), 'priority' => 35));
    $wp_customize->add_setting('freak_upgrade', array('sanitize_callback' => 'esc_textarea'));
    $wp_customize->add_control(new WP_Customize_Upgrade_Control($wp_customize, 'freak_upgrade', array('label' => __('More of Everything', 'freak'), 'description' => __('Freak Pro has more of Everything. More New Features, More Options, More Colors, More Fonts, More Layouts, Configurable Slider, Inbuilt Advertising Options, Multiple Skins, More Widgets, and a lot more options and comes with Dedicated Support. To Know More about the Pro Version, click here: <a href="http://rohitink.com/product/freak-pro/">Upgrade to Pro</a>.', 'freak'), 'section' => 'freak_sec_upgrade', 'settings' => 'freak_upgrade')));
    /* Sanitization Functions Common to Multiple Settings go Here, Specific Sanitization Functions are defined along with add_setting() */
    function freak_sanitize_checkbox($input)
    {
        if ($input == 1) {
            return 1;
        } else {
            return '';
        }
    }
    function freak_sanitize_positive_number($input)
    {
        if ($input >= 0 && is_numeric($input)) {
            return $input;
        } else {
            return '';
        }
    }
    function freak_sanitize_category($input)
    {
        if (term_exists(get_cat_name($input), 'category')) {
            return $input;
        } else {
            return '';
        }
    }
}
Пример #17
-1
/**
 * Add postMessage support for site title and description for the Theme Customizer.
 *
 * @param WP_Customize_Manager $wp_customize Theme Customizer object.
 */
function gently_customize_register($wp_customize)
{
    if (class_exists('Kirki')) {
        $wp_customize->add_section('color', array('title' => __('Color', 'gently'), 'priority' => 81));
        $wp_customize->add_section('typography', array('title' => __('Typography', 'gently'), 'priority' => 82));
        $wp_customize->add_section('header', array('title' => __('Top bar', 'gently'), 'priority' => 91));
        $wp_customize->add_section('sidebar', array('title' => __('Sidebar', 'gently'), 'priority' => 101));
        $wp_customize->add_section('footer', array('title' => __('Footer', 'gently'), 'priority' => 111));
        $wp_customize->add_section('social', array('title' => __('Social Media', 'gently'), 'priority' => 112, 'description' => __('Share buttons will be displayed under each single post.', 'gently')));
        if (function_exists('mc4wp_show_form')) {
            $wp_customize->add_section('newsletter', array('title' => __('Newsletter', 'gently'), 'priority' => 113));
        }
        // Rename default section
        $background_section = $wp_customize->get_section('background_image');
        $background_section->title = __('Background', 'gently');
        // Move background color to custom section
        $background_color_control = $wp_customize->get_control('background_color');
        $background_color_control->section = 'background_image';
        // Change blogname setting transport to post, description and title
        $blogname_setting = $wp_customize->get_setting('blogname');
        $blogname_setting->transport = 'postMessage';
        $blogname_controll = $wp_customize->get_control('blogname');
        $blogname_controll->description = __('If you want to use text version of logo remove images above.', 'gently');
        // Change Header image section order
        $header_image_section = $wp_customize->get_section('header_image');
        $header_image_section->priority = 99;
        // Remove unused header text and text color controls
        $wp_customize->remove_control('display_header_text');
        $wp_customize->remove_control('header_textcolor');
        // Remove tagline field
        $wp_customize->remove_setting('blogdescription');
        $wp_customize->remove_control('blogdescription');
    } else {
        // Convert default section to a notice that inform user about more options in customzier when they install Kirki plugin.
        $wp_customize->add_section('notice', array('title' => __('Install Kirki for more options.', 'gently'), 'priority' => 1, 'description' => __('This theme uses free plugin from wordpress.org - Kirki. Install it to use many customizer options that comes with this theme.', 'gently')));
        $wp_customize->add_setting('install_notice', array('default' => '', 'sanitize_callback' => 'esc_url_raw'));
        $wp_customize->add_control('install_notice', array('section' => 'notice', 'label' => '', 'type' => ''));
    }
}