Skip to content

Instantly share code, notes, and snippets.

@jb510
Created February 29, 2024 16:34
Show Gist options
  • Save jb510/fb02c57e4456b515f4eb74e13aa458c0 to your computer and use it in GitHub Desktop.
Save jb510/fb02c57e4456b515f4eb74e13aa458c0 to your computer and use it in GitHub Desktop.
Add Plugins menu item to top level admin bar in WordPress
<?php
/**
* Customize admin bar items
*
* @since 1.0
* @author Jon Brown
* @global array $wp_admin_bar
*/
function s9_customize_admin_bar_items() {
global $wp_admin_bar;
if ( current_user_can( 'activate_plugins' ) ) {
$wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'plugins', 'title' => __( 'Plugins' ), 'href' => admin_url( 'plugins.php' ) ) ); }
}
add_action( 'wp_before_admin_bar_render', 's9_customize_admin_bar_items' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment