mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-04 18:05:45 +03:00
Add a "remove pledge" action
This commit is contained in:
parent
fa8bb48ad6
commit
fedfface23
5 changed files with 45 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* global ajaxurl, FiveForTheFuture, fftfContributors, jQuery */
|
/* global FiveForTheFuture, fftfContributors, jQuery */
|
||||||
/* eslint no-alert: "off" */
|
/* eslint no-alert: "off" */
|
||||||
jQuery( document ).ready( function( $ ) {
|
jQuery( document ).ready( function( $ ) {
|
||||||
let ajaxurl = window.ajaxurl;
|
let ajaxurl = window.ajaxurl;
|
||||||
|
@ -153,4 +153,10 @@ jQuery( document ).ready( function( $ ) {
|
||||||
_addContributors();
|
_addContributors();
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
$( '#5ftf-pledge-remove' ).on( 'click', function( event ) {
|
||||||
|
if ( ! confirm( FiveForTheFuture.removePrompt ) ) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -549,13 +549,14 @@ function enqueue_assets() {
|
||||||
|
|
||||||
$pledge_id = is_admin() ? get_the_ID() : absint( $_REQUEST['pledge_id'] ?? 0 );
|
$pledge_id = is_admin() ? get_the_ID() : absint( $_REQUEST['pledge_id'] ?? 0 );
|
||||||
$auth_token = sanitize_text_field( $_REQUEST['auth_token'] ?? '' );
|
$auth_token = sanitize_text_field( $_REQUEST['auth_token'] ?? '' );
|
||||||
$script_data = [
|
$script_data = array(
|
||||||
// The global ajaxurl is not set on the frontend.
|
// The global ajaxurl is not set on the frontend.
|
||||||
'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ),
|
'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ),
|
||||||
'pledgeId' => $pledge_id,
|
'pledgeId' => $pledge_id,
|
||||||
'manageNonce' => wp_create_nonce( 'manage-contributors' ),
|
'manageNonce' => wp_create_nonce( 'manage-contributors' ),
|
||||||
'authToken' => $auth_token,
|
'authToken' => $auth_token,
|
||||||
];
|
'removePrompt' => __( 'Are you sure you want to remove this pledge?', 'wporg-5ftf' ),
|
||||||
|
);
|
||||||
wp_add_inline_script(
|
wp_add_inline_script(
|
||||||
'5ftf-admin',
|
'5ftf-admin',
|
||||||
sprintf(
|
sprintf(
|
||||||
|
|
|
@ -42,4 +42,6 @@ require __DIR__ . '/partial-result-messages.php';
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<?php require get_views_path() . 'form-pledge-remove.php'; ?>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
31
plugins/wporg-5ftf/views/form-pledge-remove.php
Normal file
31
plugins/wporg-5ftf/views/form-pledge-remove.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace WordPressDotOrg\FiveForTheFuture\View;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool $can_view_form
|
||||||
|
* @var int $pledge_id
|
||||||
|
* @var string $auth_token
|
||||||
|
*/
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<form class="pledge-form" id="5ftf-form-pledge-remove" action="" method="post">
|
||||||
|
<h2><?php esc_html_e( 'Remove Pledge', 'wporg-5ftf' ); ?></h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?php esc_html_e( 'This will remove your pledge from the Five for the Future listing. You will not be able to reactivate it or submit a new pledge for this company.', 'wporg-5ftf' ); ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?php wp_nonce_field( 'remove_pledge_' . $pledge_id ); ?>
|
||||||
|
<input type="hidden" name="action" value="remove-pledge" />
|
||||||
|
<input type="hidden" name="auth_token" value="<?php echo esc_attr( $auth_token ); ?>" />
|
||||||
|
<input type="hidden" name="pledge_id" value="<?php echo absint( $pledge_id ); ?>" />
|
||||||
|
<button type="submit" class="button button-danger" id="5ftf-pledge-remove">
|
||||||
|
<?php esc_html_e( 'Remove Pledge', 'wporg-5ftf' ); ?>
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
</form>
|
|
@ -29,7 +29,8 @@
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
[id*="help"] p {
|
[id*="help"] p,
|
||||||
|
p[id*="help"] {
|
||||||
margin-top: ms(-5);
|
margin-top: ms(-5);
|
||||||
font-size: ms(-2);
|
font-size: ms(-2);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue