Last active
July 13, 2017 07:43
-
-
Save trepmal/c5827f45b769103f59142692edf24fc2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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: Dev Plugins | |
*/ | |
add_action( 'muplugins_loaded', function() { | |
// Plugins to activate automatically. | |
$auto_activate = [ | |
'debug-bar/debug-bar.php', | |
'debug-bar-extender/debug-bar-extender.php', | |
'debug-bar-console/debug-bar-console.php', | |
'mail-test/mail-test.php', | |
'rewrite-rules-inspector/rewrite-rules-inspector.php', | |
'abkjfdkkj/abkjfdkkj.php', | |
]; | |
// Remove entries that don't exist to avoid activation warnings. | |
foreach ( $auto_activate as $k => $slug ) { | |
if ( ! file_exists( WP_PLUGIN_DIR . "/$slug" ) ) { | |
unset( $auto_activate[ $k ] ); | |
} | |
} | |
// Force activation. | |
add_filter( 'option_active_plugins', function ( $option ) use ( $auto_activate ) { | |
return array_merge( $option, $auto_activate ); | |
}); | |
// Remove from UI. | |
add_filter( 'all_plugins', function ( $all_plugins ) use ( $auto_activate ) { | |
foreach ( $auto_activate as $k ) { | |
if ( isset( $all_plugins[ $k ] ) ) { | |
unset( $all_plugins[ $k ] ); | |
} | |
} | |
return $all_plugins; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment