Skip to:
Content

BuddyPress.org

Changeset 12581


Ignore:
Timestamp:
03/25/2020 10:12:18 AM (6 years ago)
Author:
imath
Message:

Add a function to check the current installation support BP Blocks

As BuddyPress supports WordPress 4.8 and 4.9, we need to make sure the current installation is using WordPress >= 5.0.0 before loading the BuddyPress blocks.

See #8048

Location:
trunk/src/bp-core
Files:
2 edited

Legend:

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

    r12578 r12581  
    1010// Exit if accessed directly.
    1111defined( 'ABSPATH' ) || exit;
     12
     13/**
     14 * BuddyPress blocks require WordPress >= 5.0.0 & the BP REST API.
     15 *
     16 * @since 6.0.0
     17 *
     18 * @return bool True if the current installation supports BP Blocks.
     19 *              False otherwise.
     20 */
     21function bp_support_blocks() {
     22    return function_exists( 'register_block_type' ) && bp_rest_api_is_available();
     23}
    1224
    1325/**
  • trunk/src/bp-core/classes/class-bp-component.php

    r12578 r12581  
    468468
    469469        // Register BP Blocks.
    470         if ( bp_rest_api_is_available() ) {
     470        if ( bp_support_blocks() ) {
    471471            add_action( 'bp_blocks_init', array( $this, 'blocks_init' ), 10 );
    472472        }
Note: See TracChangeset for help on using the changeset viewer.