12% off of LTD using this coupon: TWELVEPERCENTOFF. Promo ends on 2 Dec midnight UTC.
Published on Jun 14, 2022

WPCodeBox in WP Admin Bar

Sridhar Katakam

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.

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-omagnifiercrossmenuchevron-downarrow-right