Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/28/2024 06:19:59 PM (2 years ago)
Author:
imath
Message:

BP Blocks: make sure default block titles can be translated

Some of the BP Blocks are using a title attribute into their block.json. Unfortunately, block attributes do not seem to be include in the translatable strings of the WP Block Metadata API.

To fix this, all block.json title attributes now default to an empty string & the default title value is handled within the PHP callback to render the block.

For the specific case of the Latest Activities block, this commit also fixes some errors that were preventing it to be able to select the list of Activity types to include into the rendered activities.

See #9074 (trunk)
Closes https://github.com/buddypress/buddypress/pull/223

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-blocks.php

    r13709 r13716  
    2727                $attributes,
    2828                array(
    29                         'title'         => __( 'Latest updates', 'buddypress' ),
     29                        'title'         => '',
    3030                        'maxActivities' => 5,
    3131                        'type'          => array( 'activity_update' ),
     
    3535
    3636        $max_activities = (int) $block_args['maxActivities'];
     37
     38        if ( ! $block_args['postId'] ) {
     39                $block_args['postId'] = get_the_ID();
     40        }
     41
     42        if ( ! $block_args['title'] ) {
     43                $block_args['title'] = __( 'Latest updates', 'buddypress' );
     44        }
    3745
    3846        // Should we get a specific member's activities?
     
    8088        );
    8189
     90        add_filter( 'bp_activity_get_types_supporting_generated_content', '__return_empty_array' );
     91
    8292        // Build the activity loop.
    83         if ( bp_is_theme_compat_active() && 'nouveau' === bp_get_theme_compat_id() ) {
     93        if ( function_exists( 'bp_nouveau' ) ) {
    8494                $bp_nouveau = bp_nouveau();
    8595
     
    151161        }
    152162
     163        remove_filter( 'bp_activity_get_types_supporting_generated_content', '__return_empty_array' );
     164
    153165        // Adds a container to make sure the block is styled even when used into the Columns parent block.
    154166        $widget_content = sprintf( '<div class="bp-latest-activities-block">%s</div>', "\n" . $widget_content . "\n" );
Note: See TracChangeset for help on using the changeset viewer.