handling recaptcha on the PHP side

This commit is contained in:
Amine Ben hammou
2017-12-18 18:28:42 +00:00
parent a05f9bf97b
commit caa0623112
4 changed files with 50 additions and 6 deletions

View File

@ -1,6 +1,8 @@
<?php
namespace MailPoet\Form;
use MailPoet\Models\Setting;
if(!defined('ABSPATH')) exit;
class Renderer {
@ -39,15 +41,23 @@ class Renderer {
}
static function renderBlocks($blocks = array(), $honeypot_enabled = true) {
$html = array();
// add honeypot for spambots
$html = ($honeypot_enabled) ?
$html[] = ($honeypot_enabled) ?
'<label class="mailpoet_hp_email_label">' . __('Please leave this field empty', 'mailpoet') . '<input type="email" name="data[email]"></label>' :
'';
foreach($blocks as $key => $block) {
$html .= static::renderBlock($block) . PHP_EOL;
$html[] = static::renderBlock($block) . PHP_EOL;
}
return $html;
if(Setting::getValue('re_captcha.enabled')) {
$submit = array_pop($html);
$site_key = Setting::getValue('re_captcha.site_token');
$html[] = '<div class="g-recaptcha" data-sitekey="'. $site_key .'"></div>';
$html[] = $submit;
}
return implode('', $html);
}
static function renderBlock($block = array()) {