diff --git a/plugins/wporg-5ftf/assets/js/admin.js b/plugins/wporg-5ftf/assets/js/admin.js index f4822dd..c2d961e 100644 --- a/plugins/wporg-5ftf/assets/js/admin.js +++ b/plugins/wporg-5ftf/assets/js/admin.js @@ -1,4 +1,4 @@ -/* global ajaxurl, FiveForTheFuture, fftfContributors, jQuery */ +/* global FiveForTheFuture, fftfContributors, jQuery */ /* eslint no-alert: "off" */ jQuery( document ).ready( function( $ ) { let ajaxurl = window.ajaxurl; @@ -153,4 +153,10 @@ jQuery( document ).ready( function( $ ) { _addContributors(); } } ); + + $( '#5ftf-pledge-remove' ).on( 'click', function( event ) { + if ( ! confirm( FiveForTheFuture.removePrompt ) ) { + event.preventDefault(); + } + } ); } ); diff --git a/plugins/wporg-5ftf/includes/pledge-meta.php b/plugins/wporg-5ftf/includes/pledge-meta.php index 10248da..3a5f272 100755 --- a/plugins/wporg-5ftf/includes/pledge-meta.php +++ b/plugins/wporg-5ftf/includes/pledge-meta.php @@ -549,13 +549,14 @@ function enqueue_assets() { $pledge_id = is_admin() ? get_the_ID() : absint( $_REQUEST['pledge_id'] ?? 0 ); $auth_token = sanitize_text_field( $_REQUEST['auth_token'] ?? '' ); - $script_data = [ + $script_data = array( // The global ajaxurl is not set on the frontend. 'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ), 'pledgeId' => $pledge_id, 'manageNonce' => wp_create_nonce( 'manage-contributors' ), 'authToken' => $auth_token, - ]; + 'removePrompt' => __( 'Are you sure you want to remove this pledge?', 'wporg-5ftf' ), + ); wp_add_inline_script( '5ftf-admin', sprintf( diff --git a/plugins/wporg-5ftf/views/form-pledge-manage.php b/plugins/wporg-5ftf/views/form-pledge-manage.php index ba4a3ac..f7cdb16 100644 --- a/plugins/wporg-5ftf/views/form-pledge-manage.php +++ b/plugins/wporg-5ftf/views/form-pledge-manage.php @@ -42,4 +42,6 @@ require __DIR__ . '/partial-result-messages.php'; + + diff --git a/plugins/wporg-5ftf/views/form-pledge-remove.php b/plugins/wporg-5ftf/views/form-pledge-remove.php new file mode 100644 index 0000000..0ef1b4c --- /dev/null +++ b/plugins/wporg-5ftf/views/form-pledge-remove.php @@ -0,0 +1,31 @@ + + +