找到一个没有清理回调功能的定制程序设置。WordPress主题检查插件

阿米特·米什拉(Amit Mishra)

我已经添加'sanitize_callback'到每个add_setting()函数,但它仍然显示错误。请任何人检查我的代码段并给我建议

function bookish_customize_register( $wp_customize ) {

$wp_customize->get_setting( 'blogname' )->transport        = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';

$wp_customize->remove_control( 'header_textcolor' );
$wp_customize->remove_control( 'background_color' );
$wp_customize->remove_section( 'background_image' );
$wp_customize->remove_section( 'header_image' );

/*-----------------------------------------------------------*
 * Assent Color  section
 *-----------------------------------------------------------*/ 

$wp_customize->add_setting(
    'tcx_link_color',
    array(
        'default'     => '#000000',
        'sanitize_callback' => 'bookish_sanitize_text',
        'transport'   => 'postMessage',

    )
);

$wp_customize->add_control(
    new WP_Customize_Color_Control(
        $wp_customize,
        'link_color',
        array(
            'label'      => __( 'Link Color', 'tcx' ),
            'section'    => 'colors',
            'settings'   => 'tcx_link_color'
        )
    )
);
/*-----------------------------------------------------------*
 * Defining General Setting  section
 *-----------------------------------------------------------*/

$wp_customize->add_section(
    'bookish_general_setting',
    array(
        'title'     => 'General Settings',
        'priority'  => 1

    )
);



$wp_customize->add_setting(
            'bookish-logo',
            array(
                'default' => '',
                'sanitize_callback' => 'esc_url_raw',
                'transport'   => 'postMessage',

            )
        );

$wp_customize->add_control(
    new WP_Customize_Image_Control(
        $wp_customize,
        'bookish-logo',
        array(
            'label'    => __( ' Logo', 'bookish' ),
            'section'  => 'bookish_general_setting',
            'settings' => 'bookish-logo',
            'priority' => 1

        )
    )
);

$wp_customize->add_setting(
        'bookish-retina-logo',
        array(
            'default' => '',
            'sanitize_callback' => 'esc_url_raw',
            'transport'   => 'postMessage',
        )
    );

$wp_customize->add_control(
    new WP_Customize_Image_Control(
        $wp_customize,
        'bookish-retina-logo',
        array(
            'label'    => __( 'Retina Logo', 'bookish' ),
            'section'  => 'bookish_general_setting',
            'settings' => 'bookish-retina-logo',
            'priority' => 2

        )
    )
);

$wp_customize->add_setting(
    'bookish-favicon',
    array(
        'default'  => '',
        'sanitize_callback' => 'esc_url_raw',
        'transport'   => 'postMessage',

    )
);

$wp_customize->add_control(
    new WP_Customize_Image_Control(
        $wp_customize,
        'bookish-favicon',
        array(
            'label'    => __( ' Favicon', 'bookish' ),
            'section'  => 'bookish_general_setting',
            'settings' => 'bookish-favicon',
            'priority' => 3

        )
    )
);

$wp_customize->add_setting(
    'bookish-avatar',
    array(
        'default'          => '',
        'sanitize_callback' => 'esc_url_raw',
        'transport'   => 'postMessage',

    )
);

$wp_customize->add_control(
    new WP_Customize_Image_Control(
        $wp_customize,
        'bookish-avatar',
        array(
            'label'    => __( 'Avatar', 'bookish' ),
            'section'  => 'bookish_general_setting',
            'settings' => 'bookish-avatar',
            'priority' => 4
        )
    )
);

$wp_customize->add_setting(
    'bookish-retina-avatar',
    array(
        'default'          => '',
        'sanitize_callback' => 'esc_url_raw',
        'transport'   => 'postMessage',

    )
);

$wp_customize->add_control(
    new WP_Customize_Image_Control(
        $wp_customize,
        'bookish-retina-avatar',
        array(
            'label'    => __( 'Retina Avatar', 'bookish' ),
            'section'  => 'bookish_general_setting',
            'settings' => 'bookish-retina-avatar',
            'priority' => 5
        )
    )
);

$wp_customize->add_setting(
    'bookish_profile_name',
    array(
        'default'    =>  'Vincent Doe',
        'sanitize_callback' => 'bookish_sanitize_text',
        'transport'  =>  'postMessage',
    )
);

$wp_customize->add_control(
    'bookish_profile_name',
    array(
        'section'   => 'bookish_general_setting',
        'label'     => 'Profile Name',
        'type'      => 'text'
    )
);

$wp_customize->add_setting(
    'bookish_profile_desc',
    array(
        'default'    =>  'I lie close to the earth, a thousand unknown plants are noticed by me: when I hear the buzz of the little world among the stalks.',
        'sanitize_callback' => 'bookish_sanitize_textarea',
        'transport'  =>  'postMessage',

    )
);

$wp_customize->add_control(
    'bookish_profile_desc',
    array(
        'section'   => 'bookish_general_setting',
        'label'     => 'Profile Description',
        'type'      => 'textarea'
    )
);

$wp_customize->add_section(
    'contact_setting',
    array(
        'title'     => 'Contact Info',
        'priority'  => 2
    )
);

$wp_customize->add_setting(
    'contact_heading',
    array(
        'default'    =>  'Get in touch',
        'sanitize_callback' => 'bookish_sanitize_text',
        'transport'  =>  'postMessage',
    )
);

$wp_customize->add_control(
    'contact_heading',
    array(
        'section'   => 'contact_setting',
        'label'     => 'Contact Heading',
        'type'      => 'text'
    )
);

$wp_customize->add_setting(
    'contact_email',
    array(
        'default'    =>  '',
        'sanitize_callback' => 'bookish_sanitize_email',
        'transport'  =>  'postMessage',
    )
);

$wp_customize->add_control(
    'contact_email',
    array(
        'section'   => 'contact_setting',
        'label'     => 'Email',
        'type'      =>  'email'

    )
);

$wp_customize->add_setting(
    'contact_phone',
    array(
        'default'    =>  '',
        'sanitize_callback' => 'bookish_sanitize_number',
        'transport'  =>  'postMessage',
    )
);

$wp_customize->add_control(
    'contact_phone',
    array(
        'section'   => 'contact_setting',
        'label'     => 'Phone Number',
        'type'      => 'text'
    )
);

}

