Changeset 13140 for trunk/src/bp-core/bp-core-wpabstraction.php
- Timestamp:
- 11/07/2021 05:22:42 PM (4 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/bp-core-wpabstraction.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-wpabstraction.php
r12699 r13140 310 310 311 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 back315 * to 4.9.0, this function makes sure we are using the new hook `wp_initialize_site` when the current316 * WordPress version is upper or equal to 5.1.0 and that we keep on using `wpmu_new_blog` for earlier317 * versions of WordPress.318 *319 * @since 6.0.0320 *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 312 * Catch the new site data for a later use. 335 313 * … … 400 378 do_action( 'bp_insert_site', $site_id, $user_id, $domain, $path, $network_id, $meta ); 401 379 } 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.9.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 } 380 add_action( 'wp_initialize_site', 'bp_insert_site' ); 425 381 426 382 /** … … 472 428 do_action( 'bp_delete_site', $site_id, $drop ); 473 429 } 474 add_action( bp_delete_site_hook(), 'bp_delete_site', 10, 2 ); 475 476 if ( ! function_exists( 'wp_parse_list' ) ) { 477 /** 478 * Cleans up an array, comma- or space-separated list of scalar values. 479 * 480 * As BuddyPress supports older WordPress versions than 5.1 (4.9 & 5.0), 481 * the BP REST API needs this function to be available. 482 * 483 * @since 7.0.0 484 * 485 * @param array|string $list List of values. 486 * @return array Sanitized array of values. 487 */ 488 function wp_parse_list( $list ) { 489 if ( ! is_array( $list ) ) { 490 return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); 491 } 492 493 return $list; 494 } 495 } 430 add_action( 'wp_validate_site_deletion', 'bp_delete_site', 10, 2 );
Note: See TracChangeset
for help on using the changeset viewer.