Skip to:
Content

BuddyPress.org

Changeset 13016


Ignore:
Timestamp:
07/15/2021 03:34:22 PM (4 years ago)
Author:
imath
Message:

Nouveau: only unregister the 'bp/primary-nav' block if it's registered

Nouveau unregisters this block when an admin edits a post type as it doesn't make sense to use this block into the Post Block Editor context. To prevent a _doing_it_wrong() from WordPress, it's probably safest to check if the block exists before unregistering it.

This commits also makes sure the user is using WP > 5.0.

Fixes #8528

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-nouveau/includes/functions.php

    r13009r13016 
    15531553 */
    15541554function bp_nouveau_unregister_blocks_for_post_context() {
    1555     unregister_block_type( 'bp/primary-nav' );
     1555    if ( ! function_exists( 'unregister_block_type' ) ) {
     1556        return;
     1557    }
     1558
     1559    $is_registered = WP_Block_Type_Registry::get_instance()->is_registered( 'bp/primary-nav' );
     1560
     1561    if ( $is_registered ) {
     1562        unregister_block_type( 'bp/primary-nav' );
     1563    }
    15561564}
    15571565add_action( 'load-post.php', 'bp_nouveau_unregister_blocks_for_post_context' );
Note: See TracChangeset for help on using the changeset viewer.