2
votes

Does anybody know how to disable certain plugins from loading in the back-end/admin area of Wordpress?

Currently I'm running a site that has many plugins mainly geared towards front-end manipulation yet when I access pages in the backend (ie. /wp-admin/edit.php) all CSS, JS and plugin files are being loaded for plugins that are not required there, thus increasing the load-time and responsiveness of the admin area.

I'm looking for a solution, either plugin based for code that can selectively load admin only plugins, ideally without having to hack the core files.

I'm using wordpress 3.5.1.

1

1 Answers

5
votes

Checkout Plugin Organizer. I haven't used it but according to it's description, you can "Selectively disable plugins by any post type or wordpress managed URL". I would guess that you could disable certain plugins from running on urls that contain /wp-admin/.

You can also modify the plugins themselves. It depends how they are written, but you can find where they are enqueuing the css and js files and wrap those in an is_admin() statement like this:

// Make sure we aren't in the admin area
if ( !is_admin() ) {
    wp_enqueue_script('plugin-script');
    wp_enqueue_style('plugin-style');
}

That will ensure that the scripts/styles are only loaded on the front end.

Another possibility is to find all of the css and script files that are being loaded via plugins and deregister them in your functions.php file. This will require you to poke around the plugins a bit to find the handles of all the files, but it should work well. This would deregister some of the default stuff enqueued in the admin area, so you can see what I mean.

add_action( 'admin_init', 'remove_admin_styles' );

function remove_admin_styles() {
    wp_deregister_style(
        'wp-admin',
        'ie',
        'colors',
        'colors-fresh',
        'colors-classic',
        'media',
        'install',
        'thickbox'
    );
}

As you said, you don't want to mess with core files, but if you absolutely need to you can implement the solution described in this article. As I'm sure you know, it's not a good idea to alter WordPress core files unless you absolutely have to. Just keep in mind that the changes will be wiped out if you upgrade WordPress in the future.