13

How to Add WPCodeBox to Your WordPress Admin Bar Menu

Powered by WPCodeBox

Move WPCodeBox menu to the top bar for easy access in WordPress.


<?php

add_filter( 'admin_bar_menu', function( $wp_admin_bar ) {
	if ( current_user_can( 'manage_options' ) && is_admin_bar_showing() ) {
		$iconhtml = sprintf( '<span class="wpcb ab-icon"><img src="%s" style="height: 16px;" /></span>', WP_PLUGIN_URL . '/wpcodebox/logo.svg' );

		$wp_admin_bar->add_node(
			array(
				'id'    => 'wpcodebox_adminbar',
				'title' => $iconhtml . '<span class="wpcb ab-label">' . __( 'WPCodeBox', 'wpcodebox' ) . '</span>',
				'href'  => admin_url( 'admin.php?page=wpcodebox2' ),
			)
		);
	}
}, 999 );

Other Snippets

WPCodeBox is a WordPress Code Snippets Manager that allows you to share your WordPress Code Snippets across your sites.