Created
June 1, 2020 15:19
-
-
Save laurelstreng/a0ed49291590a7c97deb2876ac314890 to your computer and use it in GitHub Desktop.
Wordpress mu-plugin to deactivate specific plugins on your local environment if defined in a wp-config-local.php file.
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: Deactivate Plugins Locally | |
Description: Deactivate specific plugins on your local environment if defined in a wp-config-local.php file. | |
Version: 1.0 | |
*/ | |
require_once(ABSPATH . 'wp-admin/includes/plugin.php'); | |
if ( defined( 'LOCAL_DISABLED_PLUGINS' ) ) { // If defined in wp-config-local.php | |
$plugins_to_disable = unserialize( LOCAL_DISABLED_PLUGINS ); | |
if ( ! empty( $plugins_to_disable ) && is_array( $plugins_to_disable ) ) { | |
deactivate_plugins( $plugins_to_disable ); | |
error_log( 'Locally disabled plugins: ' . var_export( $plugins_to_disable, true ) ); | |
} | |
} |
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 | |
// Specify which plugins you want to disable for you local environment | |
define('LOCAL_DISABLED_PLUGINS', serialize([ | |
'autoptimize/autoptimize.php', | |
'redirection/redirection.php', | |
'wp-smush-pro/wp-smush.php' | |
])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment