我正在使用设置API为插件创建选项。我是否需要验证安全性的输入值(例如stripslashes等)?(我在大多数教程中都找不到这一部分)。下面是我正在做的:
<form method="post" action="options.php">
<?php
settings_fields( \'sandbox_theme_display_options\' );
do_settings_sections( \'sandbox_theme_display_options\' );
submit_button();
?>
</form>
function sandbox_initialize_theme_options() {
add_settings_section(
\'general_settings_section\',
__( \'Display Options\', \'sandbox\' ),
\'sandbox_general_options_callback\',
\'sandbox_theme_display_options\'
);
add_settings_field(
\'show_header\',
__( \'Header\', \'sandbox\' ),
\'sandbox_toggle_header_callback\',
\'sandbox_theme_display_options\',
\'general_settings_section\',
array(
__( \'Activate this setting to display the header.\', \'sandbox\' ),
)
);
register_setting(
\'sandbox_theme_display_options\',
\'sandbox_theme_display_options\'
);
}
add_action( \'admin_init\', \'sandbox_initialize_theme_options\' );