Skip to content

Commit

Permalink
Fix error with the Elementor Checkout Element.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Jul 21, 2024
1 parent a359d77 commit 5f687da
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ Instructions for popular native integrations are below:
* Fixed conflict with Ninja Forms Upload field.
* Fixed Ninja Forms Ajax processing.
* Fixed error in cron with Matomo Analytics.
* Fixed error with the Elementor Checkout Element.

= 4.3.1 =
* Added a live form in the Contact Form 7 admin form view.
Expand Down
8 changes: 1 addition & 7 deletions src/php/AutoVerify/AutoVerify.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,7 @@ public function widget_block_content_filter( $content, array $instance, WP_Widge
* @noinspection ForgottenDebugOutputInspection
*/
public function verify_form(): void {
if ( ! Request::is_frontend() ) {
return;
}

$request_method = isset( $_SERVER['REQUEST_METHOD'] ) ? filter_var( wp_unslash( $_SERVER['REQUEST_METHOD'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) : '';

if ( 'POST' !== $request_method ) {
if ( ! Request::is_post() || ! Request::is_frontend() ) {
return;
}

Expand Down
9 changes: 2 additions & 7 deletions src/php/GiveWP/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use Give\DonationForms\ValueObjects\DonationFormErrorTypes;
use HCaptcha\Helpers\HCaptcha;
use HCaptcha\Helpers\Request;
use WP_Error;

/**
Expand Down Expand Up @@ -128,13 +129,7 @@ public function verify( $valid_data ): void {
* @return void
*/
public function verify_block(): void {
// phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
$request_method = isset( $_SERVER['REQUEST_METHOD'] )
? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) )
: '';
// phpcs:enable WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended

if ( 'POST' !== $request_method ) {
if ( ! Request::is_post() ) {
return;
}

Expand Down
25 changes: 24 additions & 1 deletion src/php/Helpers/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Request {
* @return bool
*/
public static function is_frontend(): bool {
return ! ( self::is_cli() || is_admin() || wp_doing_ajax() || self::is_rest() );
return ! ( self::is_cli() || is_admin() || wp_doing_ajax() || self::is_wc_ajax() || self::is_rest() );
}

/**
Expand Down Expand Up @@ -78,4 +78,27 @@ public static function is_rest(): bool {

return 0 === strpos( $current_url, $rest_url );
}

/**
* Check if it is a POST request.
*
* @return bool
*/
public static function is_post(): bool {
$request_method = isset( $_SERVER['REQUEST_METHOD'] )
? strtoupper( filter_var( wp_unslash( $_SERVER['REQUEST_METHOD'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) )
: '';

return 'POST' === $request_method;
}

/**
* Check if it is a WooCommerce AJAX request.
*
* @return bool
*/
public static function is_wc_ajax(): bool {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
return isset( $_GET['wc-ajax'] );
}
}

0 comments on commit 5f687da

Please sign in to comment.