CF7 All Forms Issue – suggested fix
-
Hi guys, it looks like CF7 may have changed the format of their output as the “has-spinner” class has moved, which means any form without the manual shortcode is failing if the cfturnstile_cf7_all option is set.
The current code is brittle and sensitive to such changes, or indeed any custom classes being used.
It would be more robust if you replace lines 43-56 of
inc/integrations/forms/contact-form-7.php:$button_types = array( '<input type="submit"', '<input class="wpcf7-submit" type="submit"', '<input class="wpcf7-form-control wpcf7-submit" type="submit"', '<input class="wpcf7-form-control has-spinner wpcf7-submit" type="submit"', '<input class="wpcf7-form-control has-spinner wpcf7-submit button button--secondary" type="submit"', ); $button_types = apply_filters( 'cfturnstile_cf7_button_types', $button_types ); foreach($button_types as $button_type) { if (false !== strpos($content, $button_type)) { $content = str_replace($button_type, cfturnstile_cf7_shortcode() . '<br/>' . $button_type, $content); } } return $content;
with a simple preg_replace:
return preg_replace('/(<input[^>]*type="submit")/i', cfturnstile_cf7_shortcode() . '<br/>$1', $content);
This will ensure the turnstile is added before the submit button, regardless of the classes set.
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘CF7 All Forms Issue – suggested fix’ is closed to new replies.