Skip to content

Commit cd98465

Browse files
committed
fix(recaptcha): don't create button clone if not using v2
1 parent ada45a5 commit cd98465

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

includes/class-modal-checkout.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -1922,11 +1922,15 @@ public static function order_button_html( $html ) {
19221922
$class_prefix = self::get_class_prefix();
19231923

19241924
$newspack_ui_html = preg_replace( '/class=".*?"/', "class='{$class_prefix}__button {$class_prefix}__button--primary {$class_prefix}__button--wide'", $html );
1925-
$cloned_button = preg_replace( '/type="submit"/', 'type="button"', $newspack_ui_html );
1926-
$cloned_button = preg_replace( '/id="place_order"/', '', $newspack_ui_html );
1927-
$cloned_button = preg_replace( '/name=".*?"/', 'id="place_order_clone"', $newspack_ui_html );
19281925

1929-
return $cloned_button . $newspack_ui_html;
1926+
if ( class_exists( 'Newspack\Recaptcha' ) && \Newspack\Recaptcha::can_use_captcha( 'v2' ) ) {
1927+
$cloned_button = preg_replace( '/type="submit"/', 'type="button"', $newspack_ui_html );
1928+
$cloned_button = preg_replace( '/id="place_order"/', '', $newspack_ui_html );
1929+
$cloned_button = preg_replace( '/name=".*?"/', 'id="place_order_clone"', $newspack_ui_html );
1930+
$newspack_ui_html = $cloned_button . $newspack_ui_html;
1931+
}
1932+
1933+
return $newspack_ui_html;
19301934
}
19311935

19321936
/**

0 commit comments

Comments
 (0)