diff --git a/admin/comment_form_admin.php b/admin/comment_form_admin.php
index 3701102..3f57866 100644
--- a/admin/comment_form_admin.php
+++ b/admin/comment_form_admin.php
@@ -186,6 +186,8 @@ public function sanitize_settings ( $data ){
$data['text_before'] = wp_kses_post( $data['text_before'] );
$data['text_after'] = wp_kses_post( $data['text_after'] );
+ $data['recaptcha_site_key'] = wp_kses_post( $data['recaptcha_site_key'] );
+ $data['recaptcha_secret_key'] = wp_kses_post( $data['recaptcha_secret_key'] );
return $data;
}
diff --git a/admin/views/email.php b/admin/views/email.php
index a7da1e4..ca884a0 100644
--- a/admin/views/email.php
+++ b/admin/views/email.php
@@ -61,7 +61,7 @@ public function render_mailchimp_field_callback() {
API key
diff --git a/frontend/comment_form_frontend.php b/frontend/comment_form_frontend.php
index e935123..34e793a 100755
--- a/frontend/comment_form_frontend.php
+++ b/frontend/comment_form_frontend.php
@@ -25,6 +25,9 @@ public function __construct() {
add_action('wp_footer', array($this, 'footer_output'));
// add comment form shortcode
add_shortcode('comment-form', array($this, 'shortcode'));
+ // add the pro feature: recaptcha
+ add_action( 'wp_enqueue_scripts', array($this, 'enqueue_recaptcha_script'));
+ add_action( 'comment_form_after', array($this, 'add_recaptcha_to_comment_form'));
}
/**
@@ -203,4 +206,35 @@ public function shortcode($atts = array(), $content = '') {
return $output;
}
+ /**
+ * show the recaptcha badge
+ *
+ * @since 1.0.0
+ */
+ public function enqueue_recaptcha_script() {
+ if (sc_fs()->is__premium_only()) {
+ if ( is_single() && comments_open() ) {
+ wp_enqueue_script( 'google-recaptcha', 'https://www.google.com/recaptcha/api.js', array(), null, true );
+ }
+ }
+ }
+
+ /**
+ * ensure that the reCAPTCHA badge and the required scripts
+ * are only loaded on pages where the comment form is displayed
+ *
+ * @since 1.0.0
+ */
+ public function add_recaptcha_to_comment_form() {
+ $options = $this->options();
+ echo print_r($options);
+
+ if ( is_single() && comments_open() ) :
+ if ( isset($options['recaptcha_site_key']) && $options['recaptcha_site_key'] != '' ) : ?>
+
+