mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-04-21 02:23:43 +03:00

Contributors associated with pledges have a state: they can be confirmed or unconfirmed. They also have some important meta data, namely when they were confirmed. Thus, managing contributor data for pledges is more robust if we treat them as their own post type instead of as a multidimensional array of post meta data. This also reorganizes some of the functions related to pledges so that things are more consistent between the pledge CPT and the contributior CPT. Fixes #11
77 lines
2.2 KiB
PHP
77 lines
2.2 KiB
PHP
<?php
|
|
namespace WordPressDotOrg\FiveForTheFuture\View;
|
|
|
|
/** @var array $contributors */
|
|
/** @var array $data */
|
|
/** @var bool $readonly */
|
|
?>
|
|
|
|
<?php if ( empty( $contributors ) ) : ?>
|
|
|
|
<div class="form-field">
|
|
<label for="5ftf-pledge-contributors">
|
|
<?php esc_html_e( 'Contributors', 'wordpressorg' ); ?>
|
|
</label>
|
|
<input
|
|
type="text"
|
|
id="5ftf-pledge-contributors"
|
|
name="pledge-contributors"
|
|
value="<?php echo esc_attr( $data['pledge-contributors'] ); ?>"
|
|
required
|
|
aria-describedby="5ftf-pledge-contributors-help"
|
|
/>
|
|
<p id="5ftf-pledge-contributors-help">
|
|
<?php esc_html_e( 'Separate each username with a comma.', 'wordpressorg' ); ?>
|
|
</p>
|
|
</div>
|
|
|
|
<?php else : ?>
|
|
|
|
<div class="5ftf-contributors">
|
|
<?php foreach ( $contributors as $status => $group ) : ?>
|
|
<?php if ( ! empty( $group ) ) : ?>
|
|
<h3 class="contributor-list-heading">
|
|
<?php
|
|
switch ( $status ) {
|
|
case 'pending':
|
|
esc_html_e( 'Unconfirmed', 'wporg' );
|
|
break;
|
|
case 'publish':
|
|
esc_html_e( 'Confirmed', 'wporg' );
|
|
break;
|
|
}
|
|
?>
|
|
</h3>
|
|
|
|
<ul class="contributor-list <?php echo esc_attr( $status ); ?>">
|
|
<?php foreach ( $group as $contributor_post ) :
|
|
$contributor = get_user_by( 'login', $contributor_post->post_title );
|
|
?>
|
|
<li>
|
|
<?php echo get_avatar( $contributor->user_email, 32 ); ?>
|
|
<?php echo $contributor_post->post_title; ?>
|
|
<!-- TODO These buttons don't do anything yet.
|
|
<button class="button-primary" data-action="remove" data-contributor-post="<?php echo esc_attr( $contributor_post->ID ); ?>">
|
|
<?php esc_html_e( 'Remove', 'wporg' ); ?>
|
|
</button>
|
|
<?php if ( 'pending' === $contributor_post->post_status ) : ?>
|
|
<button class="button-secondary" data-action="resend-confirmation" data-contributor-post="<?php echo esc_attr( $contributor_post->ID ); ?>">
|
|
<?php esc_html_e( 'Resend confirmation', 'wporg' ); ?>
|
|
</button>
|
|
<?php endif; ?>
|
|
-->
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
<?php endif; ?>
|
|
<?php endforeach; ?>
|
|
|
|
<!-- TODO This button doesn't do anything yet.
|
|
<button class="button-primary" data-action="add-contributor">
|
|
<?php esc_html_e( 'Add new contributor', 'wporg' ); ?>
|
|
</button>
|
|
-->
|
|
</div>
|
|
|
|
<?php endif; ?>
|