/** * Implements Catchbase theme options into Theme Customizer. * * @param $wp_customize Theme Customizer object * @return void * * @since Catch Base 1.0 */ function catchbase_customize_register($wp_customize) { $wp_customize->get_setting('blogname')->transport = 'postMessage'; /** * Set priority of blogname (Site Title) to 1. * Strangly, if more than two options is added, Site title is moved below Tagline. This rectifies this issue. */ $wp_customize->get_control('blogname')->priority = 1; $wp_customize->get_setting('blogdescription')->transport = 'postMessage'; $options = catchbase_get_theme_options(); $defaults = catchbase_get_default_theme_options(); //Custom Controls require get_template_directory() . '/inc/customizer-includes/catchbase-customizer-custom-controls.php'; // Custom Logo (added to Site Title and Tagline section in Theme Customizer) $wp_customize->add_setting('catchbase_theme_options[logo]', array('capability' => 'edit_theme_options', 'default' => $defaults['logo'], 'sanitize_callback' => 'catchbase_sanitize_image')); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'logo', array('label' => __('Logo', 'catch-base'), 'priority' => 100, 'section' => 'title_tagline', 'settings' => 'catchbase_theme_options[logo]'))); $wp_customize->add_setting('catchbase_theme_options[logo_disable]', array('capability' => 'edit_theme_options', 'default' => $defaults['logo_disable'], 'sanitize_callback' => 'catchbase_sanitize_checkbox')); $wp_customize->add_control('catchbase_theme_options[logo_disable]', array('label' => __('Check to disable logo', 'catch-base'), 'priority' => 101, 'section' => 'title_tagline', 'settings' => 'catchbase_theme_options[logo_disable]', 'type' => 'checkbox')); $wp_customize->add_setting('catchbase_theme_options[logo_alt_text]', array('capability' => 'edit_theme_options', 'default' => $defaults['logo_alt_text'], 'sanitize_callback' => 'sanitize_text_field')); $wp_customize->add_control('catchbase_logo_alt_text', array('label' => __('Logo Alt Text', 'catch-base'), 'priority' => 102, 'section' => 'title_tagline', 'settings' => 'catchbase_theme_options[logo_alt_text]', 'type' => 'text')); $wp_customize->add_setting('catchbase_theme_options[move_title_tagline]', array('capability' => 'edit_theme_options', 'default' => $defaults['move_title_tagline'], 'sanitize_callback' => 'catchbase_sanitize_checkbox')); $wp_customize->add_control('catchbase_theme_options[move_title_tagline]', array('label' => __('Check to move Site Title and Tagline before logo', 'catch-base'), 'priority' => 103, 'section' => 'title_tagline', 'settings' => 'catchbase_theme_options[move_title_tagline]', 'type' => 'checkbox')); // Custom Logo End // Color Scheme $wp_customize->add_setting('catchbase_theme_options[color_scheme]', array('capability' => 'edit_theme_options', 'default' => $defaults['color_scheme'], 'sanitize_callback' => 'catchbase_sanitize_select', 'transport' => 'postMessage')); $schemes = catchbase_color_schemes(); $choices = array(); foreach ($schemes as $scheme) { $choices[$scheme['value']] = $scheme['label']; } $wp_customize->add_control('catchbase_theme_options[color_scheme]', array('choices' => $choices, 'label' => __('Color Scheme', 'catch-base'), 'priority' => 5, 'section' => 'colors', 'settings' => 'catchbase_theme_options[color_scheme]', 'type' => 'radio')); //End Color Scheme // Header Options (added to Header section in Theme Customizer) require get_template_directory() . '/inc/customizer-includes/catchbase-customizer-header-options.php'; //Theme Options require get_template_directory() . '/inc/customizer-includes/catchbase-customizer-theme-options.php'; //Featured Content Setting require get_template_directory() . '/inc/customizer-includes/catchbase-customizer-featured-content-setting.php'; //Featured Slider require get_template_directory() . '/inc/customizer-includes/catchbase-customizer-featured-slider.php'; //Social Links require get_template_directory() . '/inc/customizer-includes/catchbase-customizer-social-icons.php'; // Reset all settings to default $wp_customize->add_section('catchbase_reset_all_settings', array('description' => __('Caution: Reset all settings to default. Refresh the page after save to view full effects.', 'catch-base'), 'priority' => 700, 'title' => __('Reset all settings', 'catch-base'))); $wp_customize->add_setting('catchbase_theme_options[reset_all_settings]', array('capability' => 'edit_theme_options', 'default' => $defaults['reset_all_settings'], 'sanitize_callback' => 'catchbase_reset_all_settings', 'transport' => 'postMessage')); $wp_customize->add_control('catchbase_theme_options[reset_all_settings]', array('label' => __('Check to reset all settings to default', 'catch-base'), 'section' => 'catchbase_reset_all_settings', 'settings' => 'catchbase_theme_options[reset_all_settings]', 'type' => 'checkbox')); // Reset all settings to default end //Important Links $wp_customize->add_section('important_links', array('priority' => 999, 'title' => __('Important Links', 'catch-base'))); /** * Has dummy Sanitizaition function as it contains no value to be sanitized */ $wp_customize->add_setting('important_links', array('sanitize_callback' => 'catchbase_sanitize_important_link')); $wp_customize->add_control(new Catchbase_Important_Links($wp_customize, 'important_links', array('label' => __('Important Links', 'catch-base'), 'section' => 'important_links', 'settings' => 'important_links', 'type' => 'important_links'))); //Important Links End }
* The template for adding color options in Customizer * * @package Catchbase * @subpackage Catchbase Pro * @since Catch Base 1.0 */ if (!defined('CATCHBASE_THEME_VERSION')) { header('Status: 403 Forbidden'); header('HTTP/1.1 403 Forbidden'); exit; } //Basic Color Options $wp_customize->add_panel('catchbase_color_options', array('capability' => 'edit_theme_options', 'description' => __('Color Options', 'catch-base'), 'priority' => 300, 'title' => __('Color Options', 'catch-base'))); $wp_customize->add_section('catchbase_color_scheme', array('panel' => 'catchbase_color_options', 'priority' => 301, 'title' => __('Basic Color Options', 'catch-base'))); $wp_customize->add_setting('catchbase_theme_options[color_scheme]', array('capability' => 'edit_theme_options', 'default' => $defaults['color_scheme'], 'sanitize_callback' => 'sanitize_key')); $schemes = catchbase_color_schemes(); $choices = array(); foreach ($schemes as $scheme) { $choices[$scheme['value']] = $scheme['label']; } $wp_customize->add_control('catchbase_theme_options[color_scheme]', array('choices' => $choices, 'label' => __('Color Scheme', 'catch-base'), 'priority' => 5, 'section' => 'catchbase_color_scheme', 'settings' => 'catchbase_theme_options[color_scheme]', 'type' => 'radio')); $catchbase_basic_color_options = catchbase_get_basic_color_options(); $i = 10; foreach ($catchbase_basic_color_options as $color_option) { $lower_color_option = str_replace(' ', '_', strtolower($color_option)); $wp_customize->add_setting('catchbase_theme_options[' . $lower_color_option . ']', array('capability' => 'edit_theme_options', 'default' => $defaults[$lower_color_option], 'sanitize_callback' => 'sanitize_hex_color')); $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'catchbase_theme_options[' . $lower_color_option . ']', array('label' => $color_option, 'priority' => $i, 'section' => 'catchbase_color_scheme', 'settings' => 'catchbase_theme_options[' . $lower_color_option . ']'))); $i++; } //Header Color Option $wp_customize->add_section('catchbase_header_color_options', array('panel' => 'catchbase_color_options', 'priority' => 302, 'title' => __('Header Color Options', 'catch-base')));