Trigger activation hooks for netork plugins when new site is created. See #14170

git-svn-id: https://develop.svn.wordpress.org/trunk@16021 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
scribu 2010-10-27 19:41:59 +00:00
parent 665b15790d
commit 9c918c6a05
2 changed files with 21 additions and 0 deletions

View File

@ -22,6 +22,7 @@ add_action( 'sanitize_user', 'strtolower' );
// Blogs
add_filter( 'wpmu_validate_blog_signup', 'signup_nonce_check' );
add_action( 'wpmu_new_blog', 'wpmu_activate_network_plugins', 9 );
add_action( 'wpmu_new_blog', 'wpmu_log_new_registrations', 10, 2 );
add_action( 'wpmu_new_blog', 'newblog_notify_siteadmin', 10, 2 );

View File

@ -1224,6 +1224,26 @@ function update_posts_count( $deprecated = '' ) {
update_option( 'post_count', (int) $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->posts} WHERE post_status = 'publish' and post_type = 'post'" ) );
}
/**
* Fires activation hooks for all active network plugins
*
* @since 3.1.0
*
* @param int $blog_id Blog ID
*/
function wpmu_activate_network_plugins( $blog_id ) {
switch_to_blog( $blog_id );
$active_sitewide_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
foreach ( array_keys( $active_sitewide_plugins ) as $plugin ) {
do_action( 'activate_' . $plugin, false );
do_action( 'activate_plugin', $plugin, false );
}
restore_current_blog();
}
function wpmu_log_new_registrations( $blog_id, $user_id ) {
global $wpdb;
$user = new WP_User( (int) $user_id );