Skip to content

Commit

Permalink
Newsletter::newsletter_signup_form(): bug fix
Browse files Browse the repository at this point in the history
The `wp_nonce_field()` function by default _displays_ the field.

This means that, as things were, the nonce field would be echo'd out when the function was called + would add a `1` to the `$html` string being created.
The resulting `$html` string would not contain the nonce field and the nonce field would not be between the `<form>` tags.

Fixed by setting the `$display` parameter to `false`.

Ref: https://developer.wordpress.org/reference/functions/wp_nonce_field/
  • Loading branch information
jrfnl committed Nov 20, 2023
1 parent c6ba6f4 commit 5ba6590
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ui/newsletter.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static function newsletter_signup_form() {
$html = '
<!-- Begin Newsletter Signup Form -->
<form method="post" id="newsletter-subscribe-form" name="newsletter-subscribe-form" novalidate>
' . \wp_nonce_field( 'newsletter', 'newsletter_nonce' ) . '
' . \wp_nonce_field( 'newsletter', 'newsletter_nonce', true, false ) . '
<p>' . $copy . '</p>
<div class="newsletter-field-group" style="display: flex; flex-direction: column">
<label for="newsletter-email" style="margin: 0 0 4px 0;"><strong>' . $email_label . '</strong></label>
Expand Down

0 comments on commit 5ba6590

Please sign in to comment.