首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >添加“©”时主题检查插件错误

添加“©”时主题检查插件错误
EN

WordPress Development用户
提问于 2018-03-28 04:42:46
回答 1查看 144关注 0票数 0

我给customizer.php添加了一个新设置

代码语言:javascript
复制
$wp_customize->add_setting( 'understrap_footer_text', array(
        'default'           => 'Copyright © 2017' ,
        'type'              => 'theme_mod',
        'sanitize_callback' => 'sanitize_textarea_field',
        'capability'        => 'edit_theme_options',
    ) );
        $wp_customize->add_control(
        new WP_Customize_Control(
            $wp_customize,
            'understrap_footer_text', array(
                'label'       => __( 'Footer Text', 'understrap' ),
                'description' => __( "No HTML", 'understrap'),
                'section'     => 'understrap_theme_post_options',
                'settings'    =>  'understrap_footer_text',
                'type'        => 'textarea',
                'priority'    => '10',
            )
        ) );

主题检查插件错误:REQUIRED: Found a Customizer setting that did not have a sanitization callback function. Every call to the add_setting() method needs to have a sanitization callback function passed.

当我从默认的© ()文本中删除add_setting()时,它没有显示错误。

十进制代码©也不能工作。

我需要显示©符号,有什么方法可以让这个工作吗?

EN

回答 1

WordPress Development用户

发布于 2018-03-28 09:26:08

您需要确保您有回调函数来处理您的卫生处理。

代码语言:javascript
复制
$wp_customize->add_setting( 'understrap_footer_text', array(
        'default'           => 'Copyright © 2017' ,
        'type'              => 'theme_mod',
        'sanitize_callback' => 'sanitize_textarea_field',
        'capability'        => 'edit_theme_options',
    ) );

所以你需要像这样的函数

代码语言:javascript
复制
/**
 * [sanitize_html description]
 * @param  [string] $input [input from textarea]
 * @return [string]        [sanitize all input no tags]
 */
function sanitize_textarea_field( $input ) {
    return wp_strip_all_tags( $input );
}
票数 1
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/299137

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档