<?php
defined('ABSPATH') or die('No script kiddies please!!');
$form_details = maybe_unserialize($form_row->form_details);
if (empty($form_details['captcha'])) {
    return;
}
/**
 * Captcha
 */
if (!empty($form_details['captcha']['enable'])) {
    $site_key = (!empty($form_details['captcha']['site_key'])) ? $form_details['captcha']['site_key'] : '';
    if (!empty($site_key)) {
?>
        <script src="//www.google.com/recaptcha/api.js?render=<?php echo esc_attr($site_key) ?>"></script>

        <script>
            if (typeof std_reCaptcha_ready != 'function') {
                function std_reCaptcha_ready() {
                    grecaptcha.execute('<?php echo esc_html($site_key) ?>', {
                        action: 'submit'
                    }).then(function(token) {
                        document.getElementById('g-recaptcha-response').value = token;

                    });
                }
            }
            grecaptcha.ready(function() {
                std_reCaptcha_ready();
            });
        </script>
        <input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response">
<?php
    }
}
