Skip to:
Content

BuddyPress.org

Changeset 13140


Ignore:
Timestamp:
11/07/2021 05:22:42 PM (3 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

Location:
trunk
Files:
1 added
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/unit-tests.yml

    r13030 r13140  
    1919          - php: '7.4'
    2020            wp_version: '5.8'
     21          - php: '7.4'
     22            wp_version: '5.4'
    2123    env:
    2224      WP_ENV_PHP_VERSION: ${{ matrix.php }}
  • trunk/src/bp-blogs/bp-blogs-functions.php

    r13108 r13140  
    575575 *
    576576 * Fires when a site's details are updated, which generally happens when
    577  * editing a site under "Network Admin > Sites". Prior to WP 4.9, the
    578  * correct hook was 'refresh_blog_details'; afterward, 'clean_site_cache'.
     577 * editing a site under "Network Admin > Sites".
    579578 *
    580579 * @since 2.3.0
     
    585584    bp_blogs_delete_blogmeta( (int) $site_id, 'url' );
    586585}
    587 
    588 if ( bp_is_running_wp( '4.9.0' ) ) {
    589     add_action( 'clean_site_cache', 'bp_blogs_delete_url_blogmeta' );
    590 } else {
    591     add_action( 'refresh_blog_details', 'bp_blogs_delete_url_blogmeta' );
    592 }
     586add_action( 'clean_site_cache', 'bp_blogs_delete_url_blogmeta' );
    593587
    594588/**
  • trunk/src/bp-core/admin/js/hello.js

    r12649 r13140  
    55 * @since 3.0.0
    66 */
    7 (function( $, bp ) {
     7(function( $, wp ) {
    88    // Bail if not set
    99    if ( typeof bpHelloStrings === 'undefined' ) {
     
    8080            $( '#TB_window' ).addClass( 'thickbox-loading' );
    8181
    82             bp.apiRequest( {
     82            wp.apiRequest( {
    8383                url: anchor.data( 'endpoint' ),
    8484                type: 'GET',
     
    119119
    120120    // Init modal after the screen's loaded.
    121     $( document ).ready( function() {
     121    $( function() {
    122122        bpHelloOpenModal();
    123123    } );
    124124
    125 }( jQuery, window.bp || {} ) );
     125}( jQuery, window.wp || {} ) );
  • trunk/src/bp-core/bp-core-blocks.php

    r13111 r13140  
    1212
    1313/**
    14  * BuddyPress blocks require WordPress >= 5.0.0 & the BP REST API.
     14 * BuddyPress blocks require the BP REST API.
    1515 *
    1616 * @since 6.0.0
     
    2020 */
    2121function bp_support_blocks() {
    22     return bp_is_running_wp( '5.0.0' ) && bp_rest_api_is_available();
     22    /**
     23     * Filter here, returning `false`, to completely disable BuddyPress blocks.
     24     *
     25     * @since 10.0.0
     26     *
     27     * @param bool $value True if the BP REST API is available. False otherwise.
     28     */
     29    return apply_filters( 'bp_support_blocks', bp_rest_api_is_available() );
    2330}
    2431
  • trunk/src/bp-core/bp-core-functions.php

    r13118 r13140  
    32713271    }
    32723272
    3273     // register_term_meta() was introduced in WP 4.9.8.
    3274     if ( ! bp_is_running_wp( '4.9.8' ) ) {
    3275         $args['object_subtype'] = $type_tax;
    3276 
    3277         return register_meta( 'term', $meta_key, $args );
    3278     }
    3279 
    32803273    return register_term_meta( $type_tax, $meta_key, $args );
    32813274}
     
    36853678    );
    36863679
    3687     if ( bp_is_running_wp( '4.9.6' ) ) {
    3688         $privacy_policy_url = get_privacy_policy_url();
    3689         if ( $privacy_policy_url ) {
    3690             $footer_text[] = sprintf(
    3691                 '<a href="%s">%s</a>',
    3692                 esc_url( $privacy_policy_url ),
    3693                 esc_html__( 'Privacy Policy', 'buddypress' )
    3694             );
    3695         }
     3680    $privacy_policy_url = get_privacy_policy_url();
     3681    if ( $privacy_policy_url ) {
     3682        $footer_text[] = sprintf(
     3683            '<a href="%s">%s</a>',
     3684            esc_url( $privacy_policy_url ),
     3685            esc_html__( 'Privacy Policy', 'buddypress' )
     3686        );
    36963687    }
    36973688
  • trunk/src/bp-core/bp-core-rest-api.php

    r12985 r13140  
    5151     * Filter here to disable the BP REST API.
    5252     *
    53      * The BP REST API requires at least WordPress 4.7.0
     53     * The BP REST API requires at least WordPress 4.7.0.
    5454     *
    5555     * @since 5.0.0
     
    5757     * @param boolean $value True if the BP REST API is available. False otherwise.
    5858     */
    59     return apply_filters( 'bp_rest_api_is_available', bp_is_running_wp( '4.7.0' ) && bp_rest_in_buddypress() ) || bp_rest_is_plugin_active();
     59    return apply_filters( 'bp_rest_api_is_available', bp_rest_in_buddypress() ) || bp_rest_is_plugin_active();
    6060}
    6161
     
    6464 *
    6565 * @since 5.0.0
     66 * @deprecated 10.0.0
    6667 */
    6768function bp_rest_api_register_request_script() {
     
    7071    }
    7172
    72     $dependencies = array( 'jquery' );
    73 
    74     // The wrapper for WP REST API requests was introduced in WordPress 4.9.0.
    75     if ( wp_script_is( 'wp-api-request', 'registered' ) ) {
    76         $dependencies = array( 'wp-api-request' );
    77     }
    78 
    7973    wp_register_script(
    8074        'bp-api-request',
    8175        sprintf( '%1$sbp-core/js/bp-api-request%2$s.js', buddypress()->plugin_url, bp_core_get_minified_asset_suffix() ),
    82         $dependencies,
     76        array( 'jquery', 'wp-api-request' ),
    8377        bp_get_version(),
    8478        true
     
    8983        'bpApiSettings',
    9084        array(
    91             'root'            => esc_url_raw( get_rest_url() ),
    92             'nonce'           => wp_create_nonce( 'wp_rest' ),
    93             'unexpectedError' => __( 'An unexpected error occured. Please try again.', 'buddypress' ),
     85            'unexpectedError'   => __( 'An unexpected error occured. Please try again.', 'buddypress' ),
     86            'deprecatedWarning' => __( 'The bp.apiRequest function is deprecated since BuddyPress 10.0.0, please use wp.apiRequest instead.', 'buddypress' ),
    9487        )
    9588    );
  • trunk/src/bp-core/bp-core-template.php

    r13108 r13140  
    38853885    );
    38863886
    3887     if ( $block_name && bp_is_running_wp( '5.0.0', '>=' ) ) {
     3887    if ( $block_name && bp_is_running_wp( '5.8.0', '>=' ) ) {
    38883888        $widget_blocks = get_option( 'widget_block', array() );
    38893889        $sidebars      = wp_get_sidebars_widgets();
  • 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 );
  • trunk/src/bp-core/classes/class-bp-admin.php

    r13139 r13140  
    655655     */
    656656    public function add_privacy_policy_content() {
    657         // Nothing to do if we're running < WP 4.9.6.
    658         if ( bp_is_running_wp( '4.9.6', '<' ) ) {
    659             return;
    660         }
    661 
    662657        $suggested_text = '<strong class="privacy-policy-tutorial">' . esc_html__( 'Suggested text:', 'buddypress' ) . ' </strong>';
    663658        $content = '';
     
    12911286            'bp-hello-js' => array(
    12921287                'file'         => "{$url}hello{$min}.js",
    1293                 'dependencies' => array( 'thickbox', 'bp-api-request' ),
     1288                'dependencies' => array( 'thickbox', 'wp-api-request' ),
    12941289                'footer'       => true,
    12951290            ),
  • trunk/src/bp-core/js/bp-api-request.js

    r12548 r13140  
    33 *
    44 * @since  5.0.0
     5 * @deprecated 10.0.0
    56 * @output bp-core/js/bp-api-request.js
    67 */
     
    89window.bp = window.bp || {};
    910
    10 ( function( wp, bp, $ ) {
     11( function( wp, bp ) {
    1112    // Bail if not set.
    1213    if ( typeof bpApiSettings === 'undefined' ) {
     
    1617    bp.isRestEnabled = true;
    1718
    18     // Polyfill wp.apiRequest if WordPress < 4.9.
     19    // Polyfill wp.apiRequest.
    1920    bp.apiRequest = function( options ) {
     21        window.console.log( bpApiSettings.deprecatedWarning );
     22
    2023        var bpRequest;
    2124
     
    2427        }
    2528
    26         // WordPress is >= 4.9.0.
    27         if ( wp.apiRequest ) {
    28             bpRequest = wp.apiRequest( options );
    29 
    30         // WordPress is < 4.9.0.
    31         } else {
    32             var url = bpApiSettings.root;
    33 
    34             if ( options.path ) {
    35                 url = url + options.path.replace( /^\//, '' );
    36             }
    37 
    38             if ( ! options.url ) {
    39                 options.url = url;
    40             }
    41 
    42             // Add The nonce only when needed.
    43             if ( -1 !== options.url.indexOf( url ) ) {
    44                 options.beforeSend = function( xhr ) {
    45                     xhr.setRequestHeader( 'X-WP-Nonce', bpApiSettings.nonce );
    46                 };
    47             }
    48 
    49             bpRequest = $.ajax( options );
    50         }
     29        bpRequest = wp.apiRequest( options );
    5130
    5231        return bpRequest.then( null, function( result ) {
     
    6746    };
    6847
    69 } )( window.wp || {}, window.bp, jQuery );
     48} )( window.wp || {}, window.bp );
  • trunk/src/bp-friends/bp-friends-blocks.php

    r13108 r13140  
    208208        );
    209209
    210         $preloaded_friends = array();
    211         if ( bp_is_running_wp( '5.0.0' ) ) {
    212             $preloaded_friends = rest_preload_api_request( '', $default_path );
    213         }
     210        $preloaded_friends = rest_preload_api_request( '', $default_path );
    214211
    215212        buddypress()->friends->block_globals['bp/friends']->items[ $widget_id ] = (object) array(
  • trunk/src/bp-groups/bp-groups-blocks.php

    r13108 r13140  
    484484        );
    485485
    486         $preloaded_groups = array();
    487         if ( bp_is_running_wp( '5.0.0' ) ) {
    488             $preloaded_groups = rest_preload_api_request( '', $default_path );
    489         }
     486        $preloaded_groups = rest_preload_api_request( '', $default_path );
    490487
    491488        buddypress()->groups->block_globals['bp/dynamic-groups']->items[ $widget_id ] = (object) array(
  • trunk/src/bp-groups/bp-groups-cssjs.php

    r13004 r13140  
    2020        'bp-group-manage-members',
    2121        sprintf( '%1$sbp-groups/js/manage-members%2$s.js', buddypress()->plugin_url, bp_core_get_minified_asset_suffix() ),
    22         array( 'json2', 'wp-backbone', 'bp-api-request' ),
     22        array( 'json2', 'wp-backbone', 'wp-api-request' ),
    2323        bp_get_version(),
    2424        true
     
    5050    );
    5151
    52     $preloaded_members = array();
    53     if ( bp_is_running_wp( '5.0.0' ) ) {
    54         $preloaded_members = rest_preload_api_request( '', $path );
    55     }
     52    $preloaded_members = rest_preload_api_request( '', $path );
    5653
    5754    return array(
  • trunk/src/bp-groups/js/manage-members.js

    r12531 r13140  
    55
    66    // Bail if not set
    7     if ( typeof bpGroupManageMembersSettings === 'undefined' || ! bp.isRestEnabled ) {
     7    if ( typeof bpGroupManageMembersSettings === 'undefined' ) {
    88        return;
    99    }
     
    6363                }
    6464
    65                 return bp.apiRequest( options );
     65                return wp.apiRequest( options );
    6666            }
    6767        },
     
    118118                };
    119119
    120                 return bp.apiRequest( options );
     120                return wp.apiRequest( options );
    121121            }
    122122        }
  • trunk/src/bp-members/bp-members-blocks.php

    r13108 r13140  
    501501        );
    502502
    503         $preloaded_members = array();
    504         if ( bp_is_running_wp( '5.0.0' ) ) {
    505             $preloaded_members = rest_preload_api_request( '', $default_path );
    506         }
     503        $preloaded_members = rest_preload_api_request( '', $default_path );
    507504
    508505        buddypress()->members->block_globals['bp/dynamic-members']->items[ $widget_id ] = (object) array(
  • trunk/src/bp-members/bp-members-template.php

    r13118 r13140  
    27462746 */
    27472747function bp_signup_requires_privacy_policy_acceptance() {
    2748     // Bail if we're running a version of WP that doesn't have the Privacy Policy feature.
    2749     if ( bp_is_running_wp( '4.9.6', '<' ) ) {
    2750         return false;
    2751     }
    27522748
    27532749    // Default to true when a published Privacy Policy page exists.
  • trunk/src/bp-settings/bp-settings-functions.php

    r13090 r13140  
    249249
    250250    if ( ! empty( $query->post ) ) {
    251         // WP 5.4 changed the user request function name to wp_get_user_request()
    252         $user_request = bp_is_running_wp( '4.9.6' ) ? 'wp_get_user_request' : 'wp_get_user_request_data';
    253         return $user_request( $query->post->ID );
     251        return wp_get_user_request( $query->post->ID );
    254252    } else {
    255253        return false;
  • trunk/src/bp-settings/classes/class-bp-settings-component.php

    r13093 r13140  
    199199        $show_data_page = apply_filters( 'bp_settings_show_user_data_page', true );
    200200
    201         // Export Data - only available for WP 4.9.6+.
    202         if ( true === $show_data_page && bp_is_running_wp( '4.9.6' ) ) {
     201        // Export Data.
     202        if ( true === $show_data_page ) {
    203203            $sub_nav[] = array(
    204204                'name'            => __( 'Export Data', 'buddypress' ),
     
    279279
    280280            // Export Data.
    281             if ( true === $show_data_page && bp_is_running_wp( '4.9.6' ) ) {
     281            if ( true === $show_data_page ) {
    282282                $wp_admin_nav[] = array(
    283283                    'parent'   => 'my-account-' . $this->id,
  • trunk/src/bp-templates/bp-nouveau/includes/functions.php

    r13016 r13140  
    15531553 */
    15541554function bp_nouveau_unregister_blocks_for_post_context() {
    1555     if ( ! function_exists( 'unregister_block_type' ) ) {
    1556         return;
    1557     }
    1558 
    15591555    $is_registered = WP_Block_Type_Registry::get_instance()->is_registered( 'bp/primary-nav' );
    15601556
  • trunk/src/class-buddypress.php

    r13109 r13140  
    559559            require $this->plugin_dir . 'bp-core/deprecated/8.0.php';
    560560            require $this->plugin_dir . 'bp-core/deprecated/9.0.php';
     561            require $this->plugin_dir . 'bp-core/deprecated/10.0.php';
    561562        }
    562563
  • trunk/src/readme.txt

    r13084 r13140  
    44License: GPLv2 or later
    55License URI: https://www.gnu.org/licenses/gpl-2.0.html
    6 Requires at least: 4.9
     6Requires at least: 5.4
    77Requires PHP: 5.6
    88Tested up to: 5.8
  • trunk/tests/phpunit/includes/testcase.php

    r13108 r13140  
    8686            if ( is_multisite() ) {
    8787                foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs WHERE blog_id != 1" ) as $blog_id ) {
    88                     if ( function_exists( 'wp_uninitialize_site' ) ) {
    89                         wp_uninitialize_site( $blog_id );
    90                     } else {
    91                         wpmu_delete_blog( $blog_id, true );
    92                     }
     88                    wp_uninitialize_site( $blog_id );
    9389                }
    9490            }
Note: See TracChangeset for help on using the changeset viewer.