首页 > 解决方案 > Wordpress 在管理栏中添加快捷方式链接以启用/禁用插件

问题描述

我想添加一个链接以在管理栏中启用和禁用插件。
在代码下面,我想知道它是否是正确的方法。谢谢你

function custom_admin_bar_link( $admin_bar ) {
    $admin_bar->add_menu( array(
    'id'    => 'wp-custom-link',
    'title' => 'Custom Item',
    'href'  => '',
    'meta'  => array(
             'title' => __('Custom'),
    ),
    ));

    $admin_bar->add_menu( array(
    'id'    => 'disable-link',
    'parent'=> 'wp-custom-link',
    'title' => 'Disable Amazon',
    'href'  => 'https://mydisablelink.com/',
    'meta'  => array(
             'title' => __('Disable Amazon'),
    ),
    ));

    $admin_bar->add_menu( array(
    'id'    => 'unable-link',
    'parent'=> 'wp-custom-link',
    'title' => 'Enable Amazon',
    'href'  => 'https://mydisablelink.com/',
    'meta'  => array(
       'title' => __('Enable Amazon'),
    ),
    ));
}

add_action( 'admin_bar_menu', 'custom_admin_bar_link', 100 );

标签: wordpress

解决方案


推荐阅读