Skip to:
Content

BuddyPress.org

Ticket #8571: 8571.patch

File 8571.patch, 17.3 KB (added by imath, 2 years ago)
  • .github/workflows/unit-tests.yml

    diff --git .github/workflows/unit-tests.yml .github/workflows/unit-tests.yml
    index 420dea24b..bb3cd9d41 100644
    jobs: 
    1818            wp_version: '5.8'
    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 }}
    2325      WP_VERSION: ${{ matrix.wp_version }}
  • src/bp-blogs/bp-blogs-functions.php

    diff --git src/bp-blogs/bp-blogs-functions.php src/bp-blogs/bp-blogs-functions.php
    index c64e88ab7..09cc5f1f1 100644
    add_action( 'update_option_site_icon', 'bp_blogs_update_option_site_icon', 10, 2 
    574574 * Deletes the 'url' blogmeta for a site.
    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
    581580 *
    add_action( 'update_option_site_icon', 'bp_blogs_update_option_site_icon', 10, 2 
    584583function bp_blogs_delete_url_blogmeta( $site_id = 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/**
    595589 * Record activity metadata about a published blog post.
  • src/bp-core/admin/js/hello.js

    diff --git src/bp-core/admin/js/hello.js src/bp-core/admin/js/hello.js
    index 8324e6cc2..47c996579 100644
     
    44 *
    55 * @since 3.0.0
    66 */
    7 (function( $, bp ) {
     7(function( $, wp ) {
    88        // Bail if not set
    99        if ( typeof bpHelloStrings === 'undefined' ) {
    1010                return;
     
    7979
    8080                        $( '#TB_window' ).addClass( 'thickbox-loading' );
    8181
    82                         bp.apiRequest( {
     82                        wp.apiRequest( {
    8383                                url: anchor.data( 'endpoint' ),
    8484                                type: 'GET',
    8585                                beforeSend: function( xhr, settings ) {
     
    118118        } );
    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 || {} ) );
  • src/bp-core/bp-core-functions.php

    diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php
    index 3dbc32f11..8b2653276 100644
    function bp_register_type_meta( $type_tax, $meta_key, array $args ) { 
    32703270                return false;
    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}
    32823275
    function bp_email_get_appearance_settings() { 
    36843677                )
    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
    36983689        $default_args = array(
  • src/bp-core/bp-core-rest-api.php

    diff --git src/bp-core/bp-core-rest-api.php src/bp-core/bp-core-rest-api.php
    index a0a719b56..74c8e1061 100644
    function bp_rest_api_is_available() { 
    6363 * Register the jQuery.ajax wrapper for BP REST API requests.
    6464 *
    6565 * @since 5.0.0
     66 * @deprecated 10.0.0
    6667 */
    6768function bp_rest_api_register_request_script() {
    6869        if ( ! bp_rest_api_is_available() ) {
    6970                return;
    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
    8579        );
    function bp_rest_api_register_request_script() { 
    8882                'bp-api-request',
    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                        'root'              => esc_url_raw( get_rest_url() ),
     86                        'nonce'             => wp_create_nonce( 'wp_rest' ),
     87                        'unexpectedError'   => __( 'An unexpected error occured. Please try again.', 'buddypress' ),
     88                        'deprecatedWarning' => __( 'The bp.apiRequest function is deprecated since BuddyPress 10.0.0, please use wp.apiRequest instead.', 'buddypress' ),
    9489                )
    9590        );
    9691}
  • src/bp-core/bp-core-wpabstraction.php

    diff --git src/bp-core/bp-core-wpabstraction.php src/bp-core/bp-core-wpabstraction.php
    index ebeb1fbc3..8f7e524bf 100644
    if ( !function_exists( 'mb_strrpos' ) ) { 
    308308        }
    309309}
    310310
    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.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 
    333311/**
    334312 * Catch the new site data for a later use.
    335313 *
    function bp_insert_site( $site, $args_or_user_id = null, $domain = '', $path = ' 
    399377         */
    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/**
    427383 * Makes sure the `bp_delete_site` hook is fired if site's deletion
    function bp_delete_site( $site_id_or_error, $drop_or_site = false ) { 
    471427         */
    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 );
  • src/bp-core/classes/class-bp-admin.php

    diff --git src/bp-core/classes/class-bp-admin.php src/bp-core/classes/class-bp-admin.php
    index ee80328cc..97b9ea449 100644
    class BP_Admin { 
    573573         * @since 4.0.0
    574574         */
    575575        public function add_privacy_policy_content() {
    576                 // Nothing to do if we're running < WP 4.9.6.
    577                 if ( bp_is_running_wp( '4.9.6', '<' ) ) {
    578                         return;
    579                 }
    580 
    581576                $suggested_text = '<strong class="privacy-policy-tutorial">' . esc_html__( 'Suggested text:', 'buddypress' ) . ' </strong>';
    582577                $content = '';
    583578
    class BP_Admin { 
    12131208                        // 3.0
    12141209                        'bp-hello-js' => array(
    12151210                                'file'         => "{$url}hello{$min}.js",
    1216                                 'dependencies' => array( 'thickbox', 'bp-api-request' ),
     1211                                'dependencies' => array( 'thickbox', 'wp-api-request' ),
    12171212                                'footer'       => true,
    12181213                        ),
    12191214                ) );
  • src/bp-core/deprecated/10.0.php

    diff --git src/bp-core/deprecated/10.0.php src/bp-core/deprecated/10.0.php
    index e69de29bb..7ff78b259 100644
     
     1<?php
     2/**
     3 * Deprecated functions.
     4 *
     5 * @package BuddyPress
     6 * @deprecated 10.0.0
     7 */
     8
     9// Exit if accessed directly.
     10if ( ! defined( 'ABSPATH' ) ) {
     11        exit;
     12}
     13
     14/**
     15 * Returns the name of the hook to use once a WordPress Site is inserted into the Database.
     16 *
     17 * WordPress 5.1.0 deprecated the `wpmu_new_blog` action. As BuddyPress is supporting WordPress back
     18 * to 4.9.0, this function makes sure we are using the new hook `wp_initialize_site` when the current
     19 * WordPress version is upper or equal to 5.1.0 and that we keep on using `wpmu_new_blog` for earlier
     20 * versions of WordPress.
     21 *
     22 * @since 6.0.0
     23 * @deprecated 10.0.0
     24 *
     25 * @return string The name of the hook to use.
     26 */
     27function bp_insert_site_hook() {
     28        _deprecated_function( __FUNCTION__, '10.0.0' );
     29
     30        $wp_hook = 'wpmu_new_blog';
     31
     32        if ( function_exists( 'wp_insert_site' ) ) {
     33                $wp_hook = 'wp_initialize_site';
     34        }
     35
     36        return $wp_hook;
     37}
     38
     39/**
     40 * Returns the name of the hook to use once a WordPress Site is deleted.
     41 *
     42 * WordPress 5.1.0 deprecated the `delete_blog` action. As BuddyPress is supporting WordPress back
     43 * to 4.9.0, this function makes sure we are using the new hook `wp_validate_site_deletion` when the
     44 * current WordPress version is upper or equal to 5.1.0 and that we keep on using `delete_blog` for
     45 * earlier versions of WordPress.
     46 *
     47 * @since 6.0.0
     48 * @deprecated 10.0.0
     49 *
     50 * @return string The name of the hook to use.
     51 */
     52function bp_delete_site_hook() {
     53        _deprecated_function( __FUNCTION__, '10.0.0' );
     54
     55        $wp_hook = 'delete_blog';
     56
     57        if ( function_exists( 'wp_delete_site' ) ) {
     58                $wp_hook = 'wp_validate_site_deletion';
     59        }
     60
     61        return $wp_hook;
     62}
  • src/bp-core/js/bp-api-request.js

    diff --git src/bp-core/js/bp-api-request.js src/bp-core/js/bp-api-request.js
    index 339b1c1a9..cb450f8ed 100644
     
    22 * jQuery.ajax wrapper for BP REST API requests.
    33 *
    44 * @since  5.0.0
     5 * @deprecated 10.0.0
    56 * @output bp-core/js/bp-api-request.js
    67 */
    78/* global bpApiSettings */
    89window.bp = window.bp || {};
    910
    10 ( function( wp, bp, $ ) {
     11( function( wp, bp ) {
    1112    // Bail if not set.
    1213    if ( typeof bpApiSettings === 'undefined' ) {
    1314        return;
    window.bp = window.bp || {}; 
    1516
    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
    2225        if ( ! options.dataType ) {
    2326            options.dataType = 'json';
    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 ) {
    5332            var errorObject = {
    window.bp = window.bp || {}; 
    6645        } );
    6746    };
    6847
    69 } )( window.wp || {}, window.bp, jQuery );
     48} )( window.wp || {}, window.bp );
  • src/bp-groups/bp-groups-cssjs.php

    diff --git src/bp-groups/bp-groups-cssjs.php src/bp-groups/bp-groups-cssjs.php
    index 99aab5bb6..915d1611c 100644
    function bp_groups_register_scripts() { 
    1919    wp_register_script(
    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
    2525    );
  • src/bp-groups/js/manage-members.js

    diff --git src/bp-groups/js/manage-members.js src/bp-groups/js/manage-members.js
    index 34ef7dccb..69358a431 100644
     
    44( function( wp, bp, $ ) {
    55
    66        // Bail if not set
    7         if ( typeof bpGroupManageMembersSettings === 'undefined' || ! bp.isRestEnabled ) {
     7        if ( typeof bpGroupManageMembersSettings === 'undefined' ) {
    88                return;
    99        }
    1010
     
    6262                                        options.headers = { 'X-HTTP-Method-Override': 'PUT' };
    6363                                }
    6464
    65                                 return bp.apiRequest( options );
     65                                return wp.apiRequest( options );
    6666                        }
    6767                },
    6868
     
    117117                                        }
    118118                                };
    119119
    120                                 return bp.apiRequest( options );
     120                                return wp.apiRequest( options );
    121121                        }
    122122                }
    123123        } );
  • src/bp-members/bp-members-template.php

    diff --git src/bp-members/bp-members-template.php src/bp-members/bp-members-template.php
    index 39cfd6e65..10e6ef071 100644
    function bp_signup_avatar_dir_value() { 
    27452745 * @return bool
    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.
    27542750        $privacy_policy_url = get_privacy_policy_url();
  • src/bp-settings/bp-settings-functions.php

    diff --git src/bp-settings/bp-settings-functions.php src/bp-settings/bp-settings-functions.php
    index 12acd24f9..399966914 100644
    function bp_settings_get_personal_data_request( $user_id = 0 ) { 
    248248        ) );
    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;
    256254        }
  • src/bp-settings/classes/class-bp-settings-component.php

    diff --git src/bp-settings/classes/class-bp-settings-component.php src/bp-settings/classes/class-bp-settings-component.php
    index c39bff37e..eb7f0acb0 100644
    class BP_Settings_Component extends BP_Component { 
    198198                 */
    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' ),
    205205                                'slug'            => 'data',
    class BP_Settings_Component extends BP_Component { 
    278278                        $show_data_page = apply_filters( 'bp_settings_show_user_data_page', true );
    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,
    284284                                        'id'       => 'my-account-' . $this->id . '-data',
  • src/class-buddypress.php

    diff --git src/class-buddypress.php src/class-buddypress.php
    index e8f2a9797..981ae06a1 100644
    class BuddyPress { 
    558558                        require $this->plugin_dir . 'bp-core/deprecated/7.0.php';
    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
    563564                // Load wp-cli module if PHP 5.6+.
  • src/readme.txt

    diff --git src/readme.txt src/readme.txt
    index 5e7eb3bfc..1a5e9b358 100644
    Contributors: johnjamesjacoby, DJPaul, boonebgorges, r-a-y, imath, mercime, tw21 
    33Tags: user profiles, activity streams, messaging, friends, user groups, notifications, community, social networking, intranet
    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
    99Stable tag: 9.1.1