Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/25/2023 10:17:33 PM (3 years ago)
Author:
imath
Message:

Update all BP Blocks & Modern JS PHP registration code

  • Use the metadata argument of the bp_register_block() function to load all BP Blocks JSON files.
  • Get BP Blocks dependencies using the @wordpress/scripts index.asset.php generated files.
  • Although the BP Blocks category has been replaced by the BP Blocks collection, leave the no more used bp_block_category() function in place in case some third party plugins are using it for their custom blocks.
  • PHPUnit tests: make sure to unregister all BP Blocks when using the BP_UnitTestCase->go_to() method.

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

File:
1 edited

Legend:

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

    r13450 r13464  
    371371         *
    372372         * @since 9.0.0
     373         * @since 12.0.0 Use the WP Blocks API v2.
    373374         *
    374375         * @param array $blocks Optional. See BP_Component::blocks_init() for
     
    379380                        array(
    380381                                'bp/friends' => array(
    381                                         'name'               => 'bp/friends',
    382                                         'editor_script'      => 'bp-friends-block',
    383                                         'editor_script_url'  => plugins_url( 'js/blocks/friends.js', dirname( __FILE__ ) ),
    384                                         'editor_script_deps' => array(
    385                                                 'wp-blocks',
    386                                                 'wp-element',
    387                                                 'wp-components',
    388                                                 'wp-i18n',
    389                                                 'wp-block-editor',
    390                                                 'wp-server-side-render',
    391                                                 'bp-block-data',
    392                                         ),
    393                                         'style'              => 'bp-friends-block',
    394                                         'style_url'          => plugins_url( 'css/blocks/friends.css', dirname( __FILE__ ) ),
    395                                         'attributes'         => array(
    396                                                 'maxFriends'    => array(
    397                                                         'type'    => 'number',
    398                                                         'default' => 5,
    399                                                 ),
    400                                                 'friendDefault' => array(
    401                                                         'type'    => 'string',
    402                                                         'default' => 'active',
    403                                                 ),
    404                                                 'linkTitle'     => array(
    405                                                         'type'    => 'boolean',
    406                                                         'default' => false,
    407                                                 ),
    408                                                 'postId'        => array(
    409                                                         'type'    => 'number',
    410                                                         'default' => 0,
    411                                                 ),
    412                                         ),
    413                                         'render_callback'    => 'bp_friends_render_friends_block',
     382                                        'metadata'        => trailingslashit( buddypress()->plugin_dir ) . 'bp-friends/blocks/dynamic-friends',
     383                                        'render_callback' => 'bp_friends_render_friends_block',
    414384                                ),
    415385                        )
Note: See TracChangeset for help on using the changeset viewer.