Skip to content

Commit

Permalink
Fix bug in GF shortcode (via tests).
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Jan 25, 2025
1 parent 288f986 commit 616eeb1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/php/GravityForms/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function add_hcaptcha( $button_input, array $form ): string {

$form_id = $form['id'] ?? 0;

if ( $this->mode_embed && $this->has_hcaptcha( $form_id ) ) {
if ( $this->has_hcaptcha( $form_id ) ) {
return $button_input;
}

Expand Down Expand Up @@ -354,7 +354,7 @@ private function should_verify(): bool {
$form_meta = (array) GFFormsModel::get_form_meta( $form_id );

if (
0 !== (int) $_POST[ $target_page_name ] &&
0 !== $target_page &&
$target_page !== $source_page &&
isset(
$form_meta['pagination']['pages'][ $target_page - 1 ],
Expand Down Expand Up @@ -398,9 +398,12 @@ private function has_hcaptcha( int $form_id ): bool {
$captcha_types = [ 'captcha', 'hcaptcha' ];

foreach ( $form['fields'] as $field ) {
$type = $field->type ?? '';
$content = $field->content ?? '';

if (
in_array( $field->type, $captcha_types, true ) ||
has_shortcode( $field['content'], 'hcaptcha' )
( $this->mode_embed && in_array( $type, $captcha_types, true ) ) ||
has_shortcode( $content, 'hcaptcha' )
) {
return true;
}
Expand Down

0 comments on commit 616eeb1

Please sign in to comment.