mercredi 16 mars 2016

disable plugin on wordpress fronpage

Im trying to disable a plugin on a wordpress frontpage to make it a bit lighter.

I got this working code where I put in wp-content/mu-plugins/ The only problem is that I cannot make it work for frontpage , only works for subpages

Here is the code :

add_filter( 'option_active_plugins', 'lg_disable_plugin' );
function lg_disable_plugin($plugins){

    if(strpos($_SERVER['REQUEST_URI'], '/subpage/') === FALSE AND strpos($_SERVER['REQUEST_URI'], '/wp-admin/') === FALSE) {

        $key = array_search( 'was-this-helpful-pro/was-this-helpful-pro.php' , $plugins );

        if ( false !== $key ) {
            unset( $plugins[$key] );
        }
    }

    return $plugins;
}

I also found another code which works.... But its the same story , I cannot figure out how to make it work for the frontpage, only subpages works

$listener_term = '/subpage/';
$current_url   = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '';

// listener for the thin load
if ( strstr( $current_url, $listener_term ) ) {
 add_filter( 'option_active_plugins', 'api_request_disable_plugin' );
}
function api_request_disable_plugin( $plugins ) {
 $plugins_not_needed = array(
 'backupwordpress/backupwordpress.php',
 'wordfence/wordfence.php',
 'contact-form-7-to-database-extension/contact-form-7-db.php',
 'contact-form-7/wp-contact-form-7.php',
 'wp-piwik/wp-piwik.php',
 'simple-responsive-slider/simple-responsive-slider.php',
 'google-sitemap-plugin/google-sitemap-plugin.php',
 'category-page-icons/menu-compouser.php',
 'easy-fancybox/easy-fancybox.php',
 'business-owner-switch/business-owner-switch.php',
 'wordpress-seo/wp-seo.php'
 );

 foreach ( $plugins_not_needed as $plugin ) {
 $key = array_search( $plugin, $plugins );
 if ( false !== $key ) {
 unset( $plugins[ $key ] );
 }
 }

 return $plugins;
}

Maybe its not possible ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire