Skip to content

Instantly share code, notes, and snippets.

@jodzeee
Last active April 29, 2024 14:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jodzeee/01ffb69417751f4c02bb1818409684d9 to your computer and use it in GitHub Desktop.
Save jodzeee/01ffb69417751f4c02bb1818409684d9 to your computer and use it in GitHub Desktop.
Add frequently used links to main menu of Admin Bar
/** Add frequently used links to main menu of Admin Bar */
if ( ! function_exists( 'x_add_options_item_to_admin_bar' ) ) {
function x_add_options_item_to_admin_bar() {
global $wp_admin_bar;
$wp_admin_bar->add_menu(
array(
'parent' => 'site-name',
'id' => 'x_library',
'title' => __( 'Media Library', 'x' ),
'href' => esc_url( admin_url( 'upload.php' ) ),
'meta' => false
// array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' );
)
);
$wp_admin_bar->add_menu(
array(
'parent' => 'site-name',
'id' => 'x_plugins',
'title' => __( 'Plugins', 'x' ),
'href' => esc_url( admin_url( 'plugins.php' ) ),
'meta' => false
// array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' );
)
);
$wp_admin_bar->add_menu(
array(
'parent' => 'site-name',
'id' => 'x_wpcodebox',
'title' => __( 'WPCodeBox', 'x' ),
'href' => esc_url( admin_url( 'admin.php?page=wpcodebox2' ) ),
'meta' => false
// array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' );
)
);
}
add_action( 'wp_before_admin_bar_render', 'x_add_options_item_to_admin_bar' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment