mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-04 10:05:43 +03:00
Use JS + AJAX to resend the confirmation email
This commit is contained in:
parent
7dbc725581
commit
d5c740ae84
5 changed files with 88 additions and 11 deletions
35
plugins/wporg-5ftf/includes/endpoints.php
Normal file
35
plugins/wporg-5ftf/includes/endpoints.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/**
|
||||
* Handle submissions to admin-ajax.php.
|
||||
*/
|
||||
|
||||
namespace WordPressDotOrg\FiveForTheFuture\Endpoints;
|
||||
|
||||
use WordPressDotOrg\FiveForTheFuture\{ Contributor, PledgeForm };
|
||||
|
||||
add_action( 'wp_ajax_manage_contributors', __NAMESPACE__ . '\handler' );
|
||||
|
||||
/**
|
||||
* Handle the AJAX request.
|
||||
*/
|
||||
function handler() {
|
||||
check_ajax_referer( 'manage-pledge', '_ajax_nonce' );
|
||||
|
||||
$action = filter_input( INPUT_POST, 'manage_action' );
|
||||
$pledge_id = filter_input( INPUT_POST, 'pledge_id', FILTER_VALIDATE_INT );
|
||||
$contributor_id = filter_input( INPUT_POST, 'contributor_id', FILTER_VALIDATE_INT );
|
||||
|
||||
switch ( $action ) {
|
||||
case 'resend-contributor-confirmation':
|
||||
$contribution = get_post( $contributor_id );
|
||||
PledgeForm\send_contributor_confirmation_emails( $pledge_id, $contributor_id );
|
||||
wp_die( wp_json_encode( [
|
||||
'success' => true,
|
||||
'message' => sprintf( __( 'Confirmation email sent to %s.', 'wporg-5ftf' ), $contribution->post_title ),
|
||||
] ) );
|
||||
break;
|
||||
}
|
||||
|
||||
// No matching action, we can just exit.
|
||||
wp_die();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue