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-groups/bp-groups-cssjs.php

    r13140 r13464  
    6666 *
    6767 * @since 9.0.0
     68 * @since 12.0.0 Uses the `@wordpress/scripts` `index.asset.php` generated file to get dependencies.
    6869 *
    6970 * @param array $scripts Data about the scripts to register.
     
    7172 */
    7273function bp_groups_register_widget_block_scripts( $scripts = array() ) {
     74        if ( ! bp_support_blocks() ) {
     75                return $scripts;
     76        }
     77
     78        $asset      = array(
     79                'dependencies' => array(),
     80                'version'      => ''
     81        );
     82        $asset_path = trailingslashit( dirname( __FILE__ ) ) . 'blocks/dynamic-widget/index.asset.php';
     83
     84        if ( file_exists( $asset_path ) ) {
     85                $asset = require $asset_path;
     86        }
     87
    7388        $scripts['bp-dynamic-groups-script'] = array(
    74                 'file'         => plugins_url( 'js/dynamic-groups.js', __FILE__ ),
    75                 'dependencies' => array(
    76                         'bp-dynamic-widget-block-script',
    77                         'wp-i18n',
    78                 ),
     89                'file'         => plugins_url( 'blocks/dynamic-widget/index.js', __FILE__ ),
     90                'dependencies' => $asset['dependencies'],
    7991                'footer'       => true,
    8092        );
Note: See TracChangeset for help on using the changeset viewer.