mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-04-24 20:03:44 +03:00

This adds the ability to deactivate/reactivate pledges from the wp-admin list table. Once deactivated, the pledge is removed from the "published" list, as if it were trashed. It is not rendered in the frontend pledge list either. You can still access the edit screen, but no edits can be made (saving the pledge is disabled by JS, as otherwise it would reactivate itself). This way we can remove a pledge, but still see the activity log. Fixes #112
112 lines
3.4 KiB
PHP
112 lines
3.4 KiB
PHP
<?php
|
|
namespace WordPressDotOrg\FiveForTheFuture\View;
|
|
|
|
use function WordPressDotOrg\FiveForTheFuture\get_views_path;
|
|
|
|
/** @var array $contributors */
|
|
/** @var int $pledge_id */
|
|
/** @var bool $readonly */
|
|
?>
|
|
<script type="text/template" id="tmpl-5ftf-contributor-lists">
|
|
<# if ( data.publish.length ) { #>
|
|
<h3 class="contributor-list-heading"><?php esc_html_e( 'Confirmed', 'wporg-5ftf' ); ?></h3>
|
|
<table class="contributor-list publish striped widefat">
|
|
<thead>
|
|
<th scope="col"><?php esc_html_e( 'Contributor', 'wporg-5ftf' ); ?></th>
|
|
<th scope="col"><?php esc_html_e( 'Date Confirmed', 'wporg-5ftf' ); ?></th>
|
|
<?php if ( ! $readonly ) : ?>
|
|
<th scope="col"><?php esc_html_e( 'Remove Contributor', 'wporg-5ftf' ); ?></th>
|
|
<?php endif; ?>
|
|
</thead>
|
|
<tbody>{{{ data.publish }}}</tbody>
|
|
</table>
|
|
<# } #>
|
|
<# if ( data.pending.length ) { #>
|
|
<h3 class="contributor-list-heading"><?php esc_html_e( 'Unconfirmed', 'wporg-5ftf' ); ?></h3>
|
|
<table class="contributor-list pending striped widefat">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col"><?php esc_html_e( 'Contributor', 'wporg-5ftf' ); ?></th>
|
|
<th scope="col" class="resend-confirm"><?php esc_html_e( 'Resend Confirmation', 'wporg-5ftf' ); ?></th>
|
|
<?php if ( ! $readonly ) : ?>
|
|
<th scope="col"><?php esc_html_e( 'Remove Contributor', 'wporg-5ftf' ); ?></th>
|
|
<?php endif; ?>
|
|
</tr>
|
|
</thead>
|
|
<tbody>{{{ data.pending }}}</tbody>
|
|
</table>
|
|
<# } #>
|
|
<# if ( ! data.publish.length && ! data.pending.length ) { #>
|
|
<p><?php esc_html_e( 'There are no contributors added to this pledge yet.', 'wporg-5ftf' ); ?></p>
|
|
<# } #>
|
|
</script>
|
|
|
|
<script type="text/template" id="tmpl-5ftf-contributor">
|
|
<tr>
|
|
<th scope="row">
|
|
{{{ data.avatar }}}
|
|
<span class="contributor-list__name">
|
|
{{ data.displayName }} ({{ data.name }})
|
|
</span>
|
|
</th>
|
|
<# if ( 'pending' === data.status ) { #>
|
|
<td class="resend-confirm">
|
|
<button
|
|
class="button"
|
|
data-action="resend-contributor-confirmation"
|
|
data-contributor-post="{{ data.contributorId }}"
|
|
>
|
|
{{ data.resendLabel }}
|
|
</button>
|
|
</td>
|
|
<# } else { #>
|
|
<td>{{ data.publishDate }}</td>
|
|
<# } #>
|
|
<?php if ( ! $readonly ) : ?>
|
|
<td>
|
|
<button
|
|
class="button-link button-link-delete"
|
|
data-action="remove-contributor"
|
|
data-contributor-post="{{ data.contributorId }}"
|
|
data-confirm="{{ data.removeConfirm }}"
|
|
aria-label="{{ data.removeLabel }}"
|
|
>
|
|
<span class="dashicons dashicons-no-alt" aria-hidden="true"></span>
|
|
<?php esc_html_e( 'Remove', 'wporg-5ftf' ); ?>
|
|
</button>
|
|
</td>
|
|
<?php endif; ?>
|
|
</tr>
|
|
</script>
|
|
|
|
<div id="5ftf-contributors">
|
|
<div class="pledge-contributors pledge-status__<?php echo esc_attr( get_post_status( $pledge_id ) ); ?>">
|
|
<?php if ( ! empty( $contributors ) ) : ?>
|
|
<?php
|
|
printf(
|
|
'<script>var fftfContributors = JSON.parse( decodeURIComponent( \'%s\' ) );</script>',
|
|
rawurlencode( wp_json_encode( $contributors ) )
|
|
);
|
|
?>
|
|
<?php else : ?>
|
|
<p><?php esc_html_e( 'There are no contributors added to this pledge yet.', 'wporg-5ftf' ); ?></p>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php
|
|
if ( ! $readonly ) :
|
|
$data = [ 'pledge-contributors' => '' ];
|
|
require get_views_path() . 'inputs-pledge-contributors.php';
|
|
?>
|
|
|
|
<div id="add-contrib-message" role="alert" aria-atomic="true"></div>
|
|
|
|
<button
|
|
class="button-primary"
|
|
data-action="add-contributor"
|
|
>
|
|
<?php esc_html_e( 'Add new contributors', 'wporg-5ftf' ); ?>
|
|
</button>
|
|
<?php endif; ?>
|
|
</div>
|