doumi1912 2015-06-23 13:01
浏览 8
已采纳

颜色选项主题定制器API无输出

I'm trying to get output from below setting but it is now working and displaying blank. When I try to echo in plan text then some times it appear in customizer mode. i'm using <?php echo get_theme_mod( 'shoplabel_color' ); ?> to Get output. Is there anything which i'm missing like javascript or any?

$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' )


                     )  ));
  • 写回答

1条回答 默认 最新

  • dougou6213 2015-06-24 16:40
    关注

    Ok resolve the issue problem in default function which i copied from chip code so now I write new function, It's working

    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;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用