首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Wordpress主题选项错误

Wordpress主题选项错误
EN

Stack Overflow用户
提问于 2016-03-27 17:05:22
回答 1查看 72关注 0票数 1

遵循本教程,我正在为wordpress主题制作一个自定义的主题选项页面:http://theme.fm/2011/08/using-the-color-picker-in-your-wordpress-theme-options-2152/

一切都很好,直到我添加了颜色选择器函数和脚本。现在,每次我进入主题选项页面,它都只是一个空白屏幕,上面有一个来自firebug的错误。如图所示。

http://i.stack.imgur.com/bR4P2.png

我删除了颜色选择器的东西,但它仍然在运行。我是javascript和php的新手,所以我不知道这里发生了什么。

这是我的主题选项页面的代码。

代码语言:javascript
复制
function mb_options_admin_menu() {
$page = add_theme_page( 'Theme Options', 'Theme Options', 'edit_theme_options', 'mb_options-theme-options', 'mb_options_theme_options' );
add_action( 'admin_print_styles-' . $page, 'mb_options_admin_scripts' );
}
add_action( 'admin_menu', 'mb_options_admin_menu' );

function mb_options_admin_scripts() {
// We'll put some javascript & css here later
}

function mb_options_theme_options() {
?>
<div class="wrap">
    <div id="icon-themes" class="icon32" ><br></div>
    <h2>My Theme Options</h2>

    <form method="post" action="options.php">
        <?php wp_nonce_field( 'update-options' ); ?>
        <?php settings_fields( 'mb_options-theme-options' ); ?>
        <?php do_settings_sections( 'mb_options-theme-options' ); ?>
        <p class="submit">
            <input name="Submit" type="submit" class="button-primary" value="Save Changes" />
        </p >
    </form>
</div>
<?php
}

function mb_options_admin_init() {
register_setting( 'mb_options-theme-options', 'mb_options-theme-options' );
add_settings_section( 'section_general', 'General Settings', 'mb_options_section_general', 'mb_options-theme-options' );
add_settings_field( 'link_color', 'Link Color', 'mb_options_setting_color', 'mb_options-theme-options', 'section_general' );
add_settings_field( 'link_hover_color', 'Link Hover Color', 'mb_options_hover_setting_color', 'mb_options-theme-options', 'section_general' );
}
add_action( 'admin_init', 'mb_options_admin_init' );

function mb_options_section_general() {
_e( 'The general section description goes here.' );
}

function mb_options_setting_color() {
$options = get_option( 'mb_options-theme-options' );
?>
<input type="text" name="mb_options-theme-options[link_color]" value="<?php echo esc_attr( $options['link_color'] ); ?>" />
<?php
}

function mb_options_hover_setting_color() {
$options = get_option( 'mb_options-theme-options' );
?>
<input type="text" name="mb_options-theme-options[link_hover_color]" value="<?php echo esc_attr( $options['link_hover_color'] ); ?>" />
<?php
}

function mb_options_link_color() {
$options = get_option( 'mb_options-theme-options' );
$link_color = $options['link_color'];
$link_hover_color = $options['link_hover_color'];
echo "<style> a { color: $link_color; } a:hover { color: $link_hover_color; } </style>";
}
add_action( 'wp_enqueue_scripts', 'mb_options_link_color' );

有人能告诉我这里出了什么问题吗?有什么方法可以修复它吗?

EN

回答 1

Stack Overflow用户

发布于 2016-03-28 05:39:15

这个错误似乎是由于我使用的前缀造成的。解决了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36245639

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档