add_action( 'customize_register', 'bookish_customize_register', 11 );

/**
 * Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
 */
function bookish_customize_preview_js() {
    wp_enqueue_script( 'bookish_customizer', get_template_directory_uri() . '/assets/js/customizer.js', array( 'customize-preview' ), '20130508', true );
}
add_action( 'customize_preview_init', 'bookish_customize_preview_js' );

function bookish_sanitize_text( $str ) {
    return sanitize_text_field( $str );
} 

function bookish_sanitize_textarea( $text ) {
    return esc_textarea( $text );
} 

function bookish_sanitize_number( $int ) {
    return absint( $int );
} 

function bookish_sanitize_email( $email ) {
    if(is_email( $email )){
        return $email;
    }else{
        return '';
    }
} 

function bookish_sanitize_file_url( $url ) {
    $output = '';
    $filetype = wp_check_filetype( $url );
    if ( $filetype["ext"] ) {
        $output = esc_url( $url );
    }
    return $output;
}

function tcx_customizer_css() {
?>
     <style type="text/css">

        .TopBanner { background-color: <?php echo get_theme_mod( 'tcx_link_color' ); ?>!important; }

     </style>
<?php
}
add_action( 'wp_head', 'tcx_customizer_css' );

提前致谢

阿米特·米什拉(Amit Mishra)

安装主题检查插件,然后修改plugins / theme-check / checks / customizer.php文件

添加 echo "$file_path: $match ";

在这段代码之后:

`if ( false === strpos( $match, 'sanitize_callback' ) && false === strpos( $match, 'sanitize_js_callback' ) ) {
$this->error[] = '<span class="tc-lead tc-required">' .       __('REQUIRED','theme-check') . '</span>: ' . __( 'Found a Customizer setting that did not have a sanitization callback function. Every call to the <strong>add_setting()</strong> method needs to have a sanitization callback function passed.', 'theme-check' );`

这应该指示导致错误的文件和代码片段。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

找到一个没有清理回调功能的定制程序设置。WordPress主题检查插件

来自分类Dev

你能找到一个网站的 wordpress 主题吗?

来自分类Dev

我有一个节点异步功能示例。回调未返回预期值

来自分类Dev

没有回调的链接功能

来自分类Dev

jQuery在同一函数中使用两个完成的回调,一个具有数据类型json,一个没有

来自分类Dev

多个Ajax请求(带有一个回调)

来自分类Dev

清理 csv 数据,w/pandas 有没有办法找到第一个可以转换为 # 的 obj 列?

来自分类Dev

如何检查以找到两个向量之间没有的第一个对象?

来自分类Dev

有没有办法简化功能,一次性检查所有输入框,而不是一个一个

来自分类Dev

wordpress,在我的插件名称下为我的插件添加一个设置操作链接

来自分类Dev

创建一个promise回调

来自分类Dev

尝试设置第一个应用程序,但网站没有打球

来自分类Dev

创建一个WordPress主题

来自分类Dev

将一个主题的数据放入回调函数中的动态数组中并进行一些计算

来自分类Dev

AJAX成功回调仅执行第一个功能

来自分类Dev

AJAX成功回调仅执行第一个功能

来自分类Dev

需要找到一个分支而没有进入vobs

来自分类Dev

回调必须是一个函数。收到null / socket.io /设置间隔

来自分类Dev

ReactJS通过props回调设置另一个类的状态

来自分类Dev

在函数内部设置一个属性并在 Element get 后回调

来自分类Dev

使用另一个类的 unique_ptr 设置回调函数

来自分类Dev

在没有所有高级功能的情况下在intelliJ中创建并运行一个简单的Java程序?

来自分类Dev

没有回调作为参数的模拟功能

来自分类Dev

在android中成功安装另一个应用程序后的回调

来自分类Dev

R:找到一个向量中没有出现在另一个向量中的每个元素并将其设置为零

来自分类Dev

具有回调功能的驱动程序

来自分类Dev

if 语句在函数内部没有找到变量(Wordpress 插件)

来自分类Dev

[javascript,jQuery]如何在继续播放另一个没有回调的动画之前等待动画完全完成

来自分类Dev

iOS中的iBeacons-从实际的BLE设备没有回调,但是当将另一个iOS设备用作广播器时,didRangeBeacons被调用

Related 相关文章

  1. 1

    找到一个没有清理回调功能的定制程序设置。WordPress主题检查插件

  2. 2

    你能找到一个网站的 wordpress 主题吗?

  3. 3

    我有一个节点异步功能示例。回调未返回预期值

  4. 4

    没有回调的链接功能

  5. 5

    jQuery在同一函数中使用两个完成的回调,一个具有数据类型json,一个没有

  6. 6

    多个Ajax请求(带有一个回调)

  7. 7

    清理 csv 数据,w/pandas 有没有办法找到第一个可以转换为 # 的 obj 列?

  8. 8

    如何检查以找到两个向量之间没有的第一个对象?

  9. 9

    有没有办法简化功能,一次性检查所有输入框,而不是一个一个

  10. 10

    wordpress,在我的插件名称下为我的插件添加一个设置操作链接

  11. 11

    创建一个promise回调

  12. 12

    尝试设置第一个应用程序,但网站没有打球

  13. 13

    创建一个WordPress主题

  14. 14

    将一个主题的数据放入回调函数中的动态数组中并进行一些计算

  15. 15

    AJAX成功回调仅执行第一个功能

  16. 16

    AJAX成功回调仅执行第一个功能

  17. 17

    需要找到一个分支而没有进入vobs

  18. 18

    回调必须是一个函数。收到null / socket.io /设置间隔

  19. 19

    ReactJS通过props回调设置另一个类的状态

  20. 20

    在函数内部设置一个属性并在 Element get 后回调

  21. 21

    使用另一个类的 unique_ptr 设置回调函数

  22. 22

    在没有所有高级功能的情况下在intelliJ中创建并运行一个简单的Java程序?

  23. 23

    没有回调作为参数的模拟功能

  24. 24

    在android中成功安装另一个应用程序后的回调

  25. 25

    R:找到一个向量中没有出现在另一个向量中的每个元素并将其设置为零

  26. 26

    具有回调功能的驱动程序

  27. 27

    if 语句在函数内部没有找到变量(Wordpress 插件)

  28. 28

    [javascript,jQuery]如何在继续播放另一个没有回调的动画之前等待动画完全完成

  29. 29

    iOS中的iBeacons-从实际的BLE设备没有回调,但是当将另一个iOS设备用作广播器时,didRangeBeacons被调用

热门标签

归档