Making a plugin only available on the front-end for the logged in super admin

I made a little plugin that enqueues 1 .js file and 1 .css file into a theme’s front-end. All it does it load a grid on top of the theme so I can visualise the design.

If this plugin was activated on a live site, is it possible that only I (the super admin) can see the JS and CSS files included onto the front-end?

Read More

All I have inside the plugin file is this:

function load_grid() {
    wp_enqueue_style('grid_css', plugins_url('/lib/css/grid.css', __FILE__) );
    wp_enqueue_script('grid_js', plugins_url('/lib/js/grid.js', __FILE__), array('jquery') );
}
add_action('wp_enqueue_scripts', 'load_grid');

Related posts

Leave a Reply

2 comments

  1. function load_grid() {
        if ( current_user_can( 'level_10' ) ) {
            wp_enqueue_style('grid_css', plugins_url('/lib/css/grid.css', __FILE__) );
            wp_enqueue_script('grid_js', plugins_url('/lib/js/grid.js', __FILE__), array('jquery') );
        }
    }
    add_action('wp_enqueue_scripts', 'load_grid');