0

テーマ選択ページでは、アクティブなテーマの下にその機能を示すリンクが表示されます。ほとんどの場合、これらはウィジェットメニュー、およびを実行した場合のテーマオプションadd_theme_page()リンクです。

独自のトップレベルメニューを作成し、add_theme_page()を使用しなかったため、パスはadmin.php?page=chosen-slug代わりにリダイレクトされ、[外観]セクションに[テーマオプション]リンクthemes.php?page=chosen-slugがありません。そのリンクを表示して、テーマにオプションがあることを示す方法はありますか?

4

1 に答える 1

0

今のところ、jQuery ソリューションが必要になると思います。それは私の最初の選択ではありませんが、少なくとも機能します。

PHP:

// Create the theme options link
add_action("admin_menu", "setup_theme_admin_menus"); 
function setup_theme_admin_menus(){
    add_theme_page('', 'Theme Options', 'manage_options', 'sample-slug', '');
}

jQuery:

// Redirect link in Appearance to your top-level menu
$('#current-theme div.theme-options a[href="themes.php?page=sample-slug"]').attr('href', 'admin.php?page=sample-slug');

/*
 * Hide the link created by add_theme_page(). Use each() since our <li> has no
 * name and this makes sure the script always works even if its position changes.
 */
$('#menu-appearance a[href="themes.php?page=sample-slug"]').each(function(){
    $(this).parent().hide();
});
于 2012-05-03T16:12:36.500 に答える