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-messages/classes/class-bp-messages-component.php

    r13450 r13464  
    486486         *
    487487         * @since 9.0.0
     488         * @since 12.0.0 Use the WP Blocks API v2.
    488489         *
    489490         * @param array $blocks Optional. See BP_Component::blocks_init() for
    … …  
    494495                        array(
    495496                                'bp/sitewide-notices' => array(
    496                                         'name'               => 'bp/sitewide-notices',
    497                                         'editor_script'      => 'bp-sitewide-notices-block',
    498                                         'editor_script_url'  => plugins_url( 'js/blocks/sitewide-notices.js', dirname( __FILE__ ) ),
    499                                         'editor_script_deps' => array(
    500                                                 'wp-blocks',
    501                                                 'wp-element',
    502                                                 'wp-components',
    503                                                 'wp-i18n',
    504                                                 'wp-block-editor',
    505                                                 'wp-server-side-render',
    506                                                 'bp-block-data',
    507                                         ),
    508                                         'style'              => 'bp-sitewide-notices-block',
    509                                         'style_url'          => plugins_url( 'css/blocks/sitewide-notices.css', dirname( __FILE__ ) ),
    510                                         'attributes'         => array(
    511                                                 'title' => array(
    512                                                         'type'    => 'string',
    513                                                         'default' => '',
    514                                                 ),
    515                                         ),
    516                                         'render_callback'    => 'bp_messages_render_sitewide_notices_block',
     497                                        'metadata'        => trailingslashit( buddypress()->plugin_dir ) . 'bp-messages/blocks/sitewide-notices',
     498                                        'render_callback' => 'bp_messages_render_sitewide_notices_block',
    517499                                ),
    518500                        )
Note: See TracChangeset for help on using the changeset viewer.