.amp-wp-footer div { margin: 0 auto; max-width: calc(840px - 32px); padding: 1.25em 16px 1.25em; position: relative; } .amp-wp-footer h2 { font-size: 1em; line-height: 1.375em; margin: 0 0 .5em; } .amp-wp-footer p { color: <?php echo sanitize_hex_color($muted_text_color); ?> ; font-size: .8em; line-height: 1.5em; margin: 0 85px 0 0; } .amp-wp-footer a { text-decoration: none; } .back-to-top { bottom: 1.275em; font-size: .8em; font-weight: 600;
/** * HEX Color sanitization callback. * * - Sanitization: hex_color * - Control: text, WP_Customize_Color_Control * * Note: sanitize_hex_color_no_hash() can also be used here, depending on whether * or not the hash prefix should be stored/retrieved with the hex color value. * * @see sanitize_hex_color() https://developer.wordpress.org/reference/functions/sanitize_hex_color/ * @link sanitize_hex_color_no_hash() https://developer.wordpress.org/reference/functions/sanitize_hex_color_no_hash/ * * @param string $hex_color HEX color to sanitize. * @param WP_Customize_Setting $setting Setting instance. * @return string The sanitized hex color if not null; otherwise, the setting default. */ function sk_sanitize_hex_color($hex_color, $setting) { // Sanitize $input as a hex value without the hash prefix. $hex_color = sanitize_hex_color($hex_color); // If $input is a valid hex value, return it; otherwise, return the default. return !null($hex_color) ? $hex_color : $setting->default; }
/** * Output styles in the header */ function govpress_inline_styles() { $options = get_option('govpress', false); if (!$options) { return; } $output = ''; if (isset($options['header_taglinecolor'])) { $output .= ".site-description { color:" . sanitize_hex_color($options['header_taglinecolor']) . " }\n"; } // if ( isset( $options['primary_color'] ) ) { // $output .= "#site-navigation, #hero-widgets, #secondary .widget-title, #home-page-featured .widget-title, .site-footer { background:" . sanitize_hex_color( $options['primary_color'] ) . " }\n"; // } if (isset($options['primary_link_color'])) { $output .= "#content a { color:" . $options['primary_link_color'] . " }\n"; $output .= "#icon-menu a, .icon-menu-container a:before { color:" . sanitize_hex_color($options['primary_link_color']) . " }\n"; } if (isset($options['primary_link_hover'])) { $output .= "#content a:hover, #content a:focus, #content a:active { color:" . sanitize_hex_color($options['primary_link_hover']) . " }\n"; $output .= "#icon-menu a:hover, #icon-menu a:focus, #icon-menu a:active { color:" . sanitize_hex_color($options['primary_link_hover']) . " }\n"; } // Output styles if ($output != '') { $output = "<!-- Custom Styling -->\n<style type=\"text/css\">\n" . $output . "</style>\n"; echo $output; } }
/** * Generate two variants of the accent color, return the original, and * save the others as theme mods. * * @since Twenty Fourteen 1.0 * * @param string $color The original color. * @return string $color The original color, sanitized. */ function twentyfourteen_generate_accent_colors($color) { $color = sanitize_hex_color($color); set_theme_mod('accent_lighter', twentyfourteen_adjust_color($color, 29)); set_theme_mod('accent_much_lighter', twentyfourteen_adjust_color($color, 49)); return $color; }
/** * Function to sanitize hex color * * @access public * @since 1.1 * * @param $coder_input * @return int || float * */ function coder_sanitize_hex_color($coder_hex_color, $coder_setting) { // Sanitize $coder_hex_color as a hex value without the hash prefix. $coder_hex_color = sanitize_hex_color($coder_hex_color); // If $coder_hex_color is a valid hex value, return it; otherwise, return the default. return !null($coder_hex_color) ? $coder_hex_color : $coder_setting->default; }
public function check_compile_bootstrap_color($color) { // Make sure we sanatize this using default WordPress Sanatize functions $color = sanitize_hex_color($color); if (!empty($color)) { add_action('customize_save_after', array($this, 'csc_bootstrap_compiler_options')); } return $color; }
/** * Menu Position Option */ function portfoliopress_head_css() { // var_dump( get_option( 'portfoliopress' ) ); $output = ''; $mod = portfoliopress_get_option('header_color', '#000000'); $color = sanitize_hex_color($mod); if ("#000000" != $color) { $output .= "#branding { background:" . $color . " }\n"; } // Output styles if ($output != '') { $output = "<!-- Portfolio Press Styling -->\n<style type=\"text/css\">\n" . $output . "</style>\n"; echo $output; } }
/** * Sanitizes the setting values based on the setting type, and optionally the choices defined for the setting. */ public function sanitize($data) { foreach ($this->registered_settings as $setting_id => $setting) { if (!array_key_exists($setting_id, $data)) { continue; } $choices = isset($setting['choices']) ? $setting['choices'] : array(); $input = $data[$setting_id]; $sanitized = null; if (isset($setting['sanitize_cb']) && is_callable($setting['sanitize_cb'])) { $sanitized = call_user_func($setting['sanitize_cb'], $input); } else { switch ($setting['type']) { case 'checkbox': $sanitized = 1 == $input ? 1 : ''; break; case 'color': $sanitized = sanitize_hex_color($input); break; case 'dropdown-pages': $sanitized = intval($input); break; case 'file': case 'image': $sanitized = esc_url($input); break; case 'radio': case 'select': $sanitized = array_key_exists($input, $choices) ? $input : null; break; case 'text': case 'textarea': $sanitized = wp_kses_post(force_balance_tags($input)); break; case 'url': $sanitized = esc_url($input); break; default: $sanitized = sanitize_text_field($input); break; } } $data[$setting_id] = $sanitized; } return $data; }
/** * Process user options to generate CSS needed to implement the choices. * * @since 1.0.0. * * @return void */ function customizer_library_gateway_build_styles() { // Main Button color $setting = 'main_color'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('button, .button, .widget_tag_cloud a'), 'declarations' => array('background-color' => $color))); } // Blockquote Border Color $setting = 'main_color'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('blockquote'), 'declarations' => array('border-left-color' => $color))); } // Main link color $setting = 'main_color'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('a, .top-bar-section li.active:not(.has-form) a:not(.button), article .entry-footer .left i:hover, footer .textwidget a:hover i, #infinite-footer .blog-info a:hover'), 'declarations' => array('color' => $color))); } // Main link hover color $setting = 'main_color_hover'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('a:hover, .top-bar-section li.active:hover:not(.has-form) a:hover:not(.button), article .entry-footer .left i:hover, footer .textwidget a:hover i, #infinite-footer .blog-info a:hover, .top-bar-section li:not(.has-form) a:hover:not(.button), .top-bar-section .dropdown li:hover:not(.has-form):not(.active) > a:not(.button)'), 'declarations' => array('color' => $color))); } // Main Button Hover color $setting = 'main_color_hover'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('button:hover, button:focus, .button:hover, .button:focus, .button.radius:hover'), 'declarations' => array('background-color' => $color))); } }
/** * Process user options to generate CSS needed to implement the choices. * * @since 1.0.0. * * @return void */ function customizer_library_demo_build_styles() { // Primary Color $setting = 'primary-color'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('.primary'), 'declarations' => array('color' => $color))); } // Secondary Color $setting = 'secondary-color'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('.secondary'), 'declarations' => array('color' => $color))); } // Border Color $setting = 'border'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('.border'), 'declarations' => array('border-color' => $color))); } // Primary Font $setting = 'primary-font'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); $stack = customizer_library_get_font_stack($mod); if ($mod != customizer_library_get_default($setting)) { Customizer_Library_Styles()->add(array('selectors' => array('.primary'), 'declarations' => array('font-family' => $stack))); } // Secondary Font $setting = 'secondary-font'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); $stack = customizer_library_get_font_stack($mod); if ($mod != customizer_library_get_default($setting)) { Customizer_Library_Styles()->add(array('selectors' => array('.secondary'), 'declarations' => array('font-family' => $stack))); } }
function fitclub_hex_color_sanitize($color) { return sanitize_hex_color($color); }
/** * Sanitization: hex_color * Control: text, WP_Customize_Color_Control * * Sanitization callback hex colors. * * Note: sanitize_hex_color_no_hash() can also be used here, * depending on whether or not the hash prefix should be * stored/retrieved with the hex color value. * * @uses sanitize_hex_color() https://developer.wordpress.org/reference/functions/sanitize_hex_color/ * @link sanitize_hex_color_no_hash() https://developer.wordpress.org/reference/functions/sanitize_hex_color_no_hash/ */ function meso_sanitize_hex_color($input, $setting) { // Sanitize $input as a hex value // without the hash prefix. $hex = sanitize_hex_color($input); // If $input is a valid hex value, // return it; otherwise, return // the default. return !null($hex) ? $hex : $setting->default; }
function get_post_color($post_id = false) { if (is_numeric($post_id)) { $color = get_post_meta($post_id, 'pure_post_color', true); } if (empty($color)) { $color = sprintf('#%06X', mt_rand(0, 0xffffff)); } return sanitize_hex_color($color); }
/** * HEX Color sanitization callback example. * * - Sanitization: hex_color * - Control: text, WP_Customize_Color_Control * * Note: sanitize_hex_color_no_hash() can also be used here, depending on whether * or not the hash prefix should be stored/retrieved with the hex color value. * * @author WPTRT <https://github.com/WPTRT> * @author Cherry Team <*****@*****.**> * @see sanitize_hex_color() https://developer.wordpress.org/reference/functions/sanitize_hex_color/ * @link sanitize_hex_color_no_hash() https://developer.wordpress.org/reference/functions/sanitize_hex_color_no_hash/ * @since 1.0.0 * @param [string] $hex_color HEX color to sanitize. * @param WP_Customize_Setting $setting Setting instance. * @return string The sanitized hex color if not null; otherwise, the setting default. */ public function sanitize_hex_color($hex_color, $setting) { // Sanitize $input as a hex value without the hash prefix. $hex_color = sanitize_hex_color($hex_color); // If $input is a valid hex value, return it; otherwise, return the default. return '' === $hex_color ? $setting->default : $hex_color; }
/** * Sanitize type: HEX value * * @since 1.0.0 * @return integer $input */ function kihon_sanitize_color($input) { return sanitize_hex_color($input); }
/** * Sanitizes a hex color without a hash. Use sanitize_hex_color() when possible. * * Saving hex colors without a hash puts the burden of adding the hash on the * UI, which makes it difficult to use or upgrade to other color types such as * rgba, hsl, rgb, and html color names. * * Returns either '', a 3 or 6 digit hex color (without a #), or null. * * @since 3.4.0 * * @param string $color * @return string|null */ function sanitize_hex_color_no_hash($color) { $color = ltrim($color, '#'); if ('' === $color) { return ''; } return sanitize_hex_color('#' . $color) ? $color : null; }
/** * adds sanitization callback funtion : number * @package inkthemes */ public static function inkthemes_sanitize_color($value) { $value = sanitize_hex_color($value); return $value; }
/** * Process user options to generate CSS needed to implement the choices. * * @since 1.0.0. * * @return void */ function customizer_library_mystore_build_styles() { // Header Background Color $setting = 'mystore-header-bg-color'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('.site-header.mystore-header-layout-standard, .site-header.mystore-header-layout-standard .search-block'), 'declarations' => array('background-color' => $color))); } // Primary Color $setting = 'mystore-primary-color'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('#comments .form-submit #submit, .search-block .search-submit, .no-results-btn, button, input[type="button"], input[type="reset"], input[type="submit"], .woocommerce ul.products li.product a.add_to_cart_button, .woocommerce-page ul.products li.product a.add_to_cart_button, .woocommerce ul.products li.product .onsale, .woocommerce-page ul.products li.product .onsale, .woocommerce button.button.alt, .woocommerce-page button.button.alt, .woocommerce input.button.alt:hover, .woocommerce-page #content input.button.alt:hover, .woocommerce .cart-collaterals .shipping_calculator .button, .woocommerce-page .cart-collaterals .shipping_calculator .button, .woocommerce a.button, .woocommerce-page a.button, .woocommerce input.button, .woocommerce-page #content input.button, .woocommerce-page input.button, .woocommerce #review_form #respond .form-submit input, .woocommerce-page #review_form #respond .form-submit input, .woocommerce-cart .wc-proceed-to-checkout a.checkout-button, .single-product span.onsale, .main-navigation ul ul a:hover, .main-navigation ul ul li.current-menu-item > a, .main-navigation ul ul li.current_page_item > a, .main-navigation ul ul li.current-menu-parent > a, .main-navigation ul ul li.current_page_parent > a, .main-navigation ul ul li.current-menu-ancestor > a, .main-navigation ul ul li.current_page_ancestor > a, .main-navigation button, .wpcf7-submit'), 'declarations' => array('background' => 'inherit', 'background-color' => $color))); } $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('.content-area .entry-content a, #comments a, .search-btn, .post-edit-link, .site-title a, .error-404.not-found .page-header .page-title span, .search-button .fa-search, .header-cart-checkout.cart-has-items .fa-shopping-cart'), 'declarations' => array('color' => $color . ' !important'))); } // Secondary Color $setting = 'mystore-secondary-color'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('.main-navigation button:hover, #comments .form-submit #submit:hover, .search-block .search-submit:hover, .no-results-btn:hover, button, input[type="button"], input[type="reset"], input[type="submit"], .woocommerce input.button.alt, .woocommerce-page #content input.button.alt, .woocommerce .cart-collaterals .shipping_calculator .button, .woocommerce-page .cart-collaterals .shipping_calculator .button, .woocommerce a.button:hover, .woocommerce-page a.button:hover, .woocommerce input.button:hover, .woocommerce-page #content input.button:hover, .woocommerce-page input.button:hover, .woocommerce ul.products li.product a.add_to_cart_button:hover, .woocommerce-page ul.products li.product a.add_to_cart_button:hover, .woocommerce button.button.alt:hover, .woocommerce-page button.button.alt:hover, .woocommerce #review_form #respond .form-submit input:hover, .woocommerce-page #review_form #respond .form-submit input:hover, .woocommerce-cart .wc-proceed-to-checkout a.checkout-button:hover, .wpcf7-submit:hover'), 'declarations' => array('background' => 'inherit', 'background-color' => $color))); } $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('a:hover, .widget-area .widget a:hover, .site-footer-widgets .widget a:hover, .search-btn:hover, .search-button .fa-search:hover, .woocommerce #content div.product p.price, .woocommerce-page #content div.product p.price, .woocommerce-page div.product p.price, .woocommerce #content div.product span.price, .woocommerce div.product span.price, .woocommerce-page #content div.product span.price, .woocommerce-page div.product span.price, .woocommerce #content div.product .woocommerce-tabs ul.tabs li.active, .woocommerce div.product .woocommerce-tabs ul.tabs li.active, .woocommerce-page #content div.product .woocommerce-tabs ul.tabs li.active, .woocommerce-page div.product .woocommerce-tabs ul.tabs li.active'), 'declarations' => array('color' => $color))); } // Site Border Color $setting = 'mystore-site-border'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('.site-border-top, .site-border-bottom, .site-border-left, .site-border-right'), 'declarations' => array('background-color' => $color))); } // Body Font $setting = 'mystore-body-font'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); $stack = customizer_library_get_font_stack($mod); if ($mod != customizer_library_get_default($setting)) { Customizer_Library_Styles()->add(array('selectors' => array('body, .widget-area .widget a'), 'declarations' => array('font-family' => $stack))); } // Body Font Color $setting = 'mystore-body-font-color'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('body, .widget-area .widget a'), 'declarations' => array('color' => $color))); } // Heading Font $setting = 'mystore-heading-font'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); $stack = customizer_library_get_font_stack($mod); if ($mod != customizer_library_get_default($setting)) { Customizer_Library_Styles()->add(array('selectors' => array('h1, h2, h3, h4, h5, h6, h1 a, h2 a, h3 a, h4 a, h5 a, h6 a, .widget-area .widget-title, .woocommerce table.cart th, .woocommerce-page #content table.cart th, .woocommerce-page table.cart th, .woocommerce input.button.alt, .woocommerce-page #content input.button.alt, .woocommerce table.cart input, .woocommerce-page #content table.cart input, .woocommerce-page table.cart input, button, input[type="button"], input[type="reset"], input[type="submit"]'), 'declarations' => array('font-family' => $stack))); } // Heading Font Color $setting = 'mystore-heading-font-color'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('h1, h2, h3, h4, h5, h6, h1 a, h2 a, h3 a, h4 a, h5 a, h6 a, .widget-area .widget-title'), 'declarations' => array('color' => $color))); } }
/** * HEXadecimal COLOR = sanitize_hex_color */ public static function sanitize_hex_color($value, $wp_settings_instance = false) { return sanitize_hex_color($value); }
/** * Validates user input when options have been saved. * @since 2.0 */ public function validate($output, $input, $defaults) { if (in_array($input['layout'], array_keys($this->get_layouts()))) { $output['layout'] = $input['layout']; } foreach ($this->font_sets as $id => $args) { if (isset($this->fonts[$input['fonts'][$id]])) { $output['fonts'][$id] = $input['fonts'][$id]; } } foreach ($this->color_sets as $id => $color) { $output['colors'][$id] = sanitize_hex_color($input['colors'][$id]); } return $output; }
/** * Gather Options * * @since 1.0.0 * * @return array $options */ function gather_options() { // Theme defaults $primary_color = '#5bc08c'; $secondary_color = '#f99868'; // Stores all the controls that will be added $options = array(); // Stores all the sections to be added $sections = array(); // Header section $section = 'title_tagline'; $options['logo'] = array('id' => 'logo', 'label' => __('Logo', 'gather'), 'section' => $section, 'type' => 'upload', 'default' => '', 'priority' => 10); $options['center-branding'] = array('id' => 'center-branding', 'label' => __('Center Header Text/Logo', 'gather'), 'section' => $section, 'type' => 'checkbox', 'default' => 0, 'priority' => 20); $options['header-background-color'] = array('id' => 'header-background-color', 'label' => __('Header Background Color', 'gather'), 'section' => $section, 'type' => 'color', 'default' => '#ffffff', 'priority' => 30); $options['header-background-image'] = array('id' => 'header-background-image', 'label' => __('Header Background Image', 'gather'), 'section' => $section, 'type' => 'upload', 'default' => '', 'priority' => 40); $choices = array('image-scale' => 'Image Scale', 'image-repeat' => 'Image Repeat'); $options['header-background-image-style'] = array('id' => 'header-background-image-style', 'label' => __('Background Image Style', 'gather'), 'section' => $section, 'type' => 'select', 'choices' => $choices, 'default' => 'image-scale', 'priority' => 50); // Navigation Styles $section = 'navigation-styles'; $sections[] = array('id' => $section, 'title' => __('Navigation Styles', 'gather'), 'priority' => '30'); $menus = array('primary', 'secondary'); foreach ($menus as $menu) { if (!has_nav_menu($menu)) { break; } if ($menu == 'primary') { $label = __('Primary Menu'); } if ($menu == 'secondary') { $label = __('Secondary Menu'); } $options[$menu . '-menu-background'] = array('id' => $menu . '-menu-background', 'label' => __(sprintf('Background (%s)', $label), 'gather'), 'section' => $section, 'type' => 'color', 'default' => $primary_color); $mod = get_theme_mod($menu . '-menu-background', $primary_color); $color = sanitize_hex_color($mod); // 5% lighter $color_obj = new Jetpack_Color($color); $lighten5 = $color_obj->lighten(5)->toHex(); // 20% lighter $color_obj = new Jetpack_Color($color); $lighten20 = $color_obj->lighten(20)->toHex(); // Contrasting text $color_obj = new Jetpack_Color($color); $contrast = $color_obj->getGrayscaleContrastingColor()->lighten(40)->toHex(); $options[$menu . '-menu-background-hover'] = array('id' => $menu . '-menu-background-hover', 'label' => __(sprintf('Background Hover (%s)', $label), 'gather'), 'section' => $section, 'type' => 'color', 'default' => $lighten5); $options[$menu . '-menu-color'] = array('id' => $menu . '-menu-color', 'label' => __(sprintf('Text (%s)', $label), 'gather'), 'section' => $section, 'type' => 'color', 'default' => $contrast); $options[$menu . '-menu-border'] = array('id' => $menu . '-menu-border', 'label' => __(sprintf('Border (%s)', $label), 'gather'), 'section' => $section, 'type' => 'color', 'default' => $lighten20); $options[$menu . '-menu-search'] = array('id' => $menu . '-menu-search', 'label' => __(sprintf('Search Box (%s)', $label), 'gather'), 'section' => $section, 'type' => 'checkbox', 'default' => 0); } // Colors $section = 'colors'; $sections[] = array('id' => $section, 'title' => __('Colors', 'gather'), 'priority' => '80'); $options['primary-color'] = array('id' => 'primary-color', 'label' => __('Primary Color', 'gather'), 'section' => $section, 'type' => 'color', 'default' => $primary_color); $options['secondary-color'] = array('id' => 'secondary-color', 'label' => __('Secondary Color', 'gather'), 'section' => $section, 'type' => 'color', 'default' => $secondary_color); $options['site-title-color'] = array('id' => 'site-title-color', 'label' => __('Site Title Color', 'gather'), 'section' => $section, 'type' => 'color', 'default' => $primary_color); $options['site-title-hover-color'] = array('id' => 'site-title-hover-color', 'label' => __('Site Title Hover Color', 'gather'), 'section' => $section, 'type' => 'color', 'default' => $secondary_color); $options['site-tagline-color'] = array('id' => 'site-tagline-color', 'label' => __('Site Tagline Color', 'gather'), 'section' => $section, 'type' => 'color', 'default' => $primary_color); // Layout $section = 'layout'; $sections[] = array('id' => $section, 'title' => __('Layout', 'gather'), 'priority' => '70'); $choices = array('sidebar-right' => 'Sidebar Right', 'sidebar-left' => 'Sidebar Left'); $options['standard-layout'] = array('id' => 'standard-layout', 'label' => __('Standard Layout', 'gather'), 'section' => $section, 'type' => 'select', 'choices' => $choices, 'default' => 'sidebar-right'); $choices = array('standard' => 'Standard Layout', 'column-masonry-2' => '2 Column Masonry', 'column-masonry-3' => '3 Column Masonry', 'column-masonry-4' => '4 Column Masonry'); $options['archive-layout'] = array('id' => 'archive-layout', 'label' => __('Archive Layout', 'gather'), 'section' => $section, 'type' => 'select', 'choices' => $choices, 'default' => 'column-masonry-3'); $options['archive-sidebar'] = array('id' => 'archive-sidebar', 'label' => __('Display Sidebar on Archives', 'gather'), 'section' => $section, 'type' => 'checkbox', 'default' => 0); // Typography $section = 'typography'; $sections[] = array('id' => $section, 'title' => __('Typography', 'gather'), 'priority' => '75'); $options['site-title-font'] = array('id' => 'site-title-font', 'label' => __('Site Title Font', 'gather'), 'section' => $section, 'type' => 'select', 'choices' => customizer_library_get_font_choices(), 'default' => 'Monoton'); $options['primary-font'] = array('id' => 'primary-font', 'label' => __('Primary Font', 'gather'), 'section' => $section, 'type' => 'select', 'choices' => customizer_library_get_font_choices(), 'default' => 'Roboto'); $options['secondary-font'] = array('id' => 'secondary-font', 'label' => __('Secondary Font', 'gather'), 'section' => $section, 'type' => 'select', 'choices' => customizer_library_get_font_choices(), 'default' => 'Merriweather'); // Archive Settings $section = 'archive'; $sections[] = array('id' => $section, 'title' => __('Archive', 'gather'), 'priority' => '80'); $options['archive-excerpts'] = array('id' => 'archive-excerpts', 'label' => __('Display Excerpts', 'gather'), 'description' => __('Display excerpts instead of full content.', 'gather'), 'section' => $section, 'type' => 'checkbox', 'default' => 0); $options['archive-featured-images'] = array('id' => 'archive-featured-images', 'label' => __('Display Featured Images', 'gather'), 'section' => $section, 'type' => 'checkbox', 'default' => 1); // Post Settings $section = 'post'; $sections[] = array('id' => $section, 'title' => __('Post', 'gather'), 'priority' => '80'); $options['display-post-dates'] = array('id' => 'display-post-dates', 'label' => __('Display Post Dates', 'gather'), 'section' => $section, 'type' => 'checkbox', 'default' => 1); $options['post-featured-images'] = array('id' => 'post-featured-images', 'label' => __('Display Featured Images', 'gather'), 'section' => $section, 'type' => 'checkbox', 'default' => 1); // Footer Settings $section = 'footer'; $sections[] = array('id' => $section, 'title' => __('Footer', 'gather'), 'priority' => '100'); $options['footer-text'] = array('id' => 'footer-text', 'label' => __('Footer Text', 'gather'), 'section' => $section, 'type' => 'textarea', 'default' => gather_get_default_footer_text()); // Adds the sections to the $options array $options['sections'] = $sections; $customizer_library = Customizer_Library::Instance(); $customizer_library->add_options($options); }
/** * Process user options to generate CSS needed to implement the choices. * * @since 1.0.0. * * @return void */ function customizer_library_demo_build_styles() { /*-------------------------------------------------------------- 2.0 Home --------------------------------------------------------------*/ // Home Hero Overly Color $setting = 'home_overlay_color'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('.color-overlay:before'), 'declarations' => array('background-color' => $color))); } // Home Hero Opacity Level $setting = 'home_opacity'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $numeral = customizer_library_sanitize_text($mod); Customizer_Library_Styles()->add(array('selectors' => array('.color-overlay:before'), 'declarations' => array('opacity' => $numeral))); } /*-------------------------------------------------------------- 5.0 Colors Sitewide --------------------------------------------------------------*/ // Color: Headers $setting = 'color-headers'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('.content-area h1, .content-area h2, .content-area h3, .content-area h4, .content-area h5, .content-area h6, .page-header h1'), 'declarations' => array('color' => $color))); } // Color: Content $setting = 'color-content'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('.entry-content p, .comment_content p, .home-secondary-content p'), 'declarations' => array('color' => $color))); } // Color: Links $setting = 'color-content-link'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('#content a, .hero-widgets-wrap a'), 'declarations' => array('color' => $color))); } // Color: Link Hover $setting = 'color-content-link-hover'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('#content a:hover, .comment_content a:hover, .hero-widgets-wrap a:hover'), 'declarations' => array('color' => $color))); } // Color: Top Mini Bar $setting = 'color-content-top-bar'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('.mini-header'), 'declarations' => array('background-color' => $color))); } // Color: Body Background $setting = 'color-content-body-bg'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('body, .home .content-area'), 'declarations' => array('background-color' => $color))); } // Color: Content Background $setting = 'color-content-bg'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('#page .site-content .row'), 'declarations' => array('background-color' => $color))); } // Color: Comments Background $setting = 'color-comments-bg'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('#comments ol.comment-list .comment-content-wrap'), 'declarations' => array('background-color' => $color))); } }
<?php if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $meta = get_post_meta($post->ID); $template_name = Village_Class_Ext::get_from_meta($meta, "_wp_page_template", null); // Turns "templates/page-someVeryNice-Page_123.php" into "someVeryNice-Page_123" // Also accepts files not in the templates directory // Otherwise filters down to null and get_template_part is going to use the default tempalte $template_name = preg_replace("/(?:templates\\/)?page-([^.]*)\\.php/", "\$1", $template_name); $page_title_enabled = Village_Class_Ext::get_from_meta($meta, "acid_page_title_enabled", true); // Colors $page_color = sanitize_hex_color(Village_Class_Ext::get_from_meta($meta, "acid_page_color")); $page_font_color = sanitize_hex_color(Village_Class_Ext::get_from_meta($meta, "acid_page_font_color")); $page_title_color = sanitize_hex_color(Village_Class_Ext::get_from_meta($meta, "acid_page_title_color")); $page_title_font_color = sanitize_hex_color(Village_Class_Ext::get_from_meta($meta, "acid_page_title_font_color")); // Page Width $page_width = Village_Class_Ext::get_from_meta($meta, "acid_page_width", "960"); // Make sure the page width is only numbers, so we can safely set that to "px" $page_width = preg_replace('/[^0-9]/', '', $page_width); ?> <?php if (false !== $page_title_enabled) { ?> <div class="hscol vertical-title-container" style="<?php echo $page_title_color ? "background-color: {$page_title_color}; " : null; echo $page_title_font_color ? "color: {$page_title_font_color}; " : null; ?> "> <div class="arrow-right"<?php
/** * Banner inline styles * * @return void * @author **/ function hb_site_banner_inline_styles() { $css = ''; if (ot_get_option('promo')) { $css .= '#promo {'; $css .= 'color:' . sanitize_hex_color(ot_get_option('promo_color')) . ';'; $css .= 'background:' . sanitize_hex_color(ot_get_option('promo_bg')) . ';'; $css .= '}'; } if ((is_single() && 'post' == get_post_type() || is_page()) && has_post_thumbnail(get_the_ID())) { $thumb = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'full'); $css .= '#hb-banner-img{'; $css .= 'background-image:url(' . esc_url(current($thumb)) . ')'; $css .= '}'; } if (empty($css)) { $css = '#love-you{position:absolute;}'; } // fix pjax call wp_add_inline_style('SDG-style', $css); }
/** * Sanitizes a hex color. Always adds hash to color * use sanitize_hex_color if exist * * @since 4.0.0 * * @param string $color maybe HEX color * @return string|null sanitized color */ function cherry_sanitize_hex_color($color) { $color = ltrim($color, '#'); $color = '#' . $color; if ('' === $color) { return ''; } if (function_exists('sanitize_hex_color')) { return sanitize_hex_color($color); } // 3 or 6 hex digits, or the empty string. if (preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color)) { return $color; } return null; }
function jbst_sanitize_hex_color($setting) { if (empty($setting)) { return ''; } return sanitize_hex_color($setting); }
/** * Sanitize hex color. * * @param string $value Value to sanitize. * @return sanitized value. * @uses sanitize_hex_color() * @since SG Window 1.0.0 */ function sgwindow_sanitize_hex_color($value) { return sanitize_hex_color($value); }
/** * adds sanitization callback funtion : number * @package onepage */ public static function onepage_sanitize_color($value) { $value = sanitize_hex_color($value); return $value; }
/** * Process user options to generate CSS needed to implement the choices. * * @since 1.0.0. * * @return void */ function customizer_library_squarely_build_styles() { // Primary Color $setting = 'header-hero'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { Customizer_Library_Styles()->add(array('selectors' => array('.section-hero'), 'declarations' => array('background-image' => 'url(' . $mod . ')'))); } $setting = 'brand-primary'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('.primary-bg', '.btn-primary', '.icon-btn-primary', '.fbox-icon i:hover', '.fbox-icon i', '.br-primary'), 'declarations' => array('background-color' => $color, 'border-color' => $color))); Customizer_Library_Styles()->add(array('selectors' => array('.text-primary', '.c-primary', '.btn-primary-outline', 'icon-btn-primary-outline', '.btn-link', '.border-sm-primary', 'a', '.nav-link', '.social-icons', '.navbar-brand'), 'declarations' => array('color' => $color, 'border-color' => $color))); } // Secondary Color $setting = 'brand-secondary'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('.secondary-bg', '.btn-secondary', '.icon-btn-secondary'), 'declarations' => array('background-color' => $color, 'border' => $color))); $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('.secondary'), 'declarations' => array('color' => $color, 'border' => $color))); } // Success Color $setting = 'brand-success'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('.success-bg', '.bg-success', '.btn-success', '.icon-btn-success'), 'declarations' => array('background-color' => $color, 'border-color' => $color))); Customizer_Library_Styles()->add(array('selectors' => array('.c-success', '.text-success', '.btn-success-outline', '.icon-btn-success-outline', '.success-outline'), 'declarations' => array('color' => $color, 'border-color' => $color))); } // Success Color $setting = 'brand-info'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('.info-bg', '.bg-info', '.btn-info', '.icon-btn-info'), 'declarations' => array('background-color' => $color, 'border-color' => $color))); Customizer_Library_Styles()->add(array('selectors' => array('.c-info', '.text-info', '.btn-info-outline', '.icon-btn-info-outline'), 'declarations' => array('color' => $color, 'border-color' => $color))); } // Border Color $setting = 'body-color'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod !== customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('body', '.c-gray'), 'declarations' => array('color' => $color))); } // Primary Font $setting = 'primary-font'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); $stack = customizer_library_get_font_stack($mod); if ($mod != customizer_library_get_default($setting)) { Customizer_Library_Styles()->add(array('selectors' => array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'a', 'li', 'body'), 'declarations' => array('font-family' => $stack))); } // Secondary Font $setting = 'secondary-font'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); $stack = customizer_library_get_font_stack($mod); if ($mod != customizer_library_get_default($setting)) { Customizer_Library_Styles()->add(array('selectors' => array('.script'), 'declarations' => array('font-family' => $stack))); } $setting = 'body_font_color'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod != customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('body'), 'declarations' => array('color' => $color))); } $setting = 'body_background'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod != customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('body'), 'declarations' => array('background-color' => $color))); } $setting = 'nav-background'; $mod = get_theme_mod($setting, customizer_library_get_default($setting)); if ($mod != customizer_library_get_default($setting)) { $color = sanitize_hex_color($mod); Customizer_Library_Styles()->add(array('selectors' => array('.navbar-custom'), 'declarations' => array('background-color' => $color))); } }
/** * Return the default HEX value for a color in a scheme. * * @param string $color * @param string $scheme (optional) * @param bool $hash (optional) * * @return string|null */ public function get_default_color($color, $scheme = '', $hash = false) { /** * Load for backwards compatibility prior to WordPress 4.6. * * @link https://core.trac.wordpress.org/ticket/27583 * @since 1.0.0 */ if (!function_exists('sanitize_hex_color') || !function_exists('sanitize_hex_color_no_hash')) { require_once ABSPATH . 'wp-includes/class-wp-customize-manager.php'; } $scheme = empty($scheme) ? $this->get_current_color_scheme_array() : $this->color_schemes[$this->sanitize_color_scheme($scheme)]; $hex = isset($scheme['colors'][$color]) ? trim($scheme['colors'][$color], '#') : null; return $hash ? sanitize_hex_color('#' . $hex) : sanitize_hex_color_no_hash($hex); }