Beispiel #1
0
 function cf7bs_recaptcha_add_shortcode_recaptcha()
 {
     $recaptcha = WPCF7_RECAPTCHA::get_instance();
     if ($recaptcha->is_active()) {
         wpcf7_add_shortcode('recaptcha', 'cf7bs_recaptcha_shortcode_handler');
     }
 }
 /**
  *	Prevent from creating more than one instance
  */
 private function __construct()
 {
     $wpcf7_version = defined('WPCF7_VERSION') ? WPCF7_VERSION : '0';
     $wpcf7_recaptcha_configured = class_exists('WPCF7_RECAPTCHA') && ($cf7_sitekey = WPCF7_RECAPTCHA::get_instance()->get_sitekey()) && WPCF7_RECAPTCHA::get_instance()->get_secret($cf7_sitekey);
     // Skip WPCF7 reCaptcha
     if ($wpcf7_recaptcha_configured || version_compare($wpcf7_version, '4.3', '<')) {
         add_action('wpcf7_init', array(&$this, 'add_shortcode_recaptcha'));
         add_action('wp_enqueue_scripts', array(&$this, 'recaptcha_enqueue_script'));
         add_action('admin_init', array(&$this, 'add_tag_generator_recaptcha'), 45);
         add_filter('wpcf7_validate_recaptcha', array(&$this, 'recaptcha_validation_filter'), 10, 2);
         add_filter('wpcf7_validate_recaptcha*', array(&$this, 'recaptcha_validation_filter'), 10, 2);
         add_filter('wpcf7_messages', array(&$this, 'add_error_message'));
     }
 }
function wpcf7_tag_generator_recaptcha($contact_form, $args = '')
{
    $args = wp_parse_args($args, array());
    $recaptcha = WPCF7_RECAPTCHA::get_instance();
    if (!$recaptcha->is_active()) {
        ?>
<div class="control-box">
<fieldset>
<legend><?php 
        echo sprintf(esc_html(__("To use reCAPTCHA, first you need to install an API key pair. For more details, see %s.", 'contact-form-7')), wpcf7_link(__('http://contactform7.com/recaptcha/', 'contact-form-7'), __('reCAPTCHA', 'contact-form-7')));
        ?>
</legend>
</fieldset>
</div>
<?php 
        return;
    }
    $description = __("Generate a form-tag for a reCAPTCHA widget. For more details, see %s.", 'contact-form-7');
    $desc_link = wpcf7_link(__('http://contactform7.com/recaptcha/', 'contact-form-7'), __('reCAPTCHA', 'contact-form-7'));
    ?>
<div class="control-box">
<fieldset>
<legend><?php 
    echo sprintf(esc_html($description), $desc_link);
    ?>
</legend>

<table class="form-table">
<tbody>
	<tr>
	<th scope="row"><?php 
    echo esc_html(__('Theme', 'contact-form-7'));
    ?>
</th>
	<td>
		<fieldset>
		<legend class="screen-reader-text"><?php 
    echo esc_html(__('Theme', 'contact-form-7'));
    ?>
</legend>
		<label for="<?php 
    echo esc_attr($args['content'] . '-theme-light');
    ?>
"><input type="radio" name="theme" class="option default" id="<?php 
    echo esc_attr($args['content'] . '-theme-light');
    ?>
" value="light" checked="checked" /> <?php 
    echo esc_html(__('Light', 'contact-form-7'));
    ?>
</label>
		<br />
		<label for="<?php 
    echo esc_attr($args['content'] . '-theme-dark');
    ?>
"><input type="radio" name="theme" class="option" id="<?php 
    echo esc_attr($args['content'] . '-theme-dark');
    ?>
" value="dark" /> <?php 
    echo esc_html(__('Dark', 'contact-form-7'));
    ?>
</label>
		</fieldset>
	</td>
	</tr>

	<tr>
	<th scope="row"><?php 
    echo esc_html(__('Size', 'contact-form-7'));
    ?>
</th>
	<td>
		<fieldset>
		<legend class="screen-reader-text"><?php 
    echo esc_html(__('Size', 'contact-form-7'));
    ?>
</legend>
		<label for="<?php 
    echo esc_attr($args['content'] . '-size-normal');
    ?>
"><input type="radio" name="size" class="option default" id="<?php 
    echo esc_attr($args['content'] . '-size-normal');
    ?>
" value="normal" checked="checked" /> <?php 
    echo esc_html(__('Normal', 'contact-form-7'));
    ?>
</label>
		<br />
		<label for="<?php 
    echo esc_attr($args['content'] . '-size-compact');
    ?>
"><input type="radio" name="size" class="option" id="<?php 
    echo esc_attr($args['content'] . '-size-compact');
    ?>
" value="compact" /> <?php 
    echo esc_html(__('Compact', 'contact-form-7'));
    ?>
</label>
		</fieldset>
	</td>
	</tr>

	<tr>
	<th scope="row"><label for="<?php 
    echo esc_attr($args['content'] . '-id');
    ?>
"><?php 
    echo esc_html(__('Id attribute', 'contact-form-7'));
    ?>
</label></th>
	<td><input type="text" name="id" class="idvalue oneline option" id="<?php 
    echo esc_attr($args['content'] . '-id');
    ?>
" /></td>
	</tr>

	<tr>
	<th scope="row"><label for="<?php 
    echo esc_attr($args['content'] . '-class');
    ?>
"><?php 
    echo esc_html(__('Class attribute', 'contact-form-7'));
    ?>
</label></th>
	<td><input type="text" name="class" class="classvalue oneline option" id="<?php 
    echo esc_attr($args['content'] . '-class');
    ?>
" /></td>
	</tr>

</tbody>
</table>
</fieldset>
</div>

<div class="insert-box">
	<input type="text" name="recaptcha" class="tag code" readonly="readonly" onfocus="this.select()" />

	<div class="submitbox">
	<input type="button" class="button button-primary insert-tag" value="<?php 
    echo esc_attr(__('Insert Tag', 'contact-form-7'));
    ?>
" />
	</div>
</div>
<?php 
}