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

    r13382 r13464  
    9595        // Version 2.7.
    9696        'bp-livestamp' => array( 'file' => "{$url}vendor/livestamp{$min}.js", 'dependencies' => array( 'jquery', 'moment' ), 'footer' => true ),
    97 
    98         // Version 9.0.
    99         'bp-dynamic-widget-block-script' => array( 'file' => "{$url}dynamic-widget-block.js", 'dependencies' => array( 'lodash', 'wp-url' ), 'footer' => true ),
    10097    );
    10198
     
    117114            $scripts['bp-moment-locale'] = array( 'file' => esc_url( $moment_locale_url ), 'dependencies' => array( 'bp-moment' ), 'footer' => true );
    118115        }
     116    }
     117
     118    if ( bp_support_blocks() ) {
     119        $asset      = array(
     120            'dependencies' => array(),
     121            'version'      => ''
     122        );
     123        $asset_path = trailingslashit( dirname( __FILE__ ) ) . 'blocks/dynamic-widget-block/index.asset.php';
     124
     125        if ( file_exists( $asset_path ) ) {
     126            $asset = require $asset_path;
     127        }
     128
     129        $scripts['bp-dynamic-widget-block'] = array(
     130            'file'         => plugins_url( 'blocks/dynamic-widget-block/index.js', __FILE__ ),
     131            'dependencies' => $asset['dependencies'],
     132            'footer'       => true,
     133        );
    119134    }
    120135
Note: See TracChangeset for help on using the changeset viewer.