Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/25/2023 10:17:33 PM (2 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-activity/classes/class-bp-activity-component.php

    r13455 r13464  
    556556     *
    557557     * @since 7.0.0
     558     * @since 12.0.0 Use the WP Blocks API v2.
    558559     *
    559560     * @param array $blocks Optional. See BP_Component::blocks_init() for
     
    563564        $blocks = array(
    564565            'bp/latest-activities' => array(
    565                 'name'               => 'bp/latest-activities',
    566                 'editor_script'      => 'bp-latest-activities-block',
    567                 'editor_script_url'  => plugins_url( 'js/blocks/latest-activities.js', dirname(  __FILE__ ) ),
    568                 'editor_script_deps' => array(
    569                     'wp-blocks',
    570                     'wp-element',
    571                     'wp-components',
    572                     'wp-i18n',
    573                     'wp-block-editor',
    574                     'wp-server-side-render',
    575                     'bp-block-data',
    576                 ),
    577                 'style'              => 'bp-latest-activities-block',
    578                 'style_url'          => plugins_url( 'css/blocks/latest-activities.css', dirname(  __FILE__ ) ),
    579                 'attributes'         => array(
    580                     'title'         => array(
    581                         'type'    => 'string',
    582                         'default' => __( 'Latest updates', 'buddypress' ),
    583                     ),
    584                     'maxActivities' => array(
    585                         'type'    => 'number',
    586                         'default' => 5,
    587                     ),
    588                     'type'          => array(
    589                         'type'    => 'array',
    590                         'default' => array( 'activity_update' ),
    591                     ),
    592                     'postId'        => array(
    593                         'type'    => 'number',
    594                         'default' => 0,
    595                     ),
    596                 ),
    597                 'render_callback'    => 'bp_activity_render_latest_activities_block',
     566                'metadata'        => trailingslashit( buddypress()->plugin_dir ) . 'bp-activity/blocks/latest-activities',
     567                'render_callback' => 'bp_activity_render_latest_activities_block',
    598568            ),
    599569        );
     
    601571        if ( bp_is_active( $this->id, 'embeds' ) ) {
    602572            $blocks['bp/embed-activity'] = array(
    603                 'name'               => 'bp/embed-activity',
    604                 'editor_script'      => 'bp-embed-activity-block',
    605                 'editor_script_url'  => plugins_url( 'js/blocks/embed-activity.js', dirname(  __FILE__ ) ),
    606                 'editor_script_deps' => array(
    607                     'wp-blocks',
    608                     'wp-element',
    609                     'wp-i18n',
    610                     'wp-components',
    611                     'wp-block-editor',
    612                     'wp-data',
    613                     'wp-compose',
    614                     'bp-block-data',
    615                 ),
     573                'metadata' => trailingslashit( buddypress()->plugin_dir ) . 'bp-activity/blocks/embed-activity',
     574
    616575            );
    617576        }
Note: See TracChangeset for help on using the changeset viewer.