Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/07/2021 05:22:42 PM (4 years ago)
Author:
imath
Message:

Raise WordPress required version to 5.4

BuddyPress 10.0.0 will require at least WordPress 5.4. The BP Development team took this decision on October 6 (2021) according to our guideline about WordPress version compatibility.

  • Add WordPress 5.4 to the WordPress versions tested into our PHPUnit GitHub action.
  • Deprecate the bp.apiRequest script which was introduced to polyfill the wp.apiRequest one. Plugin developers are encouraged to directly use the wp.apiRequest script. Please note the bp.apiRequest script will be completely removed in a next major BuddyPress version.
  • Deprecate the bp_insert_site_hook() and bp_delete_site_hook() function which were introduced to make sure to use the best hook according to the installed WordPress version when creating a new site or deleting an existing one.

At least one more commit is required to finish this "raising" process, as BP Blocks do not need anymore the CompatibiltyServerSideRender component we introduced to preserve back compatibility with WordPress version older than 5.3.

Props oztaser

See #8571

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-wpabstraction.php

    r12699 r13140  
    310310
    311311/**
    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.9.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 /**
    334312 * Catch the new site data for a later use.
    335313 *
     
    400378    do_action( 'bp_insert_site', $site_id, $user_id, $domain, $path, $network_id, $meta );
    401379}
    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 }
     380add_action( 'wp_initialize_site', 'bp_insert_site' );
    425381
    426382/**
     
    472428    do_action( 'bp_delete_site', $site_id, $drop );
    473429}
    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 }
     430add_action( 'wp_validate_site_deletion', 'bp_delete_site', 10, 2 );
Note: See TracChangeset for help on using the changeset viewer.