当前位置: 首页>>代码示例>>PHP>>正文


PHP sanitize_hex_color函数代码示例

本文整理汇总了PHP中sanitize_hex_color函数的典型用法代码示例。如果您正苦于以下问题:PHP sanitize_hex_color函数的具体用法?PHP sanitize_hex_color怎么用?PHP sanitize_hex_color使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sanitize_hex_color函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: calc

.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;
开发者ID:thenextweb,项目名称:amp-wp,代码行数:31,代码来源:style.php

示例2: sk_sanitize_hex_color

/**
 * 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;
}
开发者ID:brianjking,项目名称:Genesis-Header-Background-Customizer,代码行数:23,代码来源:plugin.php

示例3: govpress_inline_styles

/**
 * 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;
    }
}
开发者ID:HeliWang,项目名称:EngSoc-Website,代码行数:30,代码来源:customizer.php

示例4: twentyfourteen_generate_accent_colors

/**
 * 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;
}
开发者ID:jacques,项目名称:wordpress,代码行数:16,代码来源:customizer.php

示例5: coder_sanitize_hex_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;
 }
开发者ID:kafleg,项目名称:coder-customizer-framework,代码行数:17,代码来源:sanitize-color.php

示例6: check_compile_bootstrap_color

 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;
 }
开发者ID:mread1208,项目名称:wordpress-customizer-sass-compiler,代码行数:9,代码来源:class-customizer-options-bootstrap.php

示例7: portfoliopress_head_css

/**
 * 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;
    }
}
开发者ID:cherylabu,项目名称:portfolio-press,代码行数:18,代码来源:mods.php

示例8: sanitize

 /**
  * 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;
 }
开发者ID:r-moiseev,项目名称:jets,代码行数:49,代码来源:Customizer.php

示例9: customizer_library_gateway_build_styles

 /**
  * 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)));
     }
 }
开发者ID:bettirosengugi,项目名称:My-Web-Projects,代码行数:45,代码来源:styles.php

示例10: customizer_library_demo_build_styles

 /**
  * 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)));
     }
 }
开发者ID:nick144,项目名称:customizer-library-demo,代码行数:45,代码来源:styles.php

示例11: fitclub_hex_color_sanitize

 function fitclub_hex_color_sanitize($color)
 {
     return sanitize_hex_color($color);
 }
开发者ID:themegrill,项目名称:fitclub,代码行数:4,代码来源:customizer.php

示例12: meso_sanitize_hex_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;
}
开发者ID:jun200,项目名称:wordpress,代码行数:23,代码来源:sanitization-callbacks.php

示例13: get_post_color

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);
}
开发者ID:apennell,项目名称:static_portfolio,代码行数:10,代码来源:functions.php

示例14: sanitize_hex_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 <cherryframework@gmail.com>
  * @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;
 }
开发者ID:CherryFramework,项目名称:cherry-framework,代码行数:25,代码来源:cherry-customizer.php

示例15: kihon_sanitize_color

 /**
  * Sanitize type: HEX value
  *
  * @since 1.0.0
  * @return integer $input
  */
 function kihon_sanitize_color($input)
 {
     return sanitize_hex_color($input);
 }
开发者ID:ajshortt,项目名称:alex-shortt,代码行数:10,代码来源:customizer-sanitize.php


注:本文中的sanitize_hex_color函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。