예제 #1
0
파일: Epic.php 프로젝트: ITJ-RSA/Epic-Theme
 /**
  * This function sets the default color for the content area in the Theme Customizer.
  */
 function theme_mod_content_color($color)
 {
     // Return the current color if set
     if ($color) {
         return $color;
     }
     // Return the selected color scheme content color if set
     if ($selected_color_scheme = sds_get_color_scheme()) {
         return $selected_color_scheme['content_color'];
     }
     // Load all color schemes for this theme
     $color_schemes = sds_color_schemes();
     // Return the default color scheme content color
     return $color_schemes['default']['content_color'];
 }
예제 #2
0
/**
 * This function determines whether or not the user has selected a color scheme and returns
 * the color scheme details if they have.
 *
 * The default color scheme can be ignored and thus if the user has selected the default color
 * scheme it will not be returned.
 */
function sds_get_color_scheme($ignore_default = true)
{
    global $sds_theme_options;
    // Return value
    $r = false;
    // Default and all other color schemes (when user has selected options)
    if (function_exists('sds_color_schemes') && !empty($sds_theme_options['color_scheme'])) {
        $color_schemes = sds_color_schemes();
        if (!empty($sds_theme_options['color_scheme']) && isset($color_schemes[$sds_theme_options['color_scheme']])) {
            $selected_color_scheme = array_key_exists($sds_theme_options['color_scheme'], $color_schemes) ? $color_schemes[$sds_theme_options['color_scheme']] : false;
            // Is this the default color scheme?
            $default_color_scheme = isset($selected_color_scheme['default']) && $selected_color_scheme['default'] ? true : false;
            // If we're not ignoring the default, or we are and this isn't a default color scheme
            if (!$ignore_default || !$default_color_scheme) {
                $r = $selected_color_scheme;
            }
        }
    } else {
        if (function_exists('sds_color_schemes') && empty($sds_theme_options['color_scheme']) && !$ignore_default) {
            $color_schemes = sds_color_schemes();
            $r = $color_schemes['default'];
        }
    }
    return apply_filters('sds_color_scheme', $r, $ignore_default);
}
 /**
  * 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.
  */
 function pre_get_posts()
 {
     global $sds_theme_options, $post;
     $protocol = is_ssl() ? 'https' : 'http';
     // Admin only
     if (is_admin()) {
         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']);
         }
         // Droid 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=Droid+Sans:400,700'));
         }
         // Google WebFonts (Droid Sans)
         // Fetch page template if any on Pages only
         if (!empty($post) && $post->post_type === 'page') {
             $wp_page_template = get_post_meta($post->ID, '_wp_page_template', true);
         }
         // Admin only and if we have a post using our full page or landing page templates
         if (isset($wp_page_template) && ($wp_page_template === 'template-full-width.php' || $wp_page_template === 'template-landing-page.php')) {
             add_editor_style('css/editor-style-full-width.css');
         }
     }
 }
예제 #4
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');
 }
예제 #5
0
 /**
  * This function sanitizes input from the user when saving options.
  */
 public function sds_theme_options_sanitize($input)
 {
     // Reset to Defaults
     // TODO: Allow for reset in the Customizer?
     if (isset($input['reset'])) {
         return $this->get_sds_theme_option_defaults();
     }
     // Remove Logo
     if (isset($input['remove-logo'])) {
         unset($input['remove-logo']);
         // We don't want to store this value in the options array
         $input['logo_attachment_id'] = false;
     }
     // Parse arguments, replacing defaults with user input
     $input = wp_parse_args($input, $this->get_sds_theme_option_defaults());
     // General
     $input['logo_attachment_id'] = !empty($input['logo_attachment_id']) ? (int) $input['logo_attachment_id'] : '';
     $input['color_scheme'] = sanitize_text_field($input['color_scheme']);
     $input['web_font'] = !empty($input['web_font']) && $input['web_font'] !== 'default' ? sanitize_text_field($input['web_font']) : false;
     $input['hide_tagline'] = $input['hide_tagline'] ? true : false;
     // Color Scheme (remove content/background colors if they match another color scheme's default values)
     if (!empty($input['color_scheme'])) {
         // Get color schemes
         $color_schemes = function_exists('sds_color_schemes') ? sds_color_schemes() : array();
         if (!empty($color_schemes)) {
             unset($color_schemes[$input['color_scheme']]);
             // Remove current color scheme
             // Get current theme mods
             $theme_mod_content_color = get_theme_mod('content_color');
             $theme_mod_background_color = get_theme_mod('background_color');
             // Loop through color schemes
             foreach ($color_schemes as $color_scheme_id => $color_scheme) {
                 // Check to see if the current content color theme mod matches this color scheme's default value
                 if ($color_scheme['content_color'] === $theme_mod_content_color) {
                     remove_theme_mod('content_color');
                 }
                 // Check to see if the current background color theme mod matches this color scheme's default value
                 if (isset($color_scheme['background_color']) && ltrim($color_scheme['background_color'], '#') === $theme_mod_background_color) {
                     remove_theme_mod('background_color');
                 }
             }
         }
     }
     // Content Layouts
     foreach ($input['content_layouts'] as $key => &$value) {
         $value = $value !== 'default' ? sanitize_text_field($value) : false;
     }
     // Social Media
     foreach ($input['social_media'] as $key => &$value) {
         // RSS Feed (use site feed)
         if ($key === 'rss_url_use_site_feed' && $value) {
             $value = true;
             $input['social_media']['rss_url'] = '';
         } else {
             $value = esc_url($value);
         }
     }
     // Ensure the 'rss_url_use_site_feed' key is set in social media
     if (!isset($input['social_media']['rss_url_use_site_feed'])) {
         $input['social_media']['rss_url_use_site_feed'] = false;
     }
     return $input;
 }
예제 #6
0
 /**
  * This function sets/resets the current color scheme for use in the Customizer.
  */
 public function wp_loaded()
 {
     global $sds_theme_options;
     // Set the current Baton color scheme
     $sds_color_schemes = sds_color_schemes();
     $this->sds_color_scheme = !empty($sds_theme_options['color_scheme']) && array_key_exists($sds_theme_options['color_scheme'], $sds_color_schemes) ? $sds_color_schemes[$sds_theme_options['color_scheme']] : $this->sds_color_scheme;
 }
    /**
     * This function renders the control's content.
     */
    public function render_content()
    {
        ?>
		<div class="sds-theme-options-color-schemes-wrap customize-sds-theme-options-color-schemes-wrap">
			<span class="customize-control-title"><?php 
        echo esc_html($this->label);
        ?>
</span>

			<?php 
        if (!empty($this->description)) {
            ?>
				<span class="description customize-control-description"><?php 
            echo $this->description;
            ?>
</span>
			<?php 
        }
        ?>

			<?php 
        foreach (sds_color_schemes() as $name => $atts) {
            ?>
				<div class="sds-theme-options-color-scheme sds-theme-options-color-scheme-<?php 
            echo $name;
            ?>
">
					<label>
						<input type="radio" id="sds_theme_options_color_scheme_<?php 
            echo $name;
            ?>
" name="sds_theme_options[color_scheme]" <?php 
            checked(!$this->value() && isset($atts['default']) && $atts['default'] || $this->value() === $name);
            ?>
 value="<?php 
            echo esc_attr($name);
            ?>
" <?php 
            $this->link();
            ?>
 />

						<?php 
            if (isset($atts['preview']) && !empty($atts['preview'])) {
                ?>
							<div class="sds-theme-options-color-scheme-preview" style="background: <?php 
                echo esc_attr($atts['preview']);
                ?>
">&nbsp;</div>
						<?php 
            }
            ?>

						<?php 
            echo isset($atts['label']) ? $atts['label'] : false;
            ?>
					</label>
				</div>
			<?php 
        }
        ?>
		</div>
	<?php 
    }