diff --git a/themes/wporg-5ftf-2024/patterns/archive-5ftf-pledge.php b/themes/wporg-5ftf-2024/patterns/archive-5ftf-pledge.php index b5445a1..fad1274 100644 --- a/themes/wporg-5ftf-2024/patterns/archive-5ftf-pledge.php +++ b/themes/wporg-5ftf-2024/patterns/archive-5ftf-pledge.php @@ -73,9 +73,7 @@ if ( is_search() ) { - -
small avatar list
- + diff --git a/themes/wporg-5ftf-2024/src/pledge-contributors/index.php b/themes/wporg-5ftf-2024/src/pledge-contributors/index.php index 5faf42f..f56bf57 100644 --- a/themes/wporg-5ftf-2024/src/pledge-contributors/index.php +++ b/themes/wporg-5ftf-2024/src/pledge-contributors/index.php @@ -7,6 +7,7 @@ */ namespace WordPressdotorg\Theme\FiveForTheFuture_2024\Pledge_Contributors; +const TRUNCATED_MAX = 15; defined( 'WPINC' ) || die(); @@ -17,4 +18,11 @@ add_action( 'init', __NAMESPACE__ . '\init' ); */ function init() { register_block_type( dirname( __DIR__, 2 ) . '/build/pledge-contributors' ); + register_block_style( + 'wporg/pledge-contributors', + array( + 'name' => 'truncated', + 'label' => _x( 'Truncated', 'block style name', 'wporg-5ftf' ), + ) + ); } diff --git a/themes/wporg-5ftf-2024/src/pledge-contributors/render.php b/themes/wporg-5ftf-2024/src/pledge-contributors/render.php index 576a6fb..7b6e7a6 100644 --- a/themes/wporg-5ftf-2024/src/pledge-contributors/render.php +++ b/themes/wporg-5ftf-2024/src/pledge-contributors/render.php @@ -1,6 +1,7 @@ context['postId'] ) { return ''; @@ -10,6 +11,16 @@ $contributors = Contributor\get_contributor_user_objects( Contributor\get_pledge_contributors( $block->context['postId'], 'publish' ) ); +$is_truncated = isset( $attributes['className'] ) && str_contains( $attributes['className'], 'is-style-truncated' ); + +// Initialize count to zero for untruncated view. +$count_more = 0; + +if ( $is_truncated ) { + $count_more = count( $contributors ) - TRUNCATED_MAX; + $contributors = array_splice( $contributors, 0, TRUNCATED_MAX ); +} + ?>