WPCodeBox in WP Admin Bar

WPCodeBox is a fantastic WordPress code snippets plugin that I have fully embraced/switched to – mainly for its cloud feature.

DEAL ALERT

Here’s a 25% discount coupon on WPCodeBox: WPDevDesign

The plugin adds a menu item in the left sidebar in WP admin by default.

It has a built-in option to move it under the Tools menu.

Several users find it convenient to add a quick link to it in the WP admin toolbar for quick access – like this:

Here’s the snippet to do just that:

<?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=wpcb_menu_page_php' ),
			)
		);
	}
}, 999 );

Clicking on it will take us to:

https://example.com/wp-admin/admin.php?page=wpcb_menu_page_php

Facebook discussion.


Posted

in

,

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *