Skip to content

Commit

Permalink
fix: add donation form nonce field
Browse files Browse the repository at this point in the history
  • Loading branch information
chickenn00dle committed Dec 19, 2024
1 parent 4f3f653 commit 7348e15
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion includes/class-modal-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class Modal_Checkout {
*
* @var string
*/
const CHECKOUT_NONCE = 'newspack_modal_checkout_nonce';
const CHECKOUT_NONCE = 'newspack_checkout_nonce';

/**
* Checkout registration flag.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

defined( 'ABSPATH' ) || exit;

use Newspack_Blocks\Modal_Checkout;

/**
* Handles the Donate block rendering functionality.
*/
Expand Down Expand Up @@ -202,6 +204,8 @@ protected static function render_hidden_form_inputs( $attributes ) {
<input type='hidden' name='donation_currency' value='<?php echo esc_attr( $currency ); ?>' />
<input type='hidden' name='frequency_ids' value='<?php echo esc_attr( wp_json_encode( $donate_child_ids ) ); ?>' />
<?php
// Add nonce for the donation form.
wp_nonce_field( Modal_Checkout::CHECKOUT_NONCE );

foreach ( [ [ 'afterSuccessBehavior', 'after_success_behavior' ], [ 'afterSuccessButtonLabel', 'after_success_button_label' ], [ 'afterSuccessURL', 'after_success_url' ] ] as $attribute ) {
$attribute_name = $attribute[0];
Expand Down

0 comments on commit 7348e15

Please sign in to comment.