Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/21/2023 08:24:10 AM (19 months ago)
Author:
imath
Message:

BP Blocks: introduce a new $metadata argument to use WP Block API v2

The bp_register_block() array of arguments now accepts a $metadata
argument to inform about the path to a block block.json dir path. If
it's used this function is now is simple wrapper of WordPress's
register_block_type_from_metadata() function.

Closes https://github.com/buddypress/buddypress/pull/76
See #8842
See #8457
Fixes #8855

File:
1 edited

Legend:

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

    r13436 r13440  
    162162 */
    163163function bp_register_block( $args = array() ) {
     164    if ( isset( $args['metadata'] ) && is_string( $args['metadata'] ) && file_exists( $args['metadata'] ) ) {
     165        $callback = array();
     166
     167        if ( isset( $args['render_callback'] ) ) {
     168            $callback['render_callback'] = $args['render_callback'];
     169        }
     170
     171        return register_block_type_from_metadata( $args['metadata'], $callback );
     172    }
     173
    164174    return new BP_Block( $args );
    165175}
Note: See TracChangeset for help on using the changeset viewer.