Skip to content

Instantly share code, notes, and snippets.

@anibalardid
Last active July 16, 2019 12:01
Show Gist options
  • Select an option

  • Save anibalardid/5f20826b2edb81c832fddbe4f31f23f6 to your computer and use it in GitHub Desktop.

Select an option

Save anibalardid/5f20826b2edb81c832fddbe4f31f23f6 to your computer and use it in GitHub Desktop.

Revisions

  1. anibalardid revised this gist Apr 10, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions selector.php
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    <?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
  2. anibalardid revised this gist Feb 27, 2019. No changes.
  3. anibalardid revised this gist Feb 27, 2019. No changes.
  4. anibalardid created this gist Feb 27, 2019.
    47 changes: 47 additions & 0 deletions selector.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    <?php
    /*
    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;
    }
    }