Skip to:
Content

BuddyPress.org


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