Skip to content

Instantly share code, notes, and snippets.

@anibalardid
Last active July 16, 2019 12:01
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
[carga condicional plugins wp] codigo mio viejo #WordPress #Plugins
<?php
// My post: https://es.wordpress.org/support/topic/tutorial-como-deshabilitar-algunos-plugins-de-algunas-paginas-especificas/
/*
Plugin Name: Plugin Selector
Plugin URI: https://ardid.com.ar
Description: Removes plugins in selected pages
Author: Anibal Ardid
Version: 1.0
Author URI: https://ardid.com.ar
*/
if (!is_admin()) {
add_filter( 'option_active_plugins', 'plugin_selector' );
function plugin_selector($plugins){
if(strpos($_SERVER['REQUEST_URI'], '/search/') === 0) {
// KK Star Ratings
$key = array_search( 'kk-star-ratings/index.php', $plugins );
if ( false !== $key ) { unset( $plugins[$key] ); }
// Shareaholic
$key = array_search( 'shareaholic/shareaholic.php', $plugins );
if ( false !== $key ) { unset( $plugins[$key] ); }
// Genesis Responsive Slider
$key = array_search( 'genesis-responsive-slider/genesis-responsive-slider.php', $plugins );
if ( false !== $key ) { unset( $plugins[$key] ); }
// Contextual Related Posts
$key = array_search( 'contextual-related-posts/contextual-related-posts.php', $plugins );
if ( false !== $key ) { unset( $plugins[$key] ); }
} elseif($_SERVER['REQUEST_URI'] === '/' || $_SERVER['REQUEST_URI'] === '') {
// KK Star Ratings
$key = array_search( 'kk-star-ratings/index.php', $plugins );
if ( false !== $key ) { unset( $plugins[$key] ); }
// Shareaholic
$key = array_search( 'shareaholic/shareaholic.php', $plugins );
if ( false !== $key ) { unset( $plugins[$key] ); }
}
return $plugins;
}
}
@ioniacob
Copy link

Thanks, its work good.

@anibalardid
Copy link
Author

Thanks, its work good.

your welcome ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment