我有一个具有多个选项的主题模块,目前正在为这些选项添加消毒选项。这是我正在使用的代码:
$wp_customize->add_section( \'twsa_feed\' , array(
\'title\' => __( \'RSS Feed settings\',\'rss_feed\'),
\'priority\' => 30,
\'description\' => \'Your RSS feed settings\',
) );
$wp_customize->add_setting( \'short-show-name\' );
$wp_customize->add_control( \'short-show-name\', array (
\'label\' => \'Show name\',
\'description\' => \'Abbreviated show name, not the full name\',
\'section\' => \'twsa_feed\',
\'type\' => \'textbox\',
\'sanitize_callback\' => \'twsa_sanitize_text\',
));
$wp_customize->add_setting( \'show-category\' );
$wp_customize->add_control( \'show-category\', array (
\'label\' => \'Category\',
\'description\' => \'What category does your show belong to? (not really important to stick to certain categories, can make one up)\',
\'section\' => \'twsa_feed\',
\'type\' => \'textbox\',
\'sanitize_callback\' => \'twsa_sanitize_text\',
));
$wp_customize->add_setting( \'author-name\' );
$wp_customize->add_control( \'author-name\', array (
\'label\' => \'Author name\',
\'description\' => \'Must be a name\',
\'section\' => \'twsa_feed\',
\'type\' => \'textbox\',
\'sanitize_callback\' => \'twsa_sanitize_text\',
));
$wp_customize->add_setting( \'author-email\' );
$wp_customize->add_control( \'author-email\', array (
\'label\' => \'Author e-mail\',
\'description\' => \'e-mail address\',
\'section\' => \'twsa_feed\',
\'type\' => \'textbox\',
\'sanitize_callback\' => \'twsa_sanitize_text\',
));
$wp_customize->add_setting( \'itunes-subtitle\' );
$wp_customize->add_control( \'itunes-subtitle\', array (
\'label\' => \'iTunes subtitle\',
\'description\' => \'Short description of show\',
\'section\' => \'twsa_feed\',
\'type\' => \'textbox\',
\'sanitize_callback\' => \'twsa_sanitize_text\',
));
这是我用来清理数据的函数:
function twsa_sanitize_text( $input ) {
return wp_kses_post( force_balance_tags( $input ) );
};
是否可以使用一个函数来清理多个文本字段,还是需要为每个文本字段创建一个函数?
谢谢