Pledge List: Show hours because it's a more meaningful statistic.

This commit is contained in:
Ian Dunn 2019-10-31 16:23:57 -05:00
parent 7273057950
commit 33d3bc1933
No known key found for this signature in database
GPG key ID: 99B971B50343CBCB
5 changed files with 28 additions and 18 deletions

View file

@ -37,8 +37,8 @@ get_header(); ?>
<option value="alphabetical" <?php selected( $pledge_order, 'alphabetical' ); ?>>
<?php esc_html_e( 'Alphabetical', 'wordpressorg' ); ?>
</option>
<option value="contributors" <?php selected( $pledge_order, 'contributors' ); ?>>
<?php esc_html_e( 'Total Contributors', 'wordpressorg' ); ?>
<option value="hours" <?php selected( $pledge_order, 'hours' ); ?>>
<?php esc_html_e( 'Total Hours', 'wordpressorg' ); ?>
</option>
</select>
<span class="screen-reader-text">

View file

@ -5,9 +5,9 @@
namespace WordPressdotorg\Five_for_the_Future\Theme;
use WordPressDotOrg\FiveForTheFuture\Contributor;
use WordPressDotOrg\FiveForTheFuture\PledgeMeta;
use WordPressDotOrg\FiveForTheFuture\{Contributor, PledgeMeta };
$pledge = get_post();
$data = array();
foreach ( PledgeMeta\get_pledge_meta_config() as $key => $config ) {
@ -15,7 +15,6 @@ foreach ( PledgeMeta\get_pledge_meta_config() as $key => $config ) {
}
$contributors = Contributor\get_pledge_contributors( get_the_ID() );
$count = count( $contributors );
$allowed_html = array_merge(
wp_kses_allowed_html( 'data' ),
@ -36,12 +35,14 @@ $content = apply_filters( 'the_content', $data['org-description'] );
$content = strip_tags( $content );
$content = wp_trim_words( $content, 55, $more );
$total_hours = $pledge->{ PledgeMeta\META_PREFIX . 'pledge-total-hours' };
$contributor_title = sprintf(
esc_html(
_n( '%1$s has pledged %2$d contributor', '%1$s has pledged %2$d contributors', $count, 'wordpressorg' )
_n( '%1$s has pledged %2$d hour', '%1$s has pledged %2$d hours', $total_hours, 'wordpressorg' )
),
wp_kses_post( get_the_title() ),
intval( $count )
intval( $total_hours )
);
?>