Wordpress主题选项错误

时间:2016-03-27 09:05:22

标签: javascript php jquery wordpress

我在本教程之后为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的新手,所以我不知道这里发生了什么。

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

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' );

有人可以告诉我这里出了什么问题以及解决问题的方法吗?

1 个答案:

答案 0 :(得分:0)

似乎错误是由于我使用的前缀。解决。

相关问题