Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/12/2021 07:48:13 PM (5 years ago)
Author:
imath
Message:

Make sure all BP components init their BP Blocks

Even if some components don't have native BP Blocks, it makes it easier for developers to add their custom blocks or override existing BP Blocks or disable BP Blocks. Working on the BP Blocks feature as a plugin made us realize this.

This commit also improves the BP_Block constructor inline documentation, adds a new method to the Core component to register REST controllers and moves the BP_REST_Components_Endpoint one from the Members component to the Core component.

Fixes #8511

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-component.php

    r12581 r12994  
    918918     * @since 6.0.0
    919919     *
     920     * @see `BP_Block->construct()` for a full description of a BP Block arguments.
     921     *
    920922     * @param array $blocks The list of BP Blocks to register.
    921923     */
    922924    public function blocks_init( $blocks = array() ) {
    923         if ( is_array( $blocks ) && $blocks ) {
    924             /**
    925              * Filter here to disable all or some BP Blocks for a component.
    926              *
    927              * This is a dynamic hook that is based on the component string ID.
    928              *
    929              * @since 6.0.0
    930              *
    931              * @param array $blocks The list of BP Blocks for the component.
    932              */
    933             $blocks = (array) apply_filters( 'bp_' . $this->id . '_register_blocks', $blocks );
    934 
     925        /**
     926         * Filter here to add new BP Blocks, disable some or all BP Blocks for a component.
     927         *
     928         * This is a dynamic hook that is based on the component string ID.
     929         *
     930         * @since 6.0.0
     931         *
     932         * @param array $blocks The list of BP Blocks for the component.
     933         */
     934        $blocks = (array) apply_filters( 'bp_' . $this->id . '_register_blocks', $blocks );
     935        $blocks = array_filter( $blocks );
     936
     937        if ( $blocks ) {
    935938            foreach ( $blocks as $block ) {
    936939                bp_register_block( $block );
Note: See TracChangeset for help on using the changeset viewer.