adding recaptcha to form wiget
This commit is contained in:
@@ -14,6 +14,8 @@ use MailPoet\WP\Hooks;
|
|||||||
if(!defined('ABSPATH')) exit;
|
if(!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
class Widget extends \WP_Widget {
|
class Widget extends \WP_Widget {
|
||||||
|
const RECAPTCHA_API_SCRIPT = '<script src="https://www.google.com/recaptcha/api.js"></script>';
|
||||||
|
|
||||||
private $renderer;
|
private $renderer;
|
||||||
|
|
||||||
function __construct() {
|
function __construct() {
|
||||||
@@ -50,7 +52,7 @@ class Widget extends \WP_Widget {
|
|||||||
wp_print_scripts('mailpoet_vendor');
|
wp_print_scripts('mailpoet_vendor');
|
||||||
wp_print_scripts('mailpoet_public');
|
wp_print_scripts('mailpoet_public');
|
||||||
if(Setting::getValue('re_captcha.enabled')) {
|
if(Setting::getValue('re_captcha.enabled')) {
|
||||||
echo '<script src="https://www.google.com/recaptcha/api.js"></script>';
|
echo self::RECAPTCHA_API_SCRIPT;
|
||||||
}
|
}
|
||||||
$scripts = ob_get_contents();
|
$scripts = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
@@ -275,7 +277,9 @@ EOL;
|
|||||||
|
|
||||||
if(!empty($body)) {
|
if(!empty($body)) {
|
||||||
$form_id = $this->id_base . '_' . $form['id'];
|
$form_id = $this->id_base . '_' . $form['id'];
|
||||||
|
if(Setting::getValue('re_captcha.enabled')) {
|
||||||
|
$before_widget .= self::RECAPTCHA_API_SCRIPT;
|
||||||
|
}
|
||||||
$data = array(
|
$data = array(
|
||||||
'form_id' => $form_id,
|
'form_id' => $form_id,
|
||||||
'form_type' => $form_type,
|
'form_type' => $form_type,
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
<% if(title) %>
|
<% if(title) %>
|
||||||
<%= before_title | raw %><%= title | raw %><%= after_title | raw %>
|
<%= before_title | raw %><%= title | raw %><%= after_title | raw %>
|
||||||
<% endif %>
|
<% endif %>
|
||||||
|
|
||||||
<div id="<%= form_id %>" class="mailpoet_form mailpoet_form_<%= form_type %>">
|
<div id="<%= form_id %>" class="mailpoet_form mailpoet_form_<%= form_type %>">
|
||||||
<%= styles | raw %>
|
<%= styles | raw %>
|
||||||
<form
|
<form
|
||||||
|
Reference in New Issue
Block a user