Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/09/2021 04:45:15 PM (3 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

File:
1 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' );
Note: See TracChangeset for help on using the changeset viewer.