释放双眼,带上耳机,听听看~!
安装柒比贰主题以后,后台左侧菜单项会有很多,每次需要设置主题需要向下拉到最底下才能找到,及其不方便,决定把菜单搞到顶部导航栏,分层显示,方便修改主题设置。
方法:
1、在子主题functions.php添加代码
/*
* 添加包含多个链接的子菜单
*/
function custom_adminbar_menu( $meta = TRUE ) {
global $wp_admin_bar;
if ( !is_user_logged_in() ) { return; }
if ( !is_super_admin() || !is_admin_bar_showing() ) { return; }
$zms_url = get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=');
$wp_admin_bar->add_menu( array(
'id' => 'custom_menu',
'title' => __( '7b2设置' ) ) /* 设子菜单名 */
);
/* menu links */
$wp_admin_bar->add_menu( array(
'parent' => 'custom_menu',
'id' => 'sub_menu',
'title' => '主题设置', /* 设置链接名 */
'href' => $zms_url. 'zrz_options' /* 设置链接地址 */
/* 'meta' => array( target => '_blank' )*/ )
);
//二级菜单
$wp_admin_bar->add_menu( array(
'parent' => 'sub_menu',
'title' => '基本设置',
'href' => $zms_url. 'zrz_options&tab=home'
)
);
$wp_admin_bar->add_menu( array(
'parent' => 'sub_menu',
'title' => '显示设置',
'href' => $zms_url. 'zrz_options&tab=display'
)
);
$wp_admin_bar->add_menu( array(
'parent' => 'sub_menu',
'title' => '媒体',
'href' => $zms_url. 'zrz_options&tab=media'
)
);
$wp_admin_bar->add_menu( array(
'parent' => 'sub_menu',
'title' => '登录/注册',
'href' => $zms_url. 'zrz_options&tab=social'
)
);
$wp_admin_bar->add_menu( array(
'parent' => 'sub_menu',
'title' => '投稿',
'href' => $zms_url. 'zrz_options&tab=writing'
)
);
$wp_admin_bar->add_menu( array(
'parent' => 'sub_menu',
'title' => '阅读',
'href' => $zms_url. 'zrz_options&tab=reading'
)
);
$wp_admin_bar->add_menu( array(
'parent' => 'sub_menu',
'title' => '导航链接',
'href' => $zms_url. 'zrz_options&tab=links'
)
);
$wp_admin_bar->add_menu( array(
'parent' => 'sub_menu',
'title' => '财富设置',
'href' => $zms_url. 'zrz_options&tab=credit'
)
);
$wp_admin_bar->add_menu( array(
'parent' => 'sub_menu',
'title' => '支付设置',
'href' => $zms_url. 'zrz_options&tab=pay'
)
);
$wp_admin_bar->add_menu( array(
'parent' => 'sub_menu',
'title' => '任务设置',
'href' => $zms_url. 'zrz_options&tab=task'
)
);
$wp_admin_bar->add_menu( array(
'parent' => 'sub_menu',
'title' => '等级制度',
'href' => $zms_url. 'zrz_options&tab=lv'
)
);
$wp_admin_bar->add_menu( array(
'parent' => 'sub_menu',
'title' => '邮件发送',
'href' => $zms_url. 'zrz_options&tab=mail'
)
);
$wp_admin_bar->add_menu( array(
'parent' => 'sub_menu',
'title' => '广告设置',
'href' => $zms_url. 'zrz_options&tab=ads'
)
);
$wp_admin_bar->add_menu( array(
'parent' => 'custom_menu',
'title' => '卡密设置',
'href' => $zms_url. '/wp-admin/admin.php?zrz_options_card'
)
);
$wp_admin_bar->add_menu( array(
'parent' => 'custom_menu',
'title' => '邀请码', /* 设置链接名 */
'href' => $zms_url. '/wp-admin/admin.php?page=zrz_options_invitation'
)
);
}
add_action( 'admin_bar_menu', 'custom_adminbar_menu', 150 );