gpt4 book ai didi

wordpress - 发现一个没有清理回调函数的定制器设置。 WordPress 主题检查插件

转载 作者:行者123 更新时间:2023-12-03 06:42:52 25 4
gpt4 key购买 nike

我已将 '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' );

提前致谢

最佳答案

如果上述问题我有新的解决方案

'sanitize_callback' => 'esc_attr',

然后在主题检查器上检查主题后,我在那里找不到任何错误我希望对某人有所帮助。

关于wordpress - 发现一个没有清理回调函数的定制器设置。 WordPress 主题检查插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27841114/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com