Skip to:
Content

BuddyPress.org


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

    r13455 r13464  
    511511     *
    512512     * @since 9.0.0
     513     * @since 12.0.0 Use the WP Blocks API v2.
    513514     *
    514515     * @param array $blocks Optional. See BP_Component::blocks_init() for
     
    520521        if ( is_multisite() && bp_is_active( 'activity' ) ) {
    521522            $blocks['bp/recent-posts'] = array(
    522                 'name'               => 'bp/recent-posts',
    523                 'editor_script'      => 'bp-recent-posts-block',
    524                 'editor_script_url'  => plugins_url( 'js/blocks/recent-posts.js', dirname( __FILE__ ) ),
    525                 'editor_script_deps' => array(
    526                     'wp-blocks',
    527                     'wp-element',
    528                     'wp-components',
    529                     'wp-i18n',
    530                     'wp-block-editor',
    531                     'wp-server-side-render',
    532                 ),
    533                 'style'              => 'bp-recent-posts-block',
    534                 'style_url'          => plugins_url( 'css/blocks/recent-posts.css', dirname( __FILE__ ) ),
    535                 'attributes'         => array(
    536                     'title'     => array(
    537                         'type'    => 'string',
    538                         'default' => __( 'Recent Networkwide Posts', 'buddypress' ),
    539                     ),
    540                     'maxPosts'  => array(
    541                         'type'    => 'number',
    542                         'default' => 10,
    543                     ),
    544                     'linkTitle' => array(
    545                         'type'    => 'boolean',
    546                         'default' => false,
    547                     ),
    548                 ),
    549                 'render_callback'    => 'bp_blogs_render_recent_posts_block',
     523                'metadata'        => trailingslashit( buddypress()->plugin_dir ) . 'bp-blogs/blocks/recent-posts',
     524                'render_callback' => 'bp_blogs_render_recent_posts_block',
    550525            );
    551526        }
Note: See TracChangeset for help on using the changeset viewer.