Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/14/2021 02:42:18 PM (4 years ago)
Author:
imath
Message:

Merge the BP Blocks plugin's 'bp/latest-activities' Block

  • Adapt Grunt sass tasks.
  • Add the Block JavaScript source files into src/js/bp-activity/js/blocks.
  • Add the Block Scss source file into src/bp-activity/sass.
  • Generate the development files to ease testing.
  • Make sure the 'bp/embed-activity' block is only registered if embeds are active for the Activity component.

Fixes #8519

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/classes/class-bp-activity-component.php

    r12996 r13001  
    208208            'global_tables'         => $global_tables,
    209209            'meta_tables'           => $meta_tables,
     210            'block_globals'         => array(
     211                'bp/latest-activities' => array(
     212                    'widget_classnames' => array( 'wp-block-bp-latest-activities', 'buddypress' ),
     213                )
     214            ),
    210215        );
    211216
     
    484489     */
    485490    public function blocks_init( $blocks = array() ) {
    486         parent::blocks_init(
    487             array(
    488                 'bp/embed-activity' => array(
    489                     'name'               => 'bp/embed-activity',
    490                     'editor_script'      => 'bp-embed-activity-block',
    491                     'editor_script_url'  => plugins_url( 'js/blocks/embed-activity.js', dirname(  __FILE__ ) ),
    492                     'editor_script_deps' => array(
    493                         'wp-blocks',
    494                         'wp-element',
    495                         'wp-i18n',
    496                         'wp-components',
    497                         'wp-block-editor',
    498                         'wp-data',
    499                         'wp-compose',
    500                         'bp-block-data',
     491        $blocks = array(
     492            'bp/latest-activities' => array(
     493                'name'               => 'bp/latest-activities',
     494                'editor_script'      => 'bp-latest-activities-block',
     495                'editor_script_url'  => plugins_url( 'js/blocks/latest-activities.js', dirname(  __FILE__ ) ),
     496                'editor_script_deps' => array(
     497                    'wp-blocks',
     498                    'wp-element',
     499                    'wp-components',
     500                    'wp-i18n',
     501                    'wp-block-editor',
     502                    'bp-block-data',
     503                    'bp-block-components',
     504                ),
     505                'style'              => 'bp-latest-activities-block',
     506                'style_url'          => plugins_url( 'css/blocks/latest-activities.css', dirname(  __FILE__ ) ),
     507                'attributes'         => array(
     508                    'title'         => array(
     509                        'type'    => 'string',
     510                        'default' => __( 'Latest updates', 'buddypress' ),
     511                    ),
     512                    'maxActivities' => array(
     513                        'type'    => 'number',
     514                        'default' => 5,
     515                    ),
     516                    'type'          => array(
     517                        'type'    => 'array',
     518                        'default' => array( 'activity_update' ),
     519                    ),
     520                    'postId'        => array(
     521                        'type'    => 'number',
     522                        'default' => 0,
    501523                    ),
    502524                ),
    503             )
    504         );
     525                'render_callback'    => 'bp_activity_render_latest_activities_block',
     526            ),
     527        );
     528
     529        if ( bp_is_active( $this->id, 'embeds' ) ) {
     530            $blocks['bp/embed-activity'] = array(
     531                'name'               => 'bp/embed-activity',
     532                'editor_script'      => 'bp-embed-activity-block',
     533                'editor_script_url'  => plugins_url( 'js/blocks/embed-activity.js', dirname(  __FILE__ ) ),
     534                'editor_script_deps' => array(
     535                    'wp-blocks',
     536                    'wp-element',
     537                    'wp-i18n',
     538                    'wp-components',
     539                    'wp-block-editor',
     540                    'wp-data',
     541                    'wp-compose',
     542                    'bp-block-data',
     543                ),
     544            );
     545        }
     546
     547        parent::blocks_init( $blocks );
    505548    }
    506549}
Note: See TracChangeset for help on using the changeset viewer.