$_GET[‘UPDATED’]在WordPress 3.1中不起作用吗?

时间:2011-01-22 作者:janoChen

我在Wordpress 3.1中尝试了Satoshi主题,当主题选项被保存时,它们确实会被保存,但“Satoshi选项被保存”不显示消息。(消息显示在Wordpress 3.0.4中)。

functions.php:

/* -- Theme Options Page -- */
function theme_options_admin() {
    $option_fields = array();
    if ( $_GET[\'updated\'] ) echo \'<div id="message" class="updated fade"><p>Satoshi Options Saved.</p></div>\';
    echo \'<link rel="stylesheet" href="\'.get_bloginfo(\'template_url\').\'/styles/functions.css" />\';
?>

<div class="wrap">

    <h2>Satoshi Options</h2>

    <div id="message"></div>

    <div class="metabox-holder">

        <form method="post" action="options.php">
            <?php wp_nonce_field(\'update-options\'); ?>

            <div id="theme-options">

                <div id="left-column">
                    <?php
                        include("options/custom-logo.php");
                        include("options/custom-intro.php");
                        include("options/frontpage-headline.php");
                        include("options/featured-project.php");
                    ?>
                </div><!--end left-column-->
                <div id="right-column">
                    <?php
                        include("options/contact-details.php");
                        include("options/footer-text.php");
                        include("options/google-analytics.php");
                    ?>
                </div><!--end right-column-->

            </div><!--theme-options-->

            <input type="hidden" name="action" value="update" />
            <input type="hidden" name="page_options" value="<?php echo implode(",", $option_fields); ?>" />

        </form>
    </div><!--end metabox-holder-->
</div><!--end wrap-->
<?php
}
add_action(\'admin_menu\', "theme_options_admin_init");
function theme_options_admin_init()
{
    add_theme_page( "Satoshi Theme Options", "Theme Options", 8, __FILE__, \'theme_options_admin\');
}

1 个回复
最合适的回答,由SO网友:t31os 整理而成

这一行是错误的,我甚至无法在不更改主题选项页面的情况下将其打开。。

add_theme_page( "Satoshi Theme Options", "Theme Options", 8, __FILE__, \'theme_options_admin\');
将其更新为。。

add_theme_page( "Satoshi Theme Options", "Theme Options", 8, \'satoshi-theme-options\', \'theme_options_admin\');
保存选项确实按预期生成了更新的消息。

UPDATE: 看起来像$_GET 执行设置更新时,3.1中的键已更改

更新以下行

if ( $_GET[\'updated\'] ) echo \'<div id="message" class="updated fade"><p>Satoshi Options Saved.</p></div>\';

if ( $_GET[\'settings-updated\'] ) echo \'<div id="message" class="updated fade"><p>Satoshi Options Saved.</p></div>\';
保存时,您现在将看到更新的消息

结束