WordPress admin_bar的开发

新增

示例如下:

图片[1]-WordPress admin_bar的开发 - KEKC博客-KEKC博客

代码如下:

//添加admin_bar
function add_anticode_admin_bar_item($wp_admin_bar) {
    $args = array(
        'id'    => 'anticode_admin_bar_item',
        'title' => '防伪码',
        'href'  => admin_url('admin.php?page=fwmpage'),
        'meta'  => array(
            'class' => 'anticode-admin-bar-item',
        ),
    );
    $wp_admin_bar->add_node($args);
    
	$wp_admin_bar->add_menu(
		array(
			'parent' => "anticode_admin_bar_item",
			'title'  => '防伪码列表',
			'id'     => 'fwmpage',
			'href'   => admin_url( 'admin.php?page=fwmpage' ),

		)
	);
	$wp_admin_bar->add_menu(
		array(
			'parent' => "anticode_admin_bar_item",
			'title'  => '插件设置',
			'id'     => 'anticode_option',
			'href'   => admin_url( 'admin.php?page=anticode_option' ),

		)
	);
	$wp_admin_bar->add_menu(
		array(
			'parent' => "anticode_admin_bar_item",
			'title'  => '页面模板',
			'id'     => 'anti_templates',
			'href'   => admin_url( 'edit.php?post_type=anti_templates' ),

		)
	);
}
add_action('admin_bar_menu', 'add_anticode_admin_bar_item',999);

© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享