我正试图从下面的设置中获得输出,但它现在正在工作并显示为空白。当我尝试在计划文本中echo
时,有时它会出现在自定义模式中。我正在使用<?php echo get_theme_mod( 'shoplabel_color' ); ?>
来获取输出。有没有我缺少的东西,比如javascript或其他东西?
$wp_customize->add_setting('label_color',
array(
'default' => '43AC6A',
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'theme_slug_sanitize_hex_color'
));
$wp_customize->add_control(
new WP_Customize_Color_Control($wp_customize, 'label_color',
array (
'settings' => 'label_color',
'section' => 'my_theme_page',
'label' => __( 'Label color', 'theme_slug' )
) ));
好的,解决了我从芯片代码中复制的默认函数的问题,所以现在我写了新函数,它正在中工作
function theme_slug_sanitize_hex_color( $color ) {
if ( '' === $color )
return '';
// 3 or 6 hex digits, or the empty string.
if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) )
return $color;
return null;
}