Created
February 5, 2016 13:19
-
-
Save rakesh-mohanta/38953a09a080b7acec83 to your computer and use it in GitHub Desktop.
Revisions
-
d13r revised this gist
Aug 23, 2014 . 1 changed file with 2 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -24,19 +24,17 @@ function djm_activate_plugin($plugin, $buffer = false) { $current = get_option('active_plugins', array()); if (!in_array($plugin, $current)) { if ($buffer) ob_start(); include_once(WP_PLUGIN_DIR . '/' . $plugin); do_action('activate_plugin', $plugin); do_action('activate_' . $plugin); $current[] = $plugin; sort($current); update_option('active_plugins', $current); do_action('activated_plugin', $plugin); if ($buffer) ob_end_clean(); } } -
d13r revised this gist
Aug 19, 2014 . 2 changed files with 19 additions and 10 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +0,0 @@ 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,21 @@ <?php // There are three options (that I know of) for automatically enabling a plugin // in new sites. // 1. Move the plugin from wp-content/plugins/ to wp-content/mu-plugins/ (MU = // Must Use). But then it cannot be deactivated for any site. // 2. Click "Network Activate" instead of "Activate" to enable it for all sites. // I didn't want to use this though because I didn't want to affect existing // sites. Also I couldn't work out how to deactivate it for some sites (although // I've read this should be possible). // 3. Add the following to wp-content/mu-plugins/ to activate the plugin at // creation time. This way it only affects new blogs, can be deactivated easily, // and I can also set the default configuration at the same time. // Helper to activate a plugin on another site without causing a fatal error by // including the plugin file a second time // Based on activate_plugin() in wp-admin/includes/plugin.php @@ -28,16 +44,16 @@ function djm_activate_plugin($plugin, $buffer = false) function djm_wpmu_new_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { switch_to_blog($blog_id); // Activate All in One SEO Pack djm_activate_plugin('all-in-one-seo-pack/all_in_one_seo_pack.php', true); // Configure All in One SEO Pack $options = get_option('aioseop_options', array()); $options['aiosp_enabled'] = '1'; $options['aiosp_paged_format'] = ' - Page %page%'; $options['aiosp_cap_cats'] = '0'; update_option('aioseop_options', $options); restore_current_blog(); } -
d13r created this gist
Mar 3, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ There are three options (that I know of) for automatically enabling a plugin in new sites. 1. Move the plugin from `wp-content/plugins/` to `wp-content/mu-plugins/` (MU = Must Use). But then it cannot be deactivated for any site. 2. Click *Network Activate* instead of *Activate* to enable it for all sites. I didn't want to use this though because I didn't want to affect existing sites. Also I couldn't work out how to deactivate it for some sites (although I've read this should be possible). 3. Write a plugin (in `wp-content/mu-plugins/`) with a hook that activates the plugin at creation time. This way it only affects new blogs, can be deactivated easily, and I can also set the default configuration at the same time. 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ <?php // Helper to activate a plugin on another site without causing a fatal error by // including the plugin file a second time // Based on activate_plugin() in wp-admin/includes/plugin.php // $buffer option is used for All in One SEO Pack, which sends output otherwise function djm_activate_plugin($plugin, $buffer = false) { $current = get_option('active_plugins', array()); if (!in_array($plugin, $current)) { if ($buffer) { ob_start(); } include_once(WP_PLUGIN_DIR . '/' . $plugin); do_action('activate_plugin', $plugin); do_action('activate_' . $plugin); $current[] = $plugin; sort($current); update_option('active_plugins', $current); do_action('activated_plugin', $plugin); if ($buffer) { ob_end_clean(); } } } add_action('wpmu_new_blog', 'djm_wpmu_new_blog', 12, 6); // includes/ms-functions.php function djm_wpmu_new_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { switch_to_blog($blog_id); // Activate All in One SEO Pack djm_activate_plugin('all-in-one-seo-pack/all_in_one_seo_pack.php', true); // Configure All in One SEO Pack $options = get_option('aioseop_options', array()); $options['aiosp_enabled'] = '1'; $options['aiosp_paged_format'] = ' - Page %page%'; $options['aiosp_cap_cats'] = '0'; update_option('aioseop_options', $options); restore_current_blog(); }