Changeset 44805 for trunk/src/wp-includes/ms-site.php
- Timestamp:
- 03/07/2019 03:33:25 AM (7 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/ms-site.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ms-site.php
r44799 r44805 53 53 ); 54 54 55 $prepared_data = wp_prepare_site_data( $data, $defaults ); 56 if ( is_wp_error( $prepared_data ) ) { 57 return $prepared_data; 58 } 59 60 if ( false === $wpdb->insert( $wpdb->blogs, $prepared_data ) ) { 61 return new WP_Error( 'db_insert_error', __( 'Could not insert site into the database.' ), $wpdb->last_error ); 62 } 63 64 $new_site = get_site( $wpdb->insert_id ); 65 66 if ( ! $new_site ) { 67 return new WP_Error( 'get_site_error', __( 'Could not retrieve site data.' ) ); 68 } 69 70 clean_blog_cache( $new_site ); 71 72 /** 73 * Fires once a site has been inserted into the database. 74 * 75 * @since 5.1.0 76 * 77 * @param WP_Site $new_site New site object. 78 */ 79 do_action( 'wp_insert_site', $new_site ); 80 55 81 // Extract the passed arguments that may be relevant for site initialization. 56 82 $args = array_diff_key( $data, $defaults ); … … 59 85 } 60 86 61 $data = wp_prepare_site_data( $data, $defaults );62 if ( is_wp_error( $data ) ) {63 return $data;64 }65 66 if ( false === $wpdb->insert( $wpdb->blogs, $data ) ) {67 return new WP_Error( 'db_insert_error', __( 'Could not insert site into the database.' ), $wpdb->last_error );68 }69 70 $new_site = get_site( $wpdb->insert_id );71 72 if ( ! $new_site ) {73 return new WP_Error( 'get_site_error', __( 'Could not retrieve site data.' ) );74 }75 76 clean_blog_cache( $new_site );77 78 /**79 * Fires once a site has been inserted into the database.80 *81 * @since 5.1.082 *83 * @param WP_Site $new_site New site object.84 */85 do_action( 'wp_insert_site', $new_site );86 87 87 /** 88 88 * Fires when a site's initialization routine should be executed. … … 99 99 $user_id = ! empty( $args['user_id'] ) ? $args['user_id'] : 0; 100 100 $meta = ! empty( $args['options'] ) ? $args['options'] : array(); 101 102 // WPLANG was passed with `$meta` to the `wpmu_new_blog` hook prior to 5.1.0. 103 if ( ! array_key_exists( 'WPLANG', $meta ) ) { 104 $meta['WPLANG'] = get_network_option( $new_site->network_id, 'WPLANG' ); 105 } 106 107 // Rebuild the data expected by the `wpmu_new_blog` hook prior to 5.1.0 using whitelisted keys. 108 // The `$site_data_whitelist` matches the one used in `wpmu_create_blog()`. 109 $site_data_whitelist = array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ); 110 $meta = array_merge( array_intersect_key( $data, array_flip( $site_data_whitelist ) ), $meta ); 101 111 102 112 /**
Note: See TracChangeset
for help on using the changeset viewer.