Last active
October 9, 2015 05:28
-
-
Save wokamoto/3445482 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: Just do it ! | |
Plugin URI: | |
Description: | |
Version: 0.1 | |
Author: | |
Author URI: | |
*/ | |
new just_do_it(); | |
class just_do_it { | |
private $must_plugins = array( | |
'WP Multibyte Patch' => 'wp-multibyte-patch/wp-multibyte-patch.php', | |
); | |
function __construct() { | |
add_action('shutdown', array($this, 'plugins_loaded')); | |
} | |
public function plugins_loaded() { | |
$activePlugins = get_option('active_plugins'); | |
foreach ($this->must_plugins as $key => $plugin) { | |
if ( !array_search($plugin, $activePlugins) ) { | |
activate_plugin( $plugin, '', $this->is_multisite() ); | |
} | |
} | |
} | |
private function is_multisite() { | |
return function_exists('is_multisite') && is_multisite(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
WordPress がマルチサイトインストールされている場合、プラグインはネットワークで有効になります。
そこだけ、注意してください。