Exemple #1
0
 /**
  * This function adds editor styles based on post type, before TinyMCE is initalized.
  * It will also enqueue the correct color scheme stylesheet to better match front-end display.
  */
 public function pre_get_posts()
 {
     global $sds_theme_options, $post;
     // Determine the correct protocol
     $protocol = is_ssl() ? 'https' : 'http';
     // Core editor styles
     add_editor_style('css/editor-style.css');
     // Add correct color scheme if selected
     if (function_exists('sds_color_schemes') && !empty($sds_theme_options['color_scheme']) && $sds_theme_options['color_scheme'] !== 'default') {
         $color_schemes = sds_color_schemes();
         add_editor_style('css/' . $color_schemes[$sds_theme_options['color_scheme']]['stylesheet']);
     }
     // Open Sans Web Font (include only if a web font is not selected in Theme Options)
     if (!function_exists('sds_web_fonts') || empty($sds_theme_options['web_font'])) {
         add_editor_style(str_replace(',', '%2C', $protocol . '://fonts.googleapis.com/css?family=Lato:400,700,900|Martel+Sans:400,600'));
     }
     // Google WebFonts (Open Sans)
     // Fetch page template (Pages only)
     $wp_page_template = get_page_template_slug();
     // If we have a post using our full page or landing page templates
     if (!empty($post) && ($wp_page_template === 'template-full-width.php' || $wp_page_template === 'template-landing-page.php')) {
         add_editor_style('css/editor-style-full-width.css');
     }
     // FontAwesome
     add_editor_style(SDS_Theme_Options::sds_core_dir(true) . '/css/font-awesome.min.css');
 }
Exemple #2
0
function sds_customize_register($wp_customize)
{
    // Load custom Customizer API assets
    include_once SDS_Theme_Options::sds_core_dir() . '/customizer/class-sds-theme-options-customize-checkbox-control.php';
    // Checkbox Controller
    include_once SDS_Theme_Options::sds_core_dir() . '/customizer/class-sds-theme-options-customize-color-scheme-control.php';
    // Color Scheme Controller
    include_once SDS_Theme_Options::sds_core_dir() . '/customizer/class-sds-theme-options-customize-content-layout-control.php';
    // Content Layout Controller
    include_once SDS_Theme_Options::sds_core_dir() . '/customizer/class-sds-theme-options-customize-logo-control.php';
    // Logo Controller
    include_once SDS_Theme_Options::sds_core_dir() . '/customizer/class-sds-theme-options-customize-web-font-control.php';
    // Web Font Controller
    include_once SDS_Theme_Options::sds_core_dir() . '/customizer/class-sds-theme-options-customize-us-control.php';
    // Upsell Controller
    // SDS Theme Options defaults
    $sds_theme_options_instance = SDS_Theme_Options_Instance();
    $sds_theme_options_defaults = $sds_theme_options_instance->get_sds_theme_option_defaults();
    /**
     * Logo Upload (WordPress 4.5 and up and if the theme supports WordPress' custom logo)
     */
    if (SDS_Theme_Options::wp_version_compare('4.5') && get_theme_support('custom-logo')) {
        /**
         * Custom Logo Control
         */
        if ($custom_logo_control = $wp_customize->get_control('custom_logo')) {
            // Get Control
            $sds_logo_dimensions = apply_filters('sds_theme_options_logo_dimensions', '300x100');
            $custom_logo_control->priority = 30;
            // Adjust priority
            $custom_logo_control->description = sprintf(__('Upload a logo to to replace the site title. Recommended dimensions: %1$s.', 'baton'), $sds_logo_dimensions);
            // Add description
        }
    }
    /**
     * Logo Upload (below WordPress 4.5 or if the theme doesn't support WordPress' custom logo)
     */
    if (SDS_Theme_Options::wp_version_compare('4.5', '<') || !get_theme_support('custom-logo')) {
        // Setting (data is sanitized upon update_option() call using the sanitize function in $sds_theme_options_instance)
        $wp_customize->add_setting('sds_theme_options[logo_attachment_id]', array('default' => $sds_theme_options_defaults['logo_attachment_id'], 'type' => 'option', 'sanitize_callback' => 'absint'));
        // Section - overwrite the default title_tagline section properties
        $wp_customize->get_section('title_tagline')->title = __('Logo/Site Title & Tagline', 'baton');
        // Control
        $wp_customize->add_control(new SDS_Theme_Options_Customize_Logo_Control($wp_customize, 'logo_attachment_id', array('label' => __('Logo', 'baton'), 'section' => 'title_tagline', 'settings' => 'sds_theme_options[logo_attachment_id]', 'type' => 'sds_theme_options_logo')));
    }
    /**
     * Show/Hide Elements
     */
    // Section
    $wp_customize->add_section('sds_theme_options_show_hide', array('priority' => 30, 'title' => __('Show or Hide Tagline', 'baton'), 'description' => __('Use this option to show or hide the tagline on your site.', 'baton')));
    /*
     * Show/Hide Tagline
     */
    // Setting
    $wp_customize->add_setting('sds_theme_options[hide_tagline]', array('default' => $sds_theme_options_defaults['hide_tagline'], 'type' => 'option', 'sanitize_callback' => 'sds_boolval'));
    // Control
    $wp_customize->add_control(new SDS_Theme_Options_Customize_Checkbox_Control($wp_customize, 'sds_theme_options[hide_tagline]', array('label' => __('Tagline', 'baton'), 'section' => 'sds_theme_options_show_hide', 'settings' => 'sds_theme_options[hide_tagline]', 'priority' => 10, 'type' => 'checkbox', 'css_class' => 'sds-theme-options-show-hide-tagline', 'css_id' => 'sds_theme_options_hide_tagline')));
    /**
     * Color Scheme (if specified by the theme)
     */
    if (function_exists('sds_color_schemes')) {
        // Setting
        $wp_customize->add_setting('sds_theme_options[color_scheme]', array('default' => $sds_theme_options_defaults['color_scheme'], 'type' => 'option', 'sanitize_callback' => 'sanitize_html_class'));
        // Control
        $wp_customize->add_control(new SDS_Theme_Options_Customize_Color_Scheme_Control($wp_customize, 'sds_theme_options[color_scheme]', array('label' => __('Color Scheme', 'baton'), 'description' => __('Select a color scheme to use on your site.', 'baton'), 'section' => 'colors', 'settings' => 'sds_theme_options[color_scheme]', 'priority' => 10, 'type' => 'radio', 'color_controls' => apply_filters('sds_color_scheme_customizer_color_controls', array('content_color'), $wp_customize))));
    }
    /**
     * Content Color
     */
    // Setting
    $wp_customize->add_setting('content_color', array('default' => apply_filters('theme_mod_content_color', ''), 'sanitize_callback' => 'sanitize_hex_color', 'sanitize_js_callback' => 'maybe_hash_hex_color'));
    // Control
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'content_color', array('label' => __('Content Color', 'baton'), 'section' => 'colors', 'settings' => 'content_color', 'priority' => 20)));
    /*
     * Background Color (change priority)
     */
    $wp_customize->get_control('background_color')->priority = 30;
    // Move below content_color
    /**
     * Web Font (if specified by the theme)
     */
    if (function_exists('sds_web_fonts')) {
        // Section
        $wp_customize->add_section('fonts', array('priority' => 50, 'title' => __('Fonts', 'baton')));
        // Setting
        $wp_customize->add_setting('sds_theme_options[web_font]', array('default' => $sds_theme_options_defaults['web_font'], 'type' => 'option', 'sanitize_callback' => 'sanitize_text_field'));
        // Control
        $wp_customize->add_control(new SDS_Theme_Options_Customize_Web_Font_Control($wp_customize, 'sds_theme_options[web_font]', array('label' => __('Web Fonts', 'baton'), 'description' => __('Select a web font to use on your site.', 'baton'), 'section' => 'fonts', 'settings' => 'sds_theme_options[web_font]', 'priority' => 10, 'type' => 'radio')));
    }
    /**
     * Content Layouts
     */
    if (function_exists('sds_content_layouts')) {
        // Section
        $wp_customize->add_section('sds_theme_options_content_layouts', array('priority' => 70, 'title' => __('Content Layouts', 'baton'), 'description' => __('Control the layout of the content on your site here. Choose a global layout scheme to be used across your entire site or specify individual content type layout schemes by adjusting the options below.', 'baton')));
        /*
         * Global Content Layout
         */
        // Setting
        $wp_customize->add_setting('sds_theme_options[content_layouts][global]', array('default' => $sds_theme_options_defaults['content_layouts']['global'], 'type' => 'option', 'sanitize_callback' => 'sanitize_text_field'));
        // Control
        $wp_customize->add_control(new SDS_Theme_Options_Customize_Content_Layout_Control($wp_customize, 'sds_theme_options[content_layouts][global]', array('label' => __('Global Content Layout', 'baton'), 'description' => __('Select a content layout that will be applied globally on your site. Select more specific content layouts below.', 'baton'), 'section' => 'sds_theme_options_content_layouts', 'settings' => 'sds_theme_options[content_layouts][global]', 'priority' => 10, 'type' => 'radio', 'content_layout_id' => 'global')));
        /*
         * Front Page Content Layout
         */
        // Setting
        $wp_customize->add_setting('sds_theme_options[content_layouts][front_page]', array('default' => $sds_theme_options_defaults['content_layouts']['front_page'], 'type' => 'option', 'sanitize_callback' => 'sanitize_text_field'));
        // Control
        $wp_customize->add_control(new SDS_Theme_Options_Customize_Content_Layout_Control($wp_customize, 'sds_theme_options[content_layouts][front_page]', array('label' => __('Front Page Content Layout', 'baton'), 'description' => __('Select a content layout that will be applied to the front page on your site (if selected in Settings &gt; Reading).', 'baton'), 'section' => 'sds_theme_options_content_layouts', 'settings' => 'sds_theme_options[content_layouts][front_page]', 'priority' => 20, 'type' => 'radio', 'content_layout_id' => 'front_page', 'active_callback' => sds_is_front_page_sidebar_registered() ? 'sds_is_front_page_sidebar_inactive' : '')));
        /*
         * Home Content Layout
         */
        // Setting
        $wp_customize->add_setting('sds_theme_options[content_layouts][home]', array('default' => $sds_theme_options_defaults['content_layouts']['home'], 'type' => 'option', 'sanitize_callback' => 'sanitize_text_field'));
        // Control
        $wp_customize->add_control(new SDS_Theme_Options_Customize_Content_Layout_Control($wp_customize, 'sds_theme_options[content_layouts][home]', array('label' => __('Home Content Layout', 'baton'), 'description' => __('Select a content layout that will be applied to the blog on your site.', 'baton'), 'section' => 'sds_theme_options_content_layouts', 'settings' => 'sds_theme_options[content_layouts][home]', 'priority' => 30, 'type' => 'radio', 'content_layout_id' => 'home')));
        /*
         * Single Post Content Layout
         */
        // Setting
        $wp_customize->add_setting('sds_theme_options[content_layouts][single]', array('default' => $sds_theme_options_defaults['content_layouts']['single'], 'type' => 'option', 'sanitize_callback' => 'sanitize_text_field'));
        // Control
        $wp_customize->add_control(new SDS_Theme_Options_Customize_Content_Layout_Control($wp_customize, 'sds_theme_options[content_layouts][single]', array('label' => __('Single Post Content Layout', 'baton'), 'description' => __('Select a content layout that will be applied to single posts on your site.', 'baton'), 'section' => 'sds_theme_options_content_layouts', 'settings' => 'sds_theme_options[content_layouts][single]', 'priority' => 40, 'type' => 'radio', 'content_layout_id' => 'single')));
        /*
         * Single Page Content Layout
         */
        // Setting
        $wp_customize->add_setting('sds_theme_options[content_layouts][page]', array('default' => $sds_theme_options_defaults['content_layouts']['page'], 'type' => 'option', 'sanitize_callback' => 'sanitize_text_field'));
        // Control
        $wp_customize->add_control(new SDS_Theme_Options_Customize_Content_Layout_Control($wp_customize, 'sds_theme_options[content_layouts][page]', array('label' => __('Single Page Content Layout', 'baton'), 'description' => __('Select a content layout that will be applied to single pages on your site.', 'baton'), 'section' => 'sds_theme_options_content_layouts', 'settings' => 'sds_theme_options[content_layouts][page]', 'priority' => 50, 'type' => 'radio', 'content_layout_id' => 'page')));
        /*
         * Archive Content Layout
         */
        // Setting
        $wp_customize->add_setting('sds_theme_options[content_layouts][archive]', array('default' => $sds_theme_options_defaults['content_layouts']['archive'], 'type' => 'option', 'sanitize_callback' => 'sanitize_text_field'));
        // Control
        $wp_customize->add_control(new SDS_Theme_Options_Customize_Content_Layout_Control($wp_customize, 'sds_theme_options[content_layouts][archive]', array('label' => __('Archive Content Layout', 'baton'), 'description' => __('Select a content layout that will be applied to archives on your site.', 'baton'), 'section' => 'sds_theme_options_content_layouts', 'settings' => 'sds_theme_options[content_layouts][archive]', 'priority' => 60, 'type' => 'radio', 'content_layout_id' => 'archive')));
        /*
         * Category Archive Content Layout
         */
        // Setting
        $wp_customize->add_setting('sds_theme_options[content_layouts][category]', array('default' => $sds_theme_options_defaults['content_layouts']['category'], 'type' => 'option', 'sanitize_callback' => 'sanitize_text_field'));
        // Control
        $wp_customize->add_control(new SDS_Theme_Options_Customize_Content_Layout_Control($wp_customize, 'sds_theme_options[content_layouts][category]', array('label' => __('Category Archive Content Layout', 'baton'), 'description' => __('Select a content layout that will be applied to category archives on your site.', 'baton'), 'section' => 'sds_theme_options_content_layouts', 'settings' => 'sds_theme_options[content_layouts][category]', 'priority' => 70, 'type' => 'radio', 'content_layout_id' => 'category')));
        /*
         * Tag Archive Content Layout
         */
        // Setting
        $wp_customize->add_setting('sds_theme_options[content_layouts][tag]', array('default' => $sds_theme_options_defaults['content_layouts']['tag'], 'type' => 'option', 'sanitize_callback' => 'sanitize_text_field'));
        // Control
        $wp_customize->add_control(new SDS_Theme_Options_Customize_Content_Layout_Control($wp_customize, 'sds_theme_options[content_layouts][tag]', array('label' => __('Tag Archive Content Layout', 'baton'), 'description' => __('Select a content layout that will be applied to tag archives on your site.', 'baton'), 'section' => 'sds_theme_options_content_layouts', 'settings' => 'sds_theme_options[content_layouts][tag]', 'priority' => 80, 'type' => 'radio', 'content_layout_id' => 'tag')));
        /*
         * 404 Error Content Layout
         */
        // Setting
        $wp_customize->add_setting('sds_theme_options[content_layouts][404]', array('default' => $sds_theme_options_defaults['content_layouts']['404'], 'type' => 'option', 'sanitize_callback' => 'sanitize_text_field'));
        // Control
        $wp_customize->add_control(new SDS_Theme_Options_Customize_Content_Layout_Control($wp_customize, 'sds_theme_options[content_layouts][404]', array('label' => __('404 Error Content Layout', 'baton'), 'description' => __('Select a content layout that will be applied to the 404 error page on your site. <strong>Please Note: The Customizer does not allow for previewing of 404 error pages.</strong>', 'baton'), 'section' => 'sds_theme_options_content_layouts', 'settings' => 'sds_theme_options[content_layouts][404]', 'priority' => 90, 'type' => 'radio', 'content_layout_id' => '404')));
    }
    /**
     * Social Media
     */
    // Section
    $wp_customize->add_section('sds_theme_options_social_media', array('priority' => 75, 'title' => __('Social Media', 'baton'), 'description' => __('Enter your social media links here. This section is used throughout the site to display social media links to visitors. Some themes display social media links automatically, and some only display them within the Social Media widget.', 'baton')));
    /*
     * Facebook
     */
    // Setting
    $wp_customize->add_setting('sds_theme_options[social_media][facebook_url]', array('default' => $sds_theme_options_defaults['social_media']['facebook_url'], 'type' => 'option', 'sanitize_callback' => 'esc_url'));
    // Control
    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'sds_theme_options[social_media][facebook_url]', array('label' => __('Facebook', 'baton'), 'section' => 'sds_theme_options_social_media', 'settings' => 'sds_theme_options[social_media][facebook_url]', 'priority' => 10)));
    /*
     * Twitter
     */
    // Setting
    $wp_customize->add_setting('sds_theme_options[social_media][twitter_url]', array('default' => $sds_theme_options_defaults['social_media']['twitter_url'], 'type' => 'option', 'sanitize_callback' => 'esc_url'));
    // Control
    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'sds_theme_options[social_media][twitter_url]', array('label' => __('Twitter', 'baton'), 'section' => 'sds_theme_options_social_media', 'settings' => 'sds_theme_options[social_media][twitter_url]', 'priority' => 20)));
    /*
     * LinkedIn
     */
    // Setting
    $wp_customize->add_setting('sds_theme_options[social_media][linkedin_url]', array('default' => $sds_theme_options_defaults['social_media']['linkedin_url'], 'type' => 'option', 'sanitize_callback' => 'esc_url'));
    // Control
    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'sds_theme_options[social_media][linkedin_url]', array('label' => __('LinkedIn', 'baton'), 'section' => 'sds_theme_options_social_media', 'settings' => 'sds_theme_options[social_media][linkedin_url]', 'priority' => 30)));
    /*
     * Google+
     */
    // Setting
    $wp_customize->add_setting('sds_theme_options[social_media][google_plus_url]', array('default' => $sds_theme_options_defaults['social_media']['google_plus_url'], 'type' => 'option', 'sanitize_callback' => 'esc_url'));
    // Control
    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'sds_theme_options[social_media][google_plus_url]', array('label' => __('Google+', 'baton'), 'section' => 'sds_theme_options_social_media', 'settings' => 'sds_theme_options[social_media][google_plus_url]', 'priority' => 40)));
    /*
     * YouTube
     */
    // Setting
    $wp_customize->add_setting('sds_theme_options[social_media][youtube_url]', array('default' => $sds_theme_options_defaults['social_media']['youtube_url'], 'type' => 'option', 'sanitize_callback' => 'esc_url'));
    // Control
    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'sds_theme_options[social_media][youtube_url]', array('label' => __('YouTube', 'baton'), 'section' => 'sds_theme_options_social_media', 'settings' => 'sds_theme_options[social_media][youtube_url]', 'priority' => 50)));
    /*
     * Vimeo
     */
    // Setting
    $wp_customize->add_setting('sds_theme_options[social_media][vimeo_url]', array('default' => $sds_theme_options_defaults['social_media']['vimeo_url'], 'type' => 'option', 'sanitize_callback' => 'esc_url'));
    // Control
    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'sds_theme_options[social_media][vimeo_url]', array('label' => __('Vimeo', 'baton'), 'section' => 'sds_theme_options_social_media', 'settings' => 'sds_theme_options[social_media][vimeo_url]', 'priority' => 60)));
    /*
     * Instagram
     */
    // Setting
    $wp_customize->add_setting('sds_theme_options[social_media][instagram_url]', array('default' => $sds_theme_options_defaults['social_media']['instagram_url'], 'type' => 'option', 'sanitize_callback' => 'esc_url'));
    // Control
    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'sds_theme_options[social_media][instagram_url]', array('label' => __('Instagram', 'baton'), 'section' => 'sds_theme_options_social_media', 'settings' => 'sds_theme_options[social_media][instagram_url]', 'priority' => 70)));
    /*
     * Pinterest
     */
    // Setting
    $wp_customize->add_setting('sds_theme_options[social_media][pinterest_url]', array('default' => $sds_theme_options_defaults['social_media']['pinterest_url'], 'type' => 'option', 'sanitize_callback' => 'esc_url'));
    // Control
    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'sds_theme_options[social_media][pinterest_url]', array('label' => __('Pinterest', 'baton'), 'section' => 'sds_theme_options_social_media', 'settings' => 'sds_theme_options[social_media][pinterest_url]', 'priority' => 80)));
    /*
     * Flickr
     */
    // Setting
    $wp_customize->add_setting('sds_theme_options[social_media][flickr_url]', array('default' => $sds_theme_options_defaults['social_media']['flickr_url'], 'type' => 'option', 'sanitize_callback' => 'esc_url'));
    // Control
    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'sds_theme_options[social_media][flickr_url]', array('label' => __('Flickr', 'baton'), 'section' => 'sds_theme_options_social_media', 'settings' => 'sds_theme_options[social_media][flickr_url]', 'priority' => 90)));
    /*
     * Foursquare
     */
    // Setting
    $wp_customize->add_setting('sds_theme_options[social_media][foursquare_url]', array('default' => $sds_theme_options_defaults['social_media']['foursquare_url'], 'type' => 'option', 'sanitize_callback' => 'esc_url'));
    // Control
    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'sds_theme_options[social_media][foursquare_url]', array('label' => __('Foursquare', 'baton'), 'section' => 'sds_theme_options_social_media', 'settings' => 'sds_theme_options[social_media][foursquare_url]', 'priority' => 100)));
    /*
     * RSS (Use Site RSS Feed)
     */
    // Setting
    $wp_customize->add_setting('sds_theme_options[social_media][rss_url_use_site_feed]', array('default' => $sds_theme_options_defaults['social_media']['rss_url_use_site_feed'], 'type' => 'option', 'sanitize_callback' => 'sds_boolval'));
    // Control
    $wp_customize->add_control(new SDS_Theme_Options_Customize_Checkbox_Control($wp_customize, 'sds_theme_options[social_media][rss_url_use_site_feed]', array('label' => __('RSS - Use Site RSS Feed', 'baton'), 'description' => __('When "yes" is displayed, the RSS feed for your site will be used. Otherwise, you can enter a custom RSS URL to use instead.', 'baton'), 'section' => 'sds_theme_options_social_media', 'settings' => 'sds_theme_options[social_media][rss_url_use_site_feed]', 'priority' => 110, 'type' => 'checkbox', 'css_class' => 'sds-theme-options-rss-url-use-site-feed', 'css_id' => 'sds_theme_options_rss_url_use_site_feed', 'checked_label' => __('Yes', 'baton'), 'unchecked_label' => __('No', 'baton'), 'style' => array('before' => 'width: 35%; text-align: center;', 'after' => 'right: 0; width: 35%; padding: 0 6px; text-align: center;'), 'checkbox_type' => 'reverse')));
    /*
     * RSS (Custom RSS Feed)
     */
    // Setting
    $wp_customize->add_setting('sds_theme_options[social_media][rss_url]', array('default' => $sds_theme_options_defaults['social_media']['rss_url'], 'type' => 'option', 'sanitize_callback' => 'esc_url'));
    // Control
    $wp_customize->add_control(new WP_Customize_Control($wp_customize, 'sds_theme_options[social_media][rss_url]', array('label' => __('RSS - Custom RSS Feed', 'baton'), 'section' => 'sds_theme_options_social_media', 'settings' => 'sds_theme_options[social_media][rss_url]', 'priority' => 120, 'active_callback' => 'sds_social_media_use_custom_rss_feed')));
}