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

    r13105 r13464  
    1515 *
    1616 * @since 9.0.0
     17 * @since 12.0.0 Uses the `@wordpress/scripts` `index.asset.php` generated file to get dependencies.
    1718 *
    1819 * @param array $scripts Data about the scripts to register.
     
    2021 */
    2122function bp_members_register_scripts( $scripts = array() ) {
     23        if ( ! bp_support_blocks() ) {
     24                return $scripts;
     25        }
     26
     27        $asset      = array(
     28                'dependencies' => array(),
     29                'version'      => ''
     30        );
     31        $asset_path = trailingslashit( dirname( __FILE__ ) ) . 'blocks/dynamic-widget/index.asset.php';
     32
     33        if ( file_exists( $asset_path ) ) {
     34                $asset = require $asset_path;
     35        }
     36
    2237        $scripts['bp-dynamic-members-script'] = array(
     38                'file'         => plugins_url( 'blocks/dynamic-widget/index.js', __FILE__ ),
     39                'dependencies' => $asset['dependencies'],
    2340                'footer'       => true,
    24                 'file'         => plugins_url( 'js/dynamic-members.js', __FILE__ ),
    25                 'dependencies' => array(
    26                         'bp-dynamic-widget-block-script',
    27                         'wp-i18n',
    28                 ),
    2941        );
    3042
Note: See TracChangeset for help on using the changeset viewer.