不要注释掉验证代码请记住,您正在使用它来验证数据,因此它现在不返回任何内容,也不保存任何内容,请尝试以下操作:
add_action(\'admin_bar_menu\', \'make_parent_node\', 999);
function make_parent_node($wp_admin_bar) {
$args = array(
\'id\' => \'test1234\', // id of the existing child node (New > Post)
\'title\' => \'test\', // alter the title of existing node
\'parent\' => \'new-content\', // set parent to false to make it a top level (parent) node
\'href\' => admin_url(\'admin.php?page=enter_timesheet\')
);
$wp_admin_bar->add_node($args);
}
add_action(\'admin_menu\', \'test_plugin_setup_menu\');
function test_plugin_setup_menu() { /**/
add_submenu_page(\'options-general.php\', \'Forhandler options side\', \'Forhandler Options\', \'manage_options\', \'mine-første-options\', \'test_init\');
}
/**/
function test_init() { /**/
//echo "<h1>Hello World!</h1>";
?>
<div>
<h1>Codehero Dealers</h1>
<form action="options.php" method="post">
<?php settings_fields(\'mine_plugin_options\'); ?>
<?php do_settings_sections(\'mine-første-options\'); ?>
<input name="Submit" type="submit" value="<?php esc_attr_e(\'Save Changes\'); ?>" />
</form>
</div>
<?php
}
function mine_plugin_section_text() {
echo \'<p>Her finder du indstillinger til forhandler delen.</p>\';
}
// add the admin settings and such
add_action(\'admin_init\', \'mine_plugin_admin_init\');
function mine_plugin_admin_init() {
register_setting(\'mine_plugin_options\', \'mine_plugin_options\', \'mine_plugin_options_validate\');
add_settings_section(\'mine_plugin_main\', \'Main Settings\', \'mine_plugin_section_text\', \'mine-første-options\');
add_settings_field(\'mine_plugin_checkbox\', \'Forhandler checkout indstilling\', \'mine_plugin_setting_string\', \'mine-første-options\', \'mine_plugin_main\');
}
function mine_plugin_setting_string() {
$options = get_option(\'mine_plugin_options\');
echo "<input id=\'mine_plugin_checkbox\' name=\'mine_plugin_options[checkbox]\' type=\'checkbox\' value=\'1\'" . checked( 1, $options[\'checkbox\'], false ) . " />";
}
// validate our options
function mine_plugin_options_validate($input) {
$newinput[\'checkbox\'] = trim($input[\'checkbox\']);
return $newinput;
}
我们可以使用WordPress,而不是读取选项、设置条件并检查是否存在值
checked
作用