-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't call siteverify when Captcha solution is empty (#135)
* don't call siteverify when solution is empty * prepare 1.15.1
- Loading branch information
1 parent
7f4abd6
commit 9dec9c6
Showing
12 changed files
with
61 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 45 additions & 35 deletions
80
friendly-captcha/modules/divi/frcaptcha_divi_core_addon.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,105 @@ | ||
<?php | ||
|
||
class frcaptcha_divi_core_addon extends ET_Core_API_Spam_Provider { | ||
public $name = 'FriendlyCaptcha'; | ||
class frcaptcha_divi_core_addon extends ET_Core_API_Spam_Provider | ||
{ | ||
public $name = 'FriendlyCaptcha'; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public $slug = 'frcaptcha'; | ||
* @inheritDoc | ||
*/ | ||
public $slug = 'frcaptcha'; | ||
|
||
public $custom_fields = null; // avoid notice from \ET_Core_API_Email_Providers::_initialize which expects this field | ||
public $custom_fields = null; // avoid notice from \ET_Core_API_Email_Providers::_initialize which expects this field | ||
|
||
public function __construct( $owner = 'frcaptcha', $account_name = '', $api_key = '' ) { | ||
parent::__construct( $owner, $account_name, $api_key ); | ||
public function __construct($owner = 'frcaptcha', $account_name = '', $api_key = '') | ||
{ | ||
parent::__construct($owner, $account_name, $api_key); | ||
|
||
$this->_add_actions_and_filters(); | ||
} | ||
$this->_add_actions_and_filters(); | ||
} | ||
|
||
protected function _add_actions_and_filters() { | ||
if ( ! is_admin() && ! et_core_is_fb_enabled() ) { | ||
add_action( 'wp_enqueue_scripts', array( $this, 'action_wp_enqueue_scripts' ) ); | ||
} | ||
} | ||
protected function _add_actions_and_filters() | ||
{ | ||
if (!is_admin() && !et_core_is_fb_enabled()) { | ||
add_action('wp_enqueue_scripts', array($this, 'action_wp_enqueue_scripts')); | ||
} | ||
} | ||
|
||
public function action_wp_enqueue_scripts() { | ||
public function action_wp_enqueue_scripts() | ||
{ | ||
$plugin = FriendlyCaptcha_Plugin::$instance; | ||
|
||
if ( !$plugin->is_configured() ) { | ||
if (!$plugin->is_configured()) { | ||
return; | ||
} | ||
|
||
if ( ! $this->is_enabled() ) { | ||
return; | ||
} | ||
if (!$this->is_enabled()) { | ||
return; | ||
} | ||
|
||
frcaptcha_enqueue_widget_scripts(true); | ||
|
||
wp_dequeue_script('et-core-api-spam-recaptcha'); | ||
} | ||
} | ||
|
||
public function is_enabled() { | ||
public function is_enabled() | ||
{ | ||
$has_frcaptcha_module = true; | ||
|
||
if ( class_exists( 'ET_Dynamic_Assets' ) ) { | ||
if (class_exists('ET_Dynamic_Assets')) { | ||
$et_dynamic_module_framework = et_builder_dynamic_module_framework(); | ||
$is_dynamic_framework_enabled = et_builder_is_frontend() && 'on' === $et_dynamic_module_framework; | ||
$is_dynamic_css_enabled = et_builder_is_frontend() && et_use_dynamic_css(); | ||
|
||
if ( $is_dynamic_framework_enabled && $is_dynamic_css_enabled ) { | ||
if ($is_dynamic_framework_enabled && $is_dynamic_css_enabled) { | ||
$et_dynamic_assets = ET_Dynamic_Assets::init(); | ||
$saved_shortcodes = $et_dynamic_assets->get_saved_page_shortcodes(); | ||
$frcaptcha_modules = array( 'et_pb_contact_form', 'et_pb_signup' ); | ||
$has_frcaptcha_module = ! empty( array_intersect( $saved_shortcodes, $frcaptcha_modules ) ); | ||
$frcaptcha_modules = array('et_pb_contact_form', 'et_pb_signup'); | ||
$has_frcaptcha_module = !empty(array_intersect($saved_shortcodes, $frcaptcha_modules)); | ||
} | ||
} | ||
|
||
return $has_frcaptcha_module; | ||
} | ||
|
||
public function verify_form_submission() { | ||
public function verify_form_submission() | ||
{ | ||
$plugin = FriendlyCaptcha_Plugin::$instance; | ||
|
||
if ( !$plugin->is_configured() ) { | ||
if (!$plugin->is_configured()) { | ||
return array( | ||
'success' => true, | ||
'score' => 100000, | ||
); | ||
} | ||
|
||
if ( ! $this->is_enabled() ) { | ||
if (!$this->is_enabled()) { | ||
return array( | ||
'success' => true, | ||
'score' => 100000, | ||
); | ||
} | ||
|
||
$solution = et_()->array_get_sanitized( $_POST, 'token' ); | ||
$solution = et_()->array_get_sanitized($_POST, 'token'); | ||
if (empty($solution)) { | ||
return 'Captcha missing'; | ||
} | ||
|
||
$plugin = FriendlyCaptcha_Plugin::$instance; | ||
$verification = frcaptcha_verify_captcha_solution($solution, $plugin->get_sitekey(), $plugin->get_api_key()); | ||
|
||
if ( $verification["success"] ) { | ||
if ($verification["success"]) { | ||
return array( | ||
'success' => true, | ||
'score' => 100000, | ||
); | ||
} else { | ||
return 'Captcha error'; | ||
} | ||
} | ||
} | ||
|
||
public function get_account_fields() { | ||
return array(); | ||
} | ||
public function get_account_fields() | ||
{ | ||
return array(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters