我知道之前已经问过这个问题,为什么我的代码没有保存,但是这个教程最近是由用户在这里推荐的,而且我一直在关注它,(显然改变变量和选项以适应我的需要),但由于某种原因,设置保存的小栏会出现,保存按钮出现,表单本身,它看起来都正确,但是当我点击保存时,它从表单中消失了。请记住,我只尝试保存第一个选项的设置,即网站徽标网址。这是我的代码,它正确地包含在functions.php文件中。
PS:很抱歉这一切都在一起,PHP和HTML,但这是在一篇文章中将所有内容整合在一起的唯一方法,而且,我喜欢在完成后将内容放在单独的文件中。
<?php
if (!current_user_can('manage_options')) {
wp_die('You do not have permission to view this page, if you believe that this is a mistake, please contact your system administrator, or try closing the tab and come back.');
}
add_action("admin_menu", "setup_where_now_admin_menus");
function setup_where_now_admin_menus() {
add_menu_page('Front Door Theme Options', 'Front Door Theme Options', 'manage_options', 'where_now_elements', 'where_now_options') ;
}
?>
<?php
function where_now_options() { ?>
<div class="wrap">
<h2>Front Door Web Design Custom Theme Options</h2>
<form method="post" action="">
<h4>Site Logo URL</h4>
<p>Remember, this is the image used in places like your header, or anywhere else you want your logo to appear, and if you are having trouble remembering how to use this feature, you can always upload your new logo to the media section in Wordpress, get the URL from the specific images page, and then paste it here!</p>
<input type="text" name="site_logo" value="<?php echo $site_logo;?>" size="25">
<h4>Analytics Tracking Code</h4>
<p>Any code used for tracking purposes that is placed in the header goes here</p>
<input type="text" name="analytics_code">
<?php
$site_logo = get_option("where_now_site_logo");
if (isset($_POST["update_settings"])) {
$site_logo = esc_attr($_POST["site_logo"]);
update_option("where_now_site_logo", $site_logo);
?>
<div id="message" class="updated">Your Changes Have Been Saved</div>
<?php
}
?>
<input type="hidden" name="update_settings" value="Y" />
<input type="submit" value="Save settings" class="button-primary"/>
</form>
</div>
<?php
}
?>
有什么想法吗?