Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/09/2020 07:17:20 PM (5 years ago)
Author:
imath
Message:

Core: introduce the bp_is_running_wp() function

This helper function checks WordPress version and is used by BuddyPress to ensure backward-compatibility when a WordPress feature/function is not yet available on the WordPress site BuddyPress is running on.

We have standardized the way we were doing these checks so far by replacing these with the use of this new bp_is_running_wp() function. It will help us to identify backward-compatibility chunks when we bump our minimum WP version.

bp_is_running_wp() accepts two arguments:

  • the WP version, in "PHP-standardized" format.
  • the comparison operator. It defaults to >=.

Props boonebgorges, r-a-y, espellcaste

Fixes #7906

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-settings/classes/class-bp-settings-component.php

    r12272 r12745  
    194194
    195195        // Export Data - only available for WP 4.9.6+.
    196         if ( true === $show_data_page && version_compare( $GLOBALS['wp_version'], '4.9.6', '>=' ) ) {
     196        if ( true === $show_data_page && bp_is_running_wp( '4.9.6' ) ) {
    197197            $sub_nav[] = array(
    198198                'name'            => __( 'Export Data', 'buddypress' ),
     
    269269
    270270            // Export Data.
    271             if ( true === $show_data_page && version_compare( $GLOBALS['wp_version'], '4.9.6', '>=' ) ) {
     271            if ( true === $show_data_page && bp_is_running_wp( '4.9.6' ) ) {
    272272                $wp_admin_nav[] = array(
    273273                    'parent'   => 'my-account-' . $this->id,
Note: See TracChangeset for help on using the changeset viewer.