Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/25/2023 10:17:33 PM (20 months 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-templates/bp-nouveau/includes/functions.php

    r13364 r13464  
    15051505 *
    15061506 * @since 9.0.0
     1507 * @since 12.0.0 Use the WP Blocks API v2.
    15071508 *
    15081509 * @param array $blocks The Core Blocks list.
     
    15101511 */
    15111512function bp_nouveau_register_primary_nav_widget_block( $blocks = array() ) {
    1512     $editor_style = bp_locate_template_asset( 'css/primary-nav.css' );
    1513 
    15141513    $blocks['bp/primary-nav'] = array(
    1515         'name'               => 'bp/primary-nav',
    1516         'editor_script'      => 'bp-primary-nav-block',
    1517         'editor_script_url'  => trailingslashit( buddypress()->plugin_url . 'bp-core' ) . 'js/blocks/primary-nav.js',
    1518         'editor_script_deps' => array(
    1519             'wp-blocks',
    1520             'wp-element',
    1521             'wp-components',
    1522             'wp-i18n',
    1523             'wp-block-editor',
    1524             'wp-server-side-render',
    1525             'bp-block-data',
    1526         ),
    1527         'editor_style'       => 'bp-primary-nav-block',
    1528         'editor_style_url'   => $editor_style['uri'],
    1529         'attributes'         => array(
    1530             'displayTitle' => array(
    1531                 'type'    => 'boolean',
    1532                 'default' => true,
    1533             ),
    1534         ),
    1535         'render_callback'    => 'bp_nouveau_render_primary_nav_block',
     1514        'metadata'        => trailingslashit( buddypress()->plugin_dir ) . 'bp-core/blocks/primary-nav',
     1515        'render_callback' => 'bp_nouveau_render_primary_nav_block',
    15361516    );
    15371517
Note: See TracChangeset for help on using the changeset viewer.