Changeset 47011
- Timestamp:
- 12/25/2019 06:10:19 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/includes/factory/class-wp-unittest-factory-for-blog.php
r46985 r47011 33 33 public function create_object( $args ) { 34 34 global $wpdb; 35 $meta = isset( $args['meta'] ) ? $args['meta'] : array( 'public' => 1 ); 36 $user_id = isset( $args['user_id'] ) ? $args['user_id'] : get_current_user_id(); 37 // temp tables will trigger db errors when we attempt to reference them as new temp tables 35 36 // Map some arguments for backward compatibility with wpmu_create_blog() previously used here. 37 if ( ! isset( $args['public'] ) ) { 38 // Default to public, unless an options array was provided. 39 $args['public'] = ! isset( $args['meta'] ) ? 1 : 0; 40 } 41 42 if ( ! isset( $args['user_id'] ) ) { 43 $args['user_id'] = get_current_user_id(); 44 } 45 46 if ( isset( $args['site_id'] ) ) { 47 $args['network_id'] = $args['site_id']; 48 unset( $args['site_id'] ); 49 } 50 51 if ( isset( $args['meta'] ) ) { 52 // The `$site_data_whitelist` matches the one used in `wpmu_create_blog()`. 53 $site_data_whitelist = array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ); 54 55 foreach ( $args['meta'] as $key => $value ) { 56 // Promote whitelisted keys to top-level arguments, add others to the options array. 57 if ( in_array( $key, $site_data_whitelist, true ) ) { 58 $args[ $key ] = $value; 59 } else { 60 $args['options'][ $key ] = $value; 61 } 62 } 63 64 unset( $args['meta'] ); 65 } 66 67 // Temporary tables will trigger DB errors when we attempt to reference them as new temporary tables. 38 68 $suppress = $wpdb->suppress_errors(); 39 $blog = wpmu_create_blog( $args['domain'], $args['path'], $args['title'], $user_id, $meta, $args['site_id'] ); 69 70 $blog = wp_insert_site( $args ); 71 40 72 $wpdb->suppress_errors( $suppress ); 41 73
Note: See TracChangeset
for help on using the changeset viewer.