mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-14 06:15:46 +03:00
Build: 7dc7e421ae
This commit is contained in:
parent
7dc7e421ae
commit
5f016b5491
34 changed files with 891 additions and 12 deletions
50
themes/wporg-5ftf-2024/build/pledge-contributors/render.php
Normal file
50
themes/wporg-5ftf-2024/build/pledge-contributors/render.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
use WordPressDotOrg\FiveForTheFuture\Contributor;
|
||||
use const WordPressdotorg\Theme\FiveForTheFuture_2024\Pledge_Contributors\TRUNCATED_MAX;
|
||||
|
||||
if ( ! $block->context['postId'] ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$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;
|
||||
|
||||
// Set avatar size at smallest usage in px.
|
||||
$avatar_size = 70;
|
||||
|
||||
if ( $is_truncated ) {
|
||||
$count_more = count( $contributors ) - TRUNCATED_MAX;
|
||||
$contributors = array_splice( $contributors, 0, TRUNCATED_MAX );
|
||||
$avatar_size = 30;
|
||||
}
|
||||
|
||||
?>
|
||||
<div
|
||||
<?php echo get_block_wrapper_attributes(); // phpcs:ignore ?>
|
||||
>
|
||||
<?php if ( ! empty( $contributors ) ) : ?>
|
||||
<ul class="pledge-contributors">
|
||||
<?php foreach ( $contributors as $contributor ) : ?>
|
||||
<li class="pledge-contributor">
|
||||
<span class="pledge-contributor__avatar">
|
||||
<a href="<?php echo esc_url( 'https://profiles.wordpress.org/' . $contributor->user_nicename . '/' ); ?>">
|
||||
<?php echo get_avatar( $contributor->user_email, $avatar_size, 'mystery', $contributor->display_name ); ?>
|
||||
</a>
|
||||
</span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php if ( $count_more > 0 ) : ?>
|
||||
<li class="pledge-contributors__more"><?php echo '+' . esc_html( $count_more ); ?></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
<?php else : ?>
|
||||
<p class="pledge-no-contributors"><?php esc_html_e( 'No confirmed contributors yet.', 'wporg-5ftf' ); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue