Skip to:
Content

BuddyPress.org

Changeset 12944


Ignore:
Timestamp:
05/09/2021 04:45:15 PM (4 years ago)
Author:
imath
Message:

BP Blocks: anticipate 2 deprecated WP 5.8 Block filters

In WordPress 5.8, the block_categories filter is deprecated in favor of the block_categories_all one and the block_editor_settings filter is deprecated in favor of block_editor_settings_all. To maintain backward compatibility with previous versions of WordPress, we are now checking if two functions introduced in WP 5.8 (get_default_block_categories() & get_block_editor_settings()) exists before using the right filters.

Fixes #8465

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

Legend:

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

    r12927 r12944  
    13451345    );
    13461346}
    1347 add_filter( 'block_categories', 'bp_block_category', 1, 2 );
     1347
     1348/**
     1349 * Select the right `block_categories` filter according to WP version.
     1350 *
     1351 * @since 8.0.0
     1352 */
     1353function bp_block_init_category_filter() {
     1354    if ( function_exists( 'get_default_block_categories' ) ) {
     1355        add_filter( 'block_categories_all', 'bp_block_category', 1, 2 );
     1356    } else {
     1357        add_filter( 'block_categories', 'bp_block_category', 1, 2 );
     1358    }
     1359}
     1360add_action( 'bp_init', 'bp_block_init_category_filter' );
  • trunk/src/bp-core/bp-core-blocks.php

    r12745 r12944  
    6868    return $editor_settings;
    6969}
    70 add_filter( 'block_editor_settings', 'bp_blocks_editor_settings' );
     70
     71/**
     72 * Select the right `block_editor_settings` filter according to WP version.
     73 *
     74 * @since 8.0.0
     75 */
     76function bp_block_init_editor_settings_filter() {
     77    if ( function_exists( 'get_block_editor_settings' ) ) {
     78        add_filter( 'block_editor_settings_all', 'bp_blocks_editor_settings' );
     79    } else {
     80        add_filter( 'block_editor_settings', 'bp_blocks_editor_settings' );
     81    }
     82}
     83add_action( 'bp_init', 'bp_block_init_editor_settings_filter' );
    7184
    7285/**
Note: See TracChangeset for help on using the changeset viewer.