Skip to content

Instantly share code, notes, and snippets.

@infoscigeek
Created March 22, 2017 16:21
Show Gist options
  • Save infoscigeek/1e1d194155d434c99b28485678a78f78 to your computer and use it in GitHub Desktop.
Save infoscigeek/1e1d194155d434c99b28485678a78f78 to your computer and use it in GitHub Desktop.
Disabling a plugin on certain pages using a MU plugin. Author: Kamil Grzegorczyk
<?php
/*
Plugin Name: Cart66 remover
Plugin URI: http://www.lowgravity.pl
Description: Removes cart66 plugin from pages which are not store pages
Author: Kamil Grzegorczyk
Version: 1.0
Author URI: http://www.lowgravity.pl
*/
add_filter( 'option_active_plugins', 'lg_disable_cart66_plugin' );
function lg_disable_cart66_plugin($plugins){
if(strpos($_SERVER['REQUEST_URI'], '/store/') === FALSE AND strpos($_SERVER['REQUEST_URI'], '/wp-admin/') === FALSE) {
$key = array_search( 'cart66/cart66.php' , $plugins );
if ( false !== $key ) {
unset( $plugins[$key] );
}
}
return $plugins;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment