remove_action('wpcf7_init', 'wpcf7_recaptcha_add_form_tag_recaptcha');
add_action('wpcf7_init', 'wpcf7_recaptcha_add_form_tag_recaptcha_scroller');
function wpcf7_recaptcha_add_form_tag_recaptcha_scroller() {
$recaptcha = WPCF7_RECAPTCHA::get_instance();
if ( $recaptcha->is_active() ) {
wpcf7_add_form_tag( 'recaptcha', 'wpcf7_recaptcha_form_tag_handler_scroller',
array( 'display-block' => true ) );
}
}
function wpcf7_recaptcha_form_tag_handler_scroller( $tag ) {
if ( ! wp_script_is( 'google-recaptcha', 'registered' ) ) {
wpcf7_recaptcha_enqueue_scripts();
}
wp_enqueue_script( 'google-recaptcha' );
$atts = array();
$recaptcha = WPCF7_RECAPTCHA::get_instance();
$atts['data-sitekey'] = $recaptcha->get_sitekey();
$atts['data-type'] = $tag->get_option( 'type', '(audio|image)', true );
$atts['data-size'] = $tag->get_option(
'size', '(compact|normal|invisible)', true );
$atts['data-theme'] = $tag->get_option( 'theme', '(dark|light)', true );
$atts['data-badge'] = $tag->get_option(
'badge', '(bottomright|bottomleft|inline)', true );
$atts['data-tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
$atts['data-callback'] = 'recapchaCallbackSuccess';
$atts['data-expired-callback'] =
$tag->get_option( 'expired_callback', '', true );
$atts['class'] = $tag->get_class_option(
wpcf7_form_controls_class( $tag->type, 'g-recaptcha' ) );
$atts['id'] = $tag->get_id_option();
$html = sprintf( '<div %1$s></div>', wpcf7_format_atts( $atts ) );
$html .= wpcf7_recaptcha_noscript(
array( 'sitekey' => $atts['data-sitekey'] ) );
$html = sprintf( '<div class="wpcf7-form-control-wrap">%s</div>', $html );
return $html;
}