当我添加‘&Copy;’时主题检查插件出错

时间:2018-03-28 作者:Rohan Sharma

我已将新设置添加到customizer.php

$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\\u setting()的默认文本中,不会显示任何错误。

十进制代码© 也不行。

我需要展示© symbol,我有什么办法可以做到这一点吗?

1 个回复
SO网友:DevTurtle

你需要确保你有回拨功能来处理你的消毒。

$wp_customize->add_setting( \'understrap_footer_text\', array(
        \'default\'           => \'Copyright © 2017\' ,
        \'type\'              => \'theme_mod\',
        \'sanitize_callback\' => \'sanitize_textarea_field\',
        \'capability\'        => \'edit_theme_options\',
    ) );
所以你需要这样的函数

/**
 * [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 );
}

结束

相关推荐