From fea3db362434fbe7357bee5028d434bf3a2f4a2b Mon Sep 17 00:00:00 2001 From: Lucasarenaterry Date: Mon, 17 Feb 2025 17:44:07 +0000 Subject: [PATCH 1/5] Experimental --- adcaptcha.php | 4 ++-- readme.txt | 5 ++++- src/Plugin/Woocommerce/Checkout.php | 12 ++++++++++++ src/Settings/Advanced.php | 9 +++++++++ src/Settings/Settings.php | 2 +- 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/adcaptcha.php b/adcaptcha.php index e216b39..5dc2209 100644 --- a/adcaptcha.php +++ b/adcaptcha.php @@ -2,7 +2,7 @@ /** * Plugin Name: adCAPTCHA for WordPress * Description: Secure your site. Elevate your brand. Boost Ad Revenue. - * Version: 1.5.5 + * Version: 1.5.6 * Requires at least: 6.4.2 * Requires PHP: 7.4 * Author: adCAPTCHA @@ -21,7 +21,7 @@ use AdCaptcha\Instantiate; -const PLUGIN_VERSION_ADCAPTCHA = '1.5.5'; +const PLUGIN_VERSION_ADCAPTCHA = '1.5.6'; define('ADCAPTCHA_ERROR_MESSAGE', __( 'Please complete the I am human box.', 'adcaptcha' )); // Deletes data saved in the wp db on plugin uninstall diff --git a/readme.txt b/readme.txt index aa65a7e..0555ced 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Contributors: adCAPTCHA Tags: spam, anti-spam, block bots, security, adCAPTCHA Requires at least: 6.0 Tested up to: 6.5.2 -Stable tag: 1.5.5 +Stable tag: 1.5.6 Requires PHP: 7.4 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -147,3 +147,6 @@ During verification, the adCAPTCHA service may briefly receive the user's IP add = 1.5.5 = - Minor update to ContactForm7: Added the ability to manually place adCAPTCHA. - If not configured manually, it will default to appearing above the submit button. + += 1.5.6 = +- Added experimental function to disable the WooCommerce checkout endpoint. diff --git a/src/Plugin/Woocommerce/Checkout.php b/src/Plugin/Woocommerce/Checkout.php index d06ce59..8bab72b 100644 --- a/src/Plugin/Woocommerce/Checkout.php +++ b/src/Plugin/Woocommerce/Checkout.php @@ -26,8 +26,20 @@ public function setup() { add_action( 'woocommerce_review_order_before_submit', [ AdCaptcha::class, 'captcha_trigger' ] ); add_action('woocommerce_payment_complete', [ $this, 'reset_hasVerified' ]); add_action( 'woocommerce_checkout_process', [ $this, 'verify' ] ); + if (get_option('experimental_disable_wc_checkout_endpoint')) { + add_action('rest_api_init', 'disable_wc_endpoint_v1'); + } } + function disable_wc_endpoint_v1() { + $current_url = $_SERVER['REQUEST_URI']; + if (strpos($current_url, '/wp-json/wc/store/v1/checkout') !== false || strpos($current_url, '/wp-json/wc/store/checkout') !== false) { + wp_redirect(home_url('/404.php')); + exit; + } + } + + public function verify() { $session = WC()->session; $hasVerified = $session->get('hasVerified'); diff --git a/src/Settings/Advanced.php b/src/Settings/Advanced.php index 6ad4dc2..4d889a5 100644 --- a/src/Settings/Advanced.php +++ b/src/Settings/Advanced.php @@ -14,6 +14,9 @@ public function render_advance_settings() { $wc_checkout = isset($_POST['adcaptcha_advance']['wc-checkout']) ? sanitize_text_field(wp_unslash($_POST['adcaptcha_advance']['wc-checkout'])) : ''; update_option('adcaptcha_wc_checkout_optional_trigger', $wc_checkout); + + $experimental_disable_wc_checkout_endpoint = isset($_POST['adcaptcha_advance']['experimental_disable_wc_checkout_endpoint']) ? sanitize_text_field(wp_unslash($_POST['adcaptcha_advance']['experimental_disable_wc_checkout_endpoint'])) : ''; + update_option('experimental_disable_wc_checkout_endpoint', $experimental_disable_wc_checkout_endpoint); } ?> @@ -25,6 +28,7 @@ public function render_advance_settings() {

Woocommerce

@@ -32,6 +36,11 @@ public function render_advance_settings() { >
+
+

Experimental - Disable WC Checkout Endpoint:

+ > +
+
diff --git a/src/Settings/Settings.php b/src/Settings/Settings.php index 54234cc..dd2d623 100644 --- a/src/Settings/Settings.php +++ b/src/Settings/Settings.php @@ -81,6 +81,6 @@ public function change_admin_footer_text() { } public function change_admin_footer_version() { - return 'Version 1.5.5'; + return 'Version 1.5.6'; } } From 24e2f1434f1f024e324ddabecfcff3a57d805985 Mon Sep 17 00:00:00 2001 From: Lucasarenaterry Date: Fri, 21 Feb 2025 15:20:54 +0000 Subject: [PATCH 2/5] Added new advance feature to disable wc checkout endpoint --- README.md | 5 +++++ adcaptcha.php | 20 ++++++++++++-------- readme.txt | 9 ++++++++- src/Plugin/Woocommerce/Checkout.php | 4 ++-- src/Settings/Advanced.php | 4 ++-- 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 0fb5d5e..fc25cd0 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,11 @@ ### Fluent Forms +## Advance Feature + +* Able to trigger adCAPTCHA on the "Place order" button. +* Able to disable the WooCommerce checkout endpoint. This will help prevent unauthorized request, for example stopping credit card fraud. + ## Privacy Notices adCAPTCHA adheres to GDPR regulations. diff --git a/adcaptcha.php b/adcaptcha.php index 5dc2209..2a8c3e1 100644 --- a/adcaptcha.php +++ b/adcaptcha.php @@ -24,15 +24,19 @@ const PLUGIN_VERSION_ADCAPTCHA = '1.5.6'; define('ADCAPTCHA_ERROR_MESSAGE', __( 'Please complete the I am human box.', 'adcaptcha' )); -// Deletes data saved in the wp db on plugin uninstall -register_uninstall_hook( __FILE__, 'adcaptcha_uninstall' ); - -function adcaptcha_uninstall() { - delete_option( 'adcaptcha_api_key' ); - delete_option( 'adcaptcha_placement_id' ); - delete_option( 'adcaptcha_render_captcha' ); - delete_option( 'adcaptcha_selected_plugins' ); +if ( ! function_exists( 'adcaptcha_uninstall' ) ) { + // Deletes data saved in the wp db on plugin uninstall + function adcaptcha_uninstall() { + delete_option( 'adcaptcha_api_key' ); + delete_option( 'adcaptcha_placement_id' ); + delete_option( 'adcaptcha_render_captcha' ); + delete_option( 'adcaptcha_selected_plugins' ); + delete_option( 'experimental_disable_wc_checkout_endpoint' ); + delete_option( 'adcaptcha_wc_checkout_optional_trigger' ); + } } +register_uninstall_hook( __FILE__, 'adcaptcha_uninstall' ); + $instantiate = new Instantiate(); $instantiate->setup(); diff --git a/readme.txt b/readme.txt index 0555ced..ac2ae28 100644 --- a/readme.txt +++ b/readme.txt @@ -46,6 +46,13 @@ adCAPTCHA offers a unique proposition in the digital space by combining Security **Fluent Forms** +== Advance Feature == + +**Woocommerce** + +* Able to trigger adCAPTCHA on the "Place order" button. +* Able to disable the WooCommerce checkout endpoint. This will help prevent unauthorized request, for example stopping credit card fraud. + == Installation == **Installation** @@ -149,4 +156,4 @@ During verification, the adCAPTCHA service may briefly receive the user's IP add - If not configured manually, it will default to appearing above the submit button. = 1.5.6 = -- Added experimental function to disable the WooCommerce checkout endpoint. +- Added feature to disable the WooCommerce checkout endpoint. diff --git a/src/Plugin/Woocommerce/Checkout.php b/src/Plugin/Woocommerce/Checkout.php index 8bab72b..b68e66c 100644 --- a/src/Plugin/Woocommerce/Checkout.php +++ b/src/Plugin/Woocommerce/Checkout.php @@ -27,11 +27,11 @@ public function setup() { add_action('woocommerce_payment_complete', [ $this, 'reset_hasVerified' ]); add_action( 'woocommerce_checkout_process', [ $this, 'verify' ] ); if (get_option('experimental_disable_wc_checkout_endpoint')) { - add_action('rest_api_init', 'disable_wc_endpoint_v1'); + add_action('rest_api_init', [ $this, 'disable_wc_endpoint_v1' ]); } } - function disable_wc_endpoint_v1() { + public function disable_wc_endpoint_v1() { $current_url = $_SERVER['REQUEST_URI']; if (strpos($current_url, '/wp-json/wc/store/v1/checkout') !== false || strpos($current_url, '/wp-json/wc/store/checkout') !== false) { wp_redirect(home_url('/404.php')); diff --git a/src/Settings/Advanced.php b/src/Settings/Advanced.php index 4d889a5..4e4172a 100644 --- a/src/Settings/Advanced.php +++ b/src/Settings/Advanced.php @@ -37,9 +37,9 @@ public function render_advance_settings() {
-

Experimental - Disable WC Checkout Endpoint:

+

Disable Checkout Endpoint:

> -
+
From 416e699866ec15299f1f9d2f56a1209e875f2bf0 Mon Sep 17 00:00:00 2001 From: Lucasarenaterry Date: Fri, 21 Feb 2025 15:23:17 +0000 Subject: [PATCH 3/5] Fix typo error --- README.md | 2 +- readme.txt | 2 +- src/Settings/Advanced.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fc25cd0..2144fa5 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ ## Advance Feature * Able to trigger adCAPTCHA on the "Place order" button. -* Able to disable the WooCommerce checkout endpoint. This will help prevent unauthorized request, for example stopping credit card fraud. +* Able to disable the WooCommerce checkout endpoint. This will help prevent unauthorised request, for example stopping credit card fraud. ## Privacy Notices diff --git a/readme.txt b/readme.txt index ac2ae28..7041377 100644 --- a/readme.txt +++ b/readme.txt @@ -51,7 +51,7 @@ adCAPTCHA offers a unique proposition in the digital space by combining Security **Woocommerce** * Able to trigger adCAPTCHA on the "Place order" button. -* Able to disable the WooCommerce checkout endpoint. This will help prevent unauthorized request, for example stopping credit card fraud. +* Able to disable the WooCommerce checkout endpoint. This will help prevent unauthorised request, for example stopping credit card fraud. == Installation == diff --git a/src/Settings/Advanced.php b/src/Settings/Advanced.php index 4e4172a..cae4a64 100644 --- a/src/Settings/Advanced.php +++ b/src/Settings/Advanced.php @@ -39,7 +39,7 @@ public function render_advance_settings() {

Disable Checkout Endpoint:

> -
+
From cd94b0848322673dc09d732df5510bcc7282da80 Mon Sep 17 00:00:00 2001 From: Lucasarenaterry Date: Tue, 25 Feb 2025 08:46:33 +0000 Subject: [PATCH 4/5] Updated plugin version to 1.6.0 --- adcaptcha.php | 4 ++-- readme.txt | 4 ++-- src/Settings/Settings.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/adcaptcha.php b/adcaptcha.php index 2a8c3e1..c343201 100644 --- a/adcaptcha.php +++ b/adcaptcha.php @@ -2,7 +2,7 @@ /** * Plugin Name: adCAPTCHA for WordPress * Description: Secure your site. Elevate your brand. Boost Ad Revenue. - * Version: 1.5.6 + * Version: 1.6.0 * Requires at least: 6.4.2 * Requires PHP: 7.4 * Author: adCAPTCHA @@ -21,7 +21,7 @@ use AdCaptcha\Instantiate; -const PLUGIN_VERSION_ADCAPTCHA = '1.5.6'; +const PLUGIN_VERSION_ADCAPTCHA = '1.6.0'; define('ADCAPTCHA_ERROR_MESSAGE', __( 'Please complete the I am human box.', 'adcaptcha' )); if ( ! function_exists( 'adcaptcha_uninstall' ) ) { diff --git a/readme.txt b/readme.txt index 7041377..7ca7067 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Contributors: adCAPTCHA Tags: spam, anti-spam, block bots, security, adCAPTCHA Requires at least: 6.0 Tested up to: 6.5.2 -Stable tag: 1.5.6 +Stable tag: 1.6.0 Requires PHP: 7.4 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -155,5 +155,5 @@ During verification, the adCAPTCHA service may briefly receive the user's IP add - Minor update to ContactForm7: Added the ability to manually place adCAPTCHA. - If not configured manually, it will default to appearing above the submit button. -= 1.5.6 = += 1.6.0 = - Added feature to disable the WooCommerce checkout endpoint. diff --git a/src/Settings/Settings.php b/src/Settings/Settings.php index dd2d623..192572e 100644 --- a/src/Settings/Settings.php +++ b/src/Settings/Settings.php @@ -81,6 +81,6 @@ public function change_admin_footer_text() { } public function change_admin_footer_version() { - return 'Version 1.5.6'; + return 'Version 1.6.0'; } } From 08e4178f6de04ac82f03facef85a47fae77a2ee8 Mon Sep 17 00:00:00 2001 From: Lucasarenaterry Date: Tue, 25 Feb 2025 08:48:11 +0000 Subject: [PATCH 5/5] Fixe typo --- README.md | 2 +- readme.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2144fa5..c4145c6 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ ### Fluent Forms -## Advance Feature +## Advance Features * Able to trigger adCAPTCHA on the "Place order" button. * Able to disable the WooCommerce checkout endpoint. This will help prevent unauthorised request, for example stopping credit card fraud. diff --git a/readme.txt b/readme.txt index 7ca7067..8fc40c7 100644 --- a/readme.txt +++ b/readme.txt @@ -46,7 +46,7 @@ adCAPTCHA offers a unique proposition in the digital space by combining Security **Fluent Forms** -== Advance Feature == +== Advance Features == **Woocommerce**