mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-17 07:35:44 +03:00
Pledge Management: Add "request link" form to the manage pledge (#126)
When a pledge is selected but the auth token is missing/incorrect, show the email form. Like on the pledge page, submitting the correct email will trigger a new auth token + link to be emailed to the pledge manager. This makes for a clearer path for re-requesting a valid link. Fixes #114
This commit is contained in:
parent
a5d4228c6d
commit
a91c2733d2
8 changed files with 129 additions and 76 deletions
|
@ -327,6 +327,17 @@ function populate_list_table_columns( $column, $post_id ) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check if a post is an active pledge (pending or published).
|
||||
*
|
||||
* @param int $post_id The ID of a post to check.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function is_active_pledge( $post_id ) {
|
||||
return CPT_ID === get_post_type( $post_id ) &&
|
||||
in_array( get_post_status( $post_id ), array( 'pending', 'publish' ), true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new pledge post.
|
||||
|
@ -486,7 +497,7 @@ function has_existing_pledge( $key, $key_type, int $current_pledge_id = 0 ) {
|
|||
function enqueue_assets() {
|
||||
wp_register_script( 'wicg-inert', plugins_url( 'assets/js/inert.min.js', __DIR__ ), array(), '3.0.0', true );
|
||||
|
||||
if ( CPT_ID === get_post_type() ) {
|
||||
if ( CPT_ID === get_post_type() || is_page( 'manage-pledge' ) ) {
|
||||
wp_enqueue_script(
|
||||
'5ftf-dialog',
|
||||
plugins_url( 'assets/js/dialog.js', __DIR__ ),
|
||||
|
@ -496,9 +507,8 @@ function enqueue_assets() {
|
|||
);
|
||||
|
||||
$script_data = array(
|
||||
'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ), // The global ajaxurl is not set on the frontend.
|
||||
'pledgeId' => get_the_ID(),
|
||||
'ajaxNonce' => wp_create_nonce( 'send-manage-email' ),
|
||||
'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ), // The global ajaxurl is not set on the frontend.
|
||||
'ajaxNonce' => wp_create_nonce( 'send-manage-email' ),
|
||||
);
|
||||
wp_add_inline_script(
|
||||
'5ftf-dialog',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue