您好我是wordpress的新手我正在尝试开发一个wordpress插件但是在添加设置部分时遇到问题我的选项是没有保存到数据库请帮忙。
function rclk_settings_section() {
echo "Check to enable";
}
function rclk_settings_output() {
$status = get_option('rclk_sec');
?>
<label>Enable
<input type='radio' name='rclk_sec' value="1" <?php echo ($status == '1')?'checked': ' '; ?>>
</label>
<label>Disable
<input type='radio' name='rclk_sec' value="0" <?php echo ($status == '0')?'checked': ' '; ?>>
</label>
<?php
}
function disable_rclk_settings_page() {
//create settings
$section_group = "reading"; $section_name = "rclk_sec";
register_setting($sections_group, $section_name); //create section of page
$settings_section = "default"; $page = $section_group; add_settings_section($settings_section, 'Disable Right Click and CTRL+C', "rclk_settings_section", $page);
//create section fields
add_settings_field($section_name, 'Disable Right Click and CTRL+C', 'rclk_settings_output', $page, $settings_section);
}
add_action('admin_init', 'disable_rclk_settings_page');
答案 0 :(得分:1)
检查一下。
function rclk_settings_section() {
echo "Check to enable";
}
function rclk_settings_output() {
$status = get_option('rclk_sec');
?>
<label>Enable
<input type='radio' name='rclk_sec' value="1" <?php echo ($status == '1')?'checked': ' '; ?>>
</label>
<label>Disable
<input type='radio' name='rclk_sec' value="0" <?php echo ($status == '0')?'checked': ' '; ?>>
</label>
<?php
}
function disable_rclk_settings_page() {
//create settings
$section_group = "reading"; $section_name = "rclk_sec";
register_setting($sections_group, $section_name); //create section of page
$settings_section = "default"; $page = $section_group; add_settings_section($settings_section, 'Disable Right Click and CTRL+C', "rclk_settings_section", $page);
//create section fields
add_settings_field($section_name, 'Disable Right Click and CTRL+C', 'rclk_settings_output', $page, $settings_section);
}
add_action('admin_init', 'disable_rclk_settings_page');