Last active
March 2, 2022 12:38
-
-
Save musamamasood/f9e3a3ff04e992ce0fc777536df8ffd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Disable Plugin for URl | |
Plugin URI: https://www.glowlogix.com | |
Description: Disable plugins for for specific backend pages. | |
Author: Muhammad Usama M. | |
Version: 1.0.0 | |
*/ | |
add_filter( 'option_active_plugins', 'disable_plugins_per_page' ); | |
function disable_plugins_per_page( $plugin_list ) { | |
// Quit immediately if not post edit area. | |
global $pagenow; | |
if (( $pagenow == 'post.php' || $pagenow == 'edit.php' )) { | |
$disable_plugins = array ( | |
// Plugin Name | |
'hello.php', | |
'developer/developer.php' | |
); | |
$plugins_to_disable = array(); | |
foreach ( $plugin_list as $plugin ) { | |
if ( true == in_array( $plugin, $disable_plugins ) ) { | |
//error_log( "Found $plugin in list of active plugins." ); | |
$plugins_to_disable[] = $plugin; | |
} | |
} | |
// If there are plugins to disable then remove them from the list, | |
// otherwise return the original list. | |
if ( count( $plugins_to_disable ) ) { | |
$new_list = array_diff( $plugin_list, $plugins_to_disable ); | |
return $new_list; | |
} | |
} | |
return $plugin_list; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment