From 6e94db24a2065e9ab10f5e9aace47d70817dfbd7 Mon Sep 17 00:00:00 2001 From: Amine Ben hammou Date: Mon, 15 Jan 2018 09:53:03 +0000 Subject: [PATCH] minor fixes --- assets/js/src/public.js | 10 ++++------ lib/Config/Populator.php | 2 +- lib/Form/Widget.php | 6 ++++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/assets/js/src/public.js b/assets/js/src/public.js index 42acbf13f6..e8270dc2a0 100644 --- a/assets/js/src/public.js +++ b/assets/js/src/public.js @@ -8,8 +8,8 @@ function ( // eslint-disable-line func-names jQuery ) { jQuery(function ($) { // eslint-disable-line func-names - window.reCaptchaCallback = function () { - $('.mailpoet_recaptcha').each(function () { + window.reCaptchaCallback = function reCaptchaCallback() { + $('.mailpoet_recaptcha').each(function () { // eslint-disable-line func-names var sitekey = $(this).attr('data-sitekey'); var container = $(this).find('> .mailpoet_recaptcha_container').get(0); var field = $(this).find('> .mailpoet_recaptcha_field'); @@ -65,14 +65,12 @@ function ( // eslint-disable-line func-names return error.message; }).join('
') ).show(); -<<<<<<< HEAD }).done(function (response) { // eslint-disable-line func-names -======= if (window.grecaptcha) { window.grecaptcha.reset(formData.recaptcha); } - }).done(function (response) { ->>>>>>> handling multiple instances of reCaptcha + return response; + }).done(function (response) { // eslint-disable-line func-names // successfully subscribed if ( response.meta !== undefined diff --git a/lib/Config/Populator.php b/lib/Config/Populator.php index 3a3ed47aff..f802900873 100644 --- a/lib/Config/Populator.php +++ b/lib/Config/Populator.php @@ -141,7 +141,7 @@ class Populator { } // set reCaptcha settings - $re_captcha = Setting::getValue('re_captcha', array()); + $re_captcha = Setting::getValue('re_captcha'); if(empty($re_captcha)) { Setting::setValue('re_captcha', array( 'enabled' => false, diff --git a/lib/Form/Widget.php b/lib/Form/Widget.php index f6f080002d..4bda66f687 100644 --- a/lib/Form/Widget.php +++ b/lib/Form/Widget.php @@ -16,6 +16,8 @@ if(!defined('ABSPATH')) exit; class Widget extends \WP_Widget { private $renderer; + const RECAPTCHA_API_URL = 'https://www.google.com/recaptcha/api.js?onload=reCaptchaCallback&render=explicit'; + function __construct() { parent::__construct( 'mailpoet_form', @@ -49,7 +51,7 @@ class Widget extends \WP_Widget { wp_print_scripts('jquery'); wp_print_scripts('mailpoet_vendor'); wp_print_scripts('mailpoet_public'); - echo ''; + echo ''; $scripts = ob_get_contents(); ob_end_clean(); @@ -114,7 +116,7 @@ class Widget extends \WP_Widget { if(!empty($captcha['enabled'])) { wp_enqueue_script( 'mailpoet_recaptcha', - 'https://www.google.com/recaptcha/api.js?onload=reCaptchaCallback&render=explicit', + self::RECAPTCHA_API_URL, array('mailpoet_public') ); }