Add WPCodeBox link to admin menu

tdrayson

I use WPCodeBox regularly on my websites and wanted an easy way to quickly access my snippets and scripts that I had written. So I wrote a short script that adds the link to WPCodeBox for admin users only.

PHP

        <?php

add_action( 'admin_bar_menu', function($wp_admin_bar) {
    
    if ( current_user_can( 'manage_options' ) ) {
        $wp_admin_bar->add_node( array(
            'id' => 'wpcodebox',
            'title' => 'WPCodeBox',
            'href' => esc_url( admin_url( 'admin.php?page=wpcb_menu_page_php' ) ),
            'meta' => false
        ));
    }
    
}, 999);
      
Copy

👋🏻 Weekly Tutorial Digest

I send out a weekly newsletter with links to new tutorials written in the last week, you can subscribe below.

Newsletter

🔒I won't send you spam, I promise