'Pledge meta', 'uses_context' => [ 'postId' ], 'get_value_callback' => __NAMESPACE__ . '\get_meta_binding_value', ) ); } /** * Callback to provide the binding value. */ function get_meta_binding_value( $args, $block ) { if ( ! isset( $args['key'] ) ) { return ''; } $data = get_pledge_meta( $block->context['postId'] ); if ( empty( $data ) ) { return ''; } switch ( $args['key'] ) { case 'org-url-link': return sprintf( '%s', esc_url( $data['org-url'] ), esc_html( $data['org-domain'] ) ); case 'org-contribution-details': $contribution_data = get_aggregate_contributor_data_for_pledge( $block->context['postId'] ); return sprintf( __( '%1$s sponsors %2$s for a total of %3$s hours per week across %4$d teams.', 'wporg-5ftf' ), get_the_title( $block->context['postId'] ), sprintf( _n( '%d contributor', '%d contributors', $contribution_data['contributors'], 'wporg-5ftf' ), number_format_i18n( absint( $contribution_data['contributors'] ) ) ), 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'] ) ), ); } }