Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: TNG Plugin Remover (tpr)
- Plugin URI: http://www.hcnhistory.org.uk
- Description: Removes some plugins from TNG pages
- Author: Peter Cooper and Kamil Grzegorczyk
- Version: 1.0
- Author URI: http://www.hcnhistory.org.uk
- */
- /*
- * This is based on Cart66 remover from http://lowgravity.pl/blog/quick-tip-how-to-disable-wp-plugin-on-certain-page/
- * (see also https://gist.github.com/markjaquith/1044546 for something similar and better comments)
- *
- * It is needed because TNG and some WordPress plugins (e.g. Tippy) can conflict (e.g. because of multiple jQuery loads)
- * It avoids the conflict by simply preventing listed plugins from being loaded on TNG pages.
- *
- * To adapt this code for your WordPress/TNG integration, TAILOR it where indicated and save in your wp-content\mu-plugins\ folder
- * mu means Must Use - plugins in here are run before everything else - see http://codex.wordpress.org/Must_Use_Plugins
- */
- // This is the code that filters out listed plugins before any are loaded
- add_filter( 'option_active_plugins', 'tpr_disable_some_plugins' );
- function tpr_disable_some_plugins($plugins){
- // Do the disabling only for TNG pages, and make sure that it is not done for admin screens
- // TAILOR by replacing my blank-for-people by the slug of your blank page for TNG
- if(strpos($_SERVER['REQUEST_URI'], '/blank-for-people/') !== FALSE AND strpos($_SERVER['REQUEST_URI'], '/wp-admin/') === FALSE) {
- // TAILOR by repeating the call to tpr_disable for each plugin you want to disable
- // the first argument is the name of the main php file of the plugin relative to the wp-content\plugins\ folder
- // I have included most plugins even though they do not conflict, to reduce load times and possible future conflict
- // although for this snippet I have removed most of them
- tpr_disable( '404-notifier/404-notifier.php', $plugins );
- tpr_disable( 'broken-link-checker/broken-link-checker.php', $plugins );
- }
- return $plugins;
- }
- /**
- * Disable a plugin given as filename (e.g. 'cart66/cart66.php') by removing it from the $plugins array
- * Note the $plugins array argument is handled 'by reference' as it preceded by '&'
- */
- function tpr_disable( $file , &$plugins ) {
- $key = array_search( $file , $plugins );
- if ( false !== $key ) {
- unset( $plugins[$key] );
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement