在“外观”页面中的活动主题下添加链接
问题描述:
在主题选择页面中,链接显示在显示其功能的活动主题下方。大多数时间这些是小工具,菜单和一个主题选项如果您运行add_theme_page()
链接。在“外观”页面中的活动主题下添加链接
自从我创建了自己的顶级菜单,并没有使用add_theme_page(),我的路径重定向到admin.php?page=chosen-slug
而不是themes.php?page=chosen-slug
并没有主题选项在外观部分的链接。有没有一种方法可以显示该链接以显示我的主题有选项?
答
我想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();
});