I've developed a small plugin which empties the $plugin
variable. And put it into the /mu-plugins folder. But it doesn't work.
What am I missing? The plugin is executed.
If I do a print_r on $plugin it contains all the name of the plugins of my Wordpress installation.
The plugin code is:
$uri = $_SERVER['REQUEST_URI'];
if($uri == "/wp-admin/admin-ajax.php")
{
for($i=1; $i < count($plugins); $i++ )
{
{
unset( $plugins[$i] );
}
}
}
return $plugins;
===========
This is the whole code
<?php
class DisablePlugins {
var $namespace = "disable-plugins";
var $version = '1.0.0';
/**
* Instantiation construction
*
* @uses add_filter()
*/
function __construct() {
// Directory path to this plugin's files
$this->dirname = dirname( __FILE__ );
// Rules configurations directory
$this->rules_dirname = $this->dirname . '/' . $this->namespace . '-rules';
$this->siteurl = get_option( 'siteurl' );
$siteurl_http_host = parse_url( $this->siteurl );
$this->siteurl_http_host = $siteurl_http_host['host'];
add_filter( 'option_active_plugins', array( &$this, 'option_active_plugins' ), 1000, 1 );
}
/**
* Initialization function to hook into the WordPress init action
*
* Instantiates the class on a global variable and sets the class, actions
* etc. up for use.
*/
function instance() {
global $DisablePlugins;
$DisablePlugins = new DisablePlugins();
}
/**
* Hook into WordPress option_$option filter
*
* Get processed array of active plugins being loaded for a view to allow filtering
* based off of a user's preferences
*/
function option_active_plugins( $plugins ) {
$rules = $this->load_rules();
$uri = $_SERVER['REQUEST_URI'];
if($uri == "/wp-admin/admin-ajax.php")
{
for($i=1; $i < count($plugins); $i++ )
{
{
unset( $plugins[$i] );
}
}
}
return $plugins;
}
}
// Initiate the DisablePlugins class
DisablePlugins::instance();
$rules = $this->load_rules();
might be halting the script with an undefined function error? Have you checked for PHP errors?instance()
function references a hook to WP's init action but that statement appears to be missing. As it is, this plugin does not appear to actually do anything.option_active_plugins()
to a filter that doesn't exist, in WordPress anyway. Constructor finishes and nothing happens. I think we've found the problem.