handling recaptcha on the PHP side
This commit is contained in:
@ -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()) {
|
||||
|
Reference in New Issue
Block a user