Changeset 12606
- Timestamp:
- 03/31/2020 02:45:13 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-blogs/bp-blogs-cache.php
r12173 r12606 54 54 // List actions to clear object caches on. 55 55 add_action( 'bp_blogs_remove_blog_for_user', 'bp_blogs_clear_blog_object_cache', 10, 2 ); 56 add_action( ' wpmu_new_blog','bp_blogs_clear_blog_object_cache', 10, 2 );56 add_action( 'bp_insert_site', 'bp_blogs_clear_blog_object_cache', 10, 2 ); 57 57 add_action( 'bp_blogs_remove_blog', 'bp_blogs_clear_blog_object_cache' ); 58 58 -
trunk/src/bp-blogs/bp-blogs-functions.php
r12605 r12606 412 412 do_action_ref_array( 'bp_blogs_new_blog', array( &$recorded_blog, $is_private, $is_recorded, $no_activity ) ); 413 413 } 414 add_action( ' wpmu_new_blog', 'bp_blogs_record_blog', 10, 2 );414 add_action( 'bp_insert_site', 'bp_blogs_record_blog', 10, 2 ); 415 415 416 416 /** … … 995 995 do_action( 'bp_blogs_remove_blog', $blog_id ); 996 996 } 997 add_action( ' delete_blog', 'bp_blogs_remove_blog' );997 add_action( 'bp_delete_site', 'bp_blogs_remove_blog' ); 998 998 999 999 /** … … 1219 1219 do_action( 'bp_blogs_remove_data_for_blog', $blog_id ); 1220 1220 } 1221 add_action( ' delete_blog', 'bp_blogs_remove_data_for_blog', 1 );1221 add_action( 'bp_delete_site', 'bp_blogs_remove_data_for_blog', 1 ); 1222 1222 1223 1223 /** -
trunk/src/bp-core/admin/bp-core-admin-actions.php
r10825 r12606 47 47 add_action( 'custom_menu_order', 'bp_admin_custom_menu_order' ); 48 48 add_action( 'menu_order', 'bp_admin_menu_order' ); 49 add_action( ' wpmu_new_blog','bp_new_site', 10, 6 );49 add_action( 'bp_insert_site', 'bp_new_site', 10, 6 ); 50 50 51 51 // Hook on to admin_init. -
trunk/src/bp-core/bp-core-wpabstraction.php
r11447 r12606 308 308 } 309 309 } 310 311 /** 312 * Returns the name of the hook to use once a WordPress Site is inserted into the Database. 313 * 314 * WordPress 5.1.0 deprecated the `wpmu_new_blog` action. As BuddyPress is supporting WordPress back 315 * to 4.8.0, this function makes sure we are using the new hook `wp_initialize_site` when the current 316 * WordPress version is upper or equal to 5.1.0 and that we keep on using `wpmu_new_blog` for earlier 317 * versions of WordPress. 318 * 319 * @since 6.0.0 320 * 321 * @return string The name of the hook to use. 322 */ 323 function bp_insert_site_hook() { 324 $wp_hook = 'wpmu_new_blog'; 325 326 if ( function_exists( 'wp_insert_site' ) ) { 327 $wp_hook = 'wp_initialize_site'; 328 } 329 330 return $wp_hook; 331 } 332 333 /** 334 * Catch the new site data for a later use. 335 * 336 * @since 6.0.0 337 */ 338 function bp_catch_site_data( $errors = null, $data = array() ) { 339 buddypress()->new_site_data = $data; 340 } 341 add_action( 'wp_validate_site_data', 'bp_catch_site_data', 10, 2 ); 342 343 /** 344 * Fires a BuddyPress hook when a new WordPress site is inserted into the database. 345 * 346 * This hook makes sure BuddyPress is back compatible with WordPress versions < 5.1.0. 347 * 348 * @since 6.0.0 349 * 350 * @param int|WP_Site $site The Site ID or the WP Site object. 351 * @param int|array $args_or_user_id An array of Site arguments or the User ID. 352 * @param string $domain Site domain. 353 * @param string $path Site path. 354 * @param int $network_id Network ID. Only relevant on multi-network installations. 355 * @param array $meta Meta data. Used to set initial site options. 356 */ 357 function bp_insert_site( $site, $args_or_user_id = null, $domain = '', $path = '', $network_id = 0, $meta = array() ) { 358 if ( $site instanceof WP_Site ) { 359 $bp = buddypress(); 360 $site_id = $site->id; 361 $domain = $site->domain; 362 $path = $site->path; 363 $network_id = $site->network_id; 364 $args = (array) $args_or_user_id; 365 366 $user_id = 0; 367 if ( isset( $args['user_id'] ) && $args['user_id'] ) { 368 $user_id = (int) $args['user_id']; 369 } 370 371 $meta = array(); 372 if ( isset( $args['options'] ) && $args['options'] ) { 373 $meta = (array) $args['options']; 374 375 if ( ! array_key_exists( 'WPLANG', $meta ) ) { 376 $meta['WPLANG'] = get_network_option( $site->network_id, 'WPLANG' ); 377 } 378 379 if ( isset( $bp->new_site_data ) ) { 380 $meta = array_merge( $bp->new_site_data, $meta ); 381 } 382 } 383 } else { 384 $site_id = $site; 385 $user_id = (int) $args_or_user_id; 386 } 387 388 /** 389 * Fires when a new WordPress site has been inserted into the database. 390 * 391 * @since 6.0.0 392 * 393 * @param int $site_id Site ID. 394 * @param int $user_id User ID. 395 * @param string $domain Site domain. 396 * @param string $path Site path. 397 * @param int $network_id Network ID. Only relevant on multi-network installations. 398 * @param array $meta Meta data. Used to set initial site options. 399 */ 400 do_action( 'bp_insert_site', $site_id, $user_id, $domain, $path, $network_id, $meta ); 401 } 402 add_action( bp_insert_site_hook(), 'bp_insert_site' ); 403 404 /** 405 * Returns the name of the hook to use once a WordPress Site is deleted. 406 * 407 * WordPress 5.1.0 deprecated the `delete_blog` action. As BuddyPress is supporting WordPress back 408 * to 4.8.0, this function makes sure we are using the new hook `wp_validate_site_deletion` when the 409 * current WordPress version is upper or equal to 5.1.0 and that we keep on using `delete_blog` for 410 * earlier versions of WordPress. 411 * 412 * @since 6.0.0 413 * 414 * @return string The name of the hook to use. 415 */ 416 function bp_delete_site_hook() { 417 $wp_hook = 'delete_blog'; 418 419 if ( function_exists( 'wp_delete_site' ) ) { 420 $wp_hook = 'wp_validate_site_deletion'; 421 } 422 423 return $wp_hook; 424 } 425 426 /** 427 * Makes sure the `bp_delete_site` hook is fired if site's deletion 428 * was performed without dropping tables. 429 * 430 * @since 6.0.0 431 * 432 * @param WP_Site $site The site object. 433 */ 434 function bp_delete_site_no_tables_drop( $site ) { 435 if ( isset( $site->deleted ) && 1 === (int) $site->deleted ) { 436 return bp_delete_site( $site->id, false ); 437 } 438 } 439 add_action( 'wp_update_site', 'bp_delete_site_no_tables_drop', 10, 1 ); 440 441 /** 442 * Fires a BuddyPress hook when a new WordPress site is deleted. 443 * 444 * This hook makes sure BuddyPress is back compatible with WordPress versions < 5.1.0. 445 * 446 * @since 6.0.0 447 * 448 * @param int|WP_Error $site_id_or_error A WP Error object or the site ID. 449 * @param bool|WP_Site $drop_or_site A WP Site object or a boolean to inform whether site's table should be dropped. 450 */ 451 function bp_delete_site( $site_id_or_error, $drop_or_site = false ) { 452 if ( $drop_or_site instanceof WP_Site ) { 453 if ( ! empty( $site_id_or_error->errors ) ) { 454 return; 455 } 456 457 $site_id = (int) $drop_or_site->id; 458 $drop = true; 459 } else { 460 $site_id = (int) $site_id_or_error; 461 $drop = (bool) $drop_or_site; 462 } 463 464 /** 465 * Fires when a WordPress site is deleted. 466 * 467 * @since 6.0.0 468 * 469 * @param int $site_id The site ID. 470 * @param bool $drop True if site's table should be dropped. Default is false. 471 */ 472 do_action( 'bp_delete_site', $site_id, $drop ); 473 } 474 add_action( bp_delete_site_hook(), 'bp_delete_site', 10, 2 ); -
trunk/tests/phpunit/testcases/activity/functions.php
r12605 r12606 856 856 } 857 857 858 if ( function_exists( 'wp_initialize_site' ) ) {859 $this->setExpectedDeprecated( 'wpmu_new_blog' );860 }861 862 858 $b = self::factory()->blog->create(); 863 859 $u = self::factory()->user->create(); … … 972 968 } 973 969 974 if ( function_exists( 'wp_initialize_site' ) ) {975 $this->setExpectedDeprecated( 'wpmu_new_blog' );976 }977 978 970 $b = self::factory()->blog->create(); 979 971 $u = self::factory()->user->create(); … … 1107 1099 public function test_bp_activity_format_activity_action_custom_post_type_comment() { 1108 1100 if ( is_multisite() ) { 1109 if ( function_exists( 'wp_initialize_site' ) ) {1110 $this->setExpectedDeprecated( 'wpmu_new_blog' );1111 }1112 1113 1101 $b = self::factory()->blog->create(); 1114 1102 switch_to_blog( $b ); -
trunk/tests/phpunit/testcases/blogs/activity.php
r12395 r12606 34 34 } 35 35 36 if ( function_exists( 'wp_initialize_site' ) ) {37 $this->setExpectedDeprecated( 'wpmu_new_blog' );38 }39 40 36 $b = self::factory()->blog->create(); 41 37 $u = self::factory()->user->create(); … … 131 127 } 132 128 133 if ( function_exists( 'wp_initialize_site' ) ) {134 $this->setExpectedDeprecated( 'wpmu_new_blog' );135 }136 137 129 $b = self::factory()->blog->create(); 138 130 $u = self::factory()->user->create(); … … 176 168 } 177 169 178 if ( function_exists( 'wp_initialize_site' ) ) {179 $this->setExpectedDeprecated( 'wpmu_new_blog' );180 }181 182 170 $b = self::factory()->blog->create(); 183 171 $u = self::factory()->user->create(); … … 223 211 } 224 212 225 if ( function_exists( 'wp_initialize_site' ) ) {226 $this->setExpectedDeprecated( 'wpmu_new_blog' );227 }228 229 213 add_filter( 'bp_blogs_activity_created_blog_action', array( $this, 'created_blog_passthrough' ), 10, 2 ); 230 214 … … 255 239 } 256 240 257 if ( function_exists( 'wp_initialize_site' ) ) {258 $this->setExpectedDeprecated( 'wpmu_new_blog' );259 }260 261 241 add_filter( 'bp_blogs_activity_new_post_action', array( $this, 'new_post_passthrough' ), 10, 2 ); 262 242 … … 287 267 } 288 268 289 if ( function_exists( 'wp_initialize_site' ) ) {290 $this->setExpectedDeprecated( 'wpmu_new_blog' );291 }292 293 269 add_filter( 'bp_blogs_activity_new_comment_action', array( $this, 'new_comment_passthrough' ), 10, 2 ); 294 270 … … 322 298 if ( ! is_multisite() ) { 323 299 $this->markTestSkipped(); 324 }325 326 if ( function_exists( 'wp_initialize_site' ) ) {327 $this->setExpectedDeprecated( 'wpmu_new_blog' );328 300 } 329 301 -
trunk/tests/phpunit/testcases/blogs/cache.php
r12247 r12606 14 14 } 15 15 16 if ( function_exists( 'wp_initialize_site' ) ) {17 $this->setExpectedDeprecated( 'wpmu_new_blog' );18 }19 20 16 $b1 = self::factory()->blog->create(); 21 17 $b2 = self::factory()->blog->create(); … … 99 95 } 100 96 101 if ( function_exists( 'wp_initialize_site' ) ) {102 $this->setExpectedDeprecated( 'wpmu_new_blog' );103 }104 105 97 $u = self::factory()->user->create(); 106 98 … … 197 189 } 198 190 199 if ( function_exists( 'wp_initialize_site' ) ) {200 $this->setExpectedDeprecated( 'wpmu_new_blog' );201 }202 203 191 $u = self::factory()->user->create(); 204 192 … … 274 262 if ( ! is_multisite() ) { 275 263 $this->markTestSkipped(); 276 }277 278 if ( function_exists( 'wp_initialize_site' ) ) {279 $this->setExpectedDeprecated( 'wpmu_new_blog' );280 $this->setExpectedDeprecated( 'delete_blog' );281 264 } 282 265 … … 315 298 } 316 299 317 if ( function_exists( 'wp_initialize_site' ) ) {318 $this->setExpectedDeprecated( 'wpmu_new_blog' );319 }320 321 300 $u = self::factory()->user->create(); 322 301 -
trunk/tests/phpunit/testcases/blogs/class-bp-blogs-blog.php
r12246 r12606 9 9 if ( ! is_multisite() ) { 10 10 $this->markTestSkipped(); 11 }12 13 if ( function_exists( 'wp_initialize_site' ) ) {14 $this->setExpectedDeprecated( 'wpmu_new_blog' );15 11 } 16 12 … … 42 38 } 43 39 44 if ( function_exists( 'wp_initialize_site' ) ) {45 $this->setExpectedDeprecated( 'wpmu_new_blog' );46 }47 48 40 $old_user = get_current_user_id(); 49 41 … … 71 63 if ( ! is_multisite() ) { 72 64 $this->markTestSkipped(); 73 }74 75 if ( function_exists( 'wp_initialize_site' ) ) {76 $this->setExpectedDeprecated( 'wpmu_new_blog' );77 65 } 78 66 … … 106 94 } 107 95 108 if ( function_exists( 'wp_initialize_site' ) ) {109 $this->setExpectedDeprecated( 'wpmu_new_blog' );110 }111 112 96 $old_user = get_current_user_id(); 113 97 … … 136 120 if ( ! is_multisite() ) { 137 121 $this->markTestSkipped(); 138 }139 140 if ( function_exists( 'wp_initialize_site' ) ) {141 $this->setExpectedDeprecated( 'wpmu_new_blog' );142 122 } 143 123 -
trunk/tests/phpunit/testcases/blogs/functions.php
r12605 r12606 286 286 if ( ! is_multisite() ) { 287 287 $this->markTestSkipped(); 288 }289 290 if ( function_exists( 'wp_initialize_site' ) ) {291 $this->setExpectedDeprecated( 'wpmu_new_blog' );292 288 } 293 289 … … 891 887 public function test_bp_blogs_comment_sync_activity_comment_for_custom_post_type() { 892 888 if ( is_multisite() ) { 893 if ( function_exists( 'wp_initialize_site' ) ) {894 $this->setExpectedDeprecated( 'wpmu_new_blog' );895 }896 897 889 $b = self::factory()->blog->create(); 898 890 switch_to_blog( $b ); … … 1001 993 } 1002 994 1003 if ( function_exists( 'wp_initialize_site' ) ) {1004 $this->setExpectedDeprecated( 'wpmu_new_blog' );1005 }1006 1007 995 $old_user = get_current_user_id(); 1008 996 … … 1035 1023 if ( ! is_multisite() ) { 1036 1024 $this->markTestSkipped(); 1037 }1038 1039 if ( function_exists( 'wp_initialize_site' ) ) {1040 $this->setExpectedDeprecated( 'wpmu_new_blog' );1041 $this->setExpectedDeprecated( 'delete_blog' );1042 1025 } 1043 1026 … … 1089 1072 } 1090 1073 1091 if ( function_exists( 'wp_initialize_site' ) ) {1092 $this->setExpectedDeprecated( 'wpmu_new_blog' );1093 }1094 1095 1074 $reset_post = $_POST; 1096 1075 $old_user = get_current_user_id(); … … 1151 1130 } 1152 1131 1153 if ( function_exists( 'wp_initialize_site' ) ) {1154 $this->setExpectedDeprecated( 'wpmu_new_blog' );1155 }1156 1157 1132 $u1 = self::factory()->user->create(); 1158 1133 $b1 = get_current_blog_id(); … … 1181 1156 } 1182 1157 1183 if ( function_exists( 'wp_initialize_site' ) ) {1184 $this->setExpectedDeprecated( 'wpmu_new_blog' );1185 }1186 1187 1158 $u1 = self::factory()->user->create(); 1188 1159 $b1 = get_current_blog_id(); -
trunk/tests/phpunit/testcases/blogs/template.php
r12496 r12606 378 378 } 379 379 380 if ( function_exists( 'wp_initialize_site' ) ) {381 $this->setExpectedDeprecated( 'wpmu_new_blog' );382 }383 384 380 global $blogs_template; 385 381 $reset_blogs_template = $blogs_template; … … 422 418 } 423 419 424 if ( function_exists( 'wp_initialize_site' ) ) {425 $this->setExpectedDeprecated( 'wpmu_new_blog' );426 }427 428 420 global $blogs_template; 429 421 $reset_blogs_template = $blogs_template; -
trunk/tests/phpunit/testcases/core/avatars.php
r12507 r12606 24 24 if ( ! is_multisite() ) { 25 25 $this->markTestSkipped(); 26 }27 28 if ( function_exists( 'wp_initialize_site' ) ) {29 $this->setExpectedDeprecated( 'wpmu_new_blog' );30 26 } 31 27 -
trunk/tests/phpunit/testcases/core/caps.php
r12246 r12606 9 9 if ( ! is_multisite() ) { 10 10 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 11 }12 13 if ( function_exists( 'wp_initialize_site' ) ) {14 $this->setExpectedDeprecated( 'wpmu_new_blog' );15 11 } 16 12 … … 35 31 if ( ! is_multisite() ) { 36 32 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 37 }38 39 if ( function_exists( 'wp_initialize_site' ) ) {40 $this->setExpectedDeprecated( 'wpmu_new_blog' );41 33 } 42 34 -
trunk/tests/phpunit/testcases/core/functions.php
r12569 r12606 701 701 702 702 if ( is_multisite() ) { 703 if ( function_exists( 'wp_initialize_site' ) ) {704 $this->setExpectedDeprecated( 'wpmu_new_blog' );705 }706 707 703 $b = self::factory()->blog->create(); 708 704 switch_to_blog( $b ); … … 850 846 } 851 847 852 if ( function_exists( 'wp_initialize_site' ) ) {853 $this->setExpectedDeprecated( 'wpmu_new_blog' );854 }855 856 848 $bp = buddypress(); 857 849 $reset_bp_pages = $bp->pages; -
trunk/tests/phpunit/testcases/core/functions/bpCoreGetDirectoryPageIds.php
r12246 r12606 260 260 } 261 261 262 if ( function_exists( 'wp_initialize_site' ) ) {263 $this->setExpectedDeprecated( 'wpmu_new_blog' );264 }265 266 262 $dir_pages = bp_core_get_directory_pages(); 267 263 -
trunk/tests/phpunit/testcases/members/functions.php
r12605 r12606 578 578 579 579 if ( is_multisite() ) { 580 if ( function_exists( 'wp_initialize_site' ) ) {581 $this->setExpectedDeprecated( 'wpmu_new_blog' );582 }583 584 580 $signups['ms-blog'] = array( 'signup_id' => self::factory()->signup->create( array( 585 581 'user_login' => 'msblog', -
trunk/tests/phpunit/testcases/routing/url.php
r12246 r12606 42 42 // (3) Multisite, root blog other than 1 43 43 if ( is_multisite() ) { 44 if ( function_exists( 'wp_initialize_site' ) ) {45 $this->setExpectedDeprecated( 'wpmu_new_blog' );46 }47 48 44 $original_root_blog = bp_get_root_blog_id(); 49 45 $blog_id = self::factory()->blog->create( array(
Note: See TracChangeset
for help on using the changeset viewer.