adding recaptcha to form wiget

This commit is contained in:
Amine Ben hammou
2017-12-19 11:33:50 +00:00
parent 99a007fb70
commit 2228f60e2a
2 changed files with 7 additions and 3 deletions

View File

@@ -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,

View File

@@ -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