From fedfface23fce73e70825361c9726f2d55de0805 Mon Sep 17 00:00:00 2001 From: Kelly Dwan Date: Fri, 6 Dec 2019 16:48:54 -0500 Subject: [PATCH] Add a "remove pledge" action --- plugins/wporg-5ftf/assets/js/admin.js | 8 ++++- plugins/wporg-5ftf/includes/pledge-meta.php | 5 +-- .../wporg-5ftf/views/form-pledge-manage.php | 2 ++ .../wporg-5ftf/views/form-pledge-remove.php | 31 +++++++++++++++++++ .../wporg-5ftf/css/objects/_pledge-form.scss | 3 +- 5 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 plugins/wporg-5ftf/views/form-pledge-remove.php 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 @@ + + +
+ +
+

+ +

+ +

+ +

+ + + + + +

+
diff --git a/themes/wporg-5ftf/css/objects/_pledge-form.scss b/themes/wporg-5ftf/css/objects/_pledge-form.scss index 19b1b85..d0a098f 100644 --- a/themes/wporg-5ftf/css/objects/_pledge-form.scss +++ b/themes/wporg-5ftf/css/objects/_pledge-form.scss @@ -29,7 +29,8 @@ height: auto; } - [id*="help"] p { + [id*="help"] p, + p[id*="help"] { margin-top: ms(-5); font-size: ms(-2); }