Block binding: Add value for displaying short contribution details

This commit is contained in:
Kelly Dwan 2024-08-29 16:57:45 -04:00
parent f2e80b8d07
commit 0e5b8788eb
No known key found for this signature in database
GPG key ID: 8BA5575F3D11575D
2 changed files with 8 additions and 2 deletions

View file

@ -59,5 +59,11 @@ function get_meta_binding_value( $args, $block ) {
number_format_i18n( absint( $contribution_data['hours'] ) ),
count( $contribution_data['teams'] )
);
case 'org-contribution-short-details':
$contribution_data = get_aggregate_contributor_data_for_pledge( $block->context['postId'] );
return sprintf(
__( 'Has pledged %s hours per week.', 'wporg-5ftf' ),
number_format_i18n( absint( $contribution_data['hours'] ) ),
);
}
}

View file

@ -65,8 +65,8 @@ if ( is_search() ) {
<div class="wp-block-group">
<!-- wp:post-title {"isLink":true,"fontSize":"heading-3"} /-->
<!-- wp:paragraph -->
<p>Has pledged…</p>
<!-- wp:paragraph {"style":{"elements":{"link":{"color":{"text":"var:preset|color|charcoal-4"}}}},"textColor":"charcoal-4","metadata":{"bindings":{"content":{"source":"wporg-5ftf/pledge-meta","args":{"key":"org-contribution-short-details"}}}}} -->
<p class="has-charcoal-4-color has-text-color has-link-color"></p>
<!-- /wp:paragraph -->
<!-- wp:post-excerpt {"moreText":"[MORE]","showMoreOnNewLine":false,"excerptLength":50} /-->