diff --git a/dapper.php b/dapper.php index 0a4281d..401ec4d 100644 --- a/dapper.php +++ b/dapper.php @@ -1208,26 +1208,44 @@ if ( class_exists( 'WPCF7' ) ) { } // 2. NEW: Visible checkbox — use reliable append method - add_filter( 'wpcf7_form_elements', 'dapper_cf7_append_human_checkbox', 30 ); // Higher priority = later + add_filter( 'wpcf7_form_elements', 'dapper_cf7_append_human_checkbox', 100 ); // Higher priority = later function dapper_cf7_append_human_checkbox( $form ) { - if ( get_option( 'dapper_enable_cf7_human_checkbox', 'on' ) !== 'on' ) { - return $form; + if ( get_option( 'dapper_enable_cf7_human_checkbox', 'on' ) !== 'on' ) { + return $form; } + // Debug: Confirm filter is firing (now using your helper) + dapper_debug_log( 'CF7 checkbox filter FIRED - form length before insert: ' . strlen( $form ) ); + $unique = uniqid(); $checkbox_html = ' -
- - - -

Quick check to stop spam — thank you!

-
'; +
+ + + +

Quick check to help stop spam. Thanks!

+
'; - // Append right before the closing — most reliable - return str_replace( '', $checkbox_html . '', $form ); + // 1. Try after the response output div (common in widgets/Flatsome) + $form = preg_replace( '/(
]*>.*?<\/div>)/is', '$1' . $checkbox_html, $form, 1 ); + + // 2. If not found, insert before + if ( strpos( $form, $checkbox_html ) === false ) { + $form = str_replace( '', $checkbox_html . '', $form ); + } + + // 3. Ultimate fallback: just append to the end + if ( strpos( $form, $checkbox_html ) === false ) { + $form .= $checkbox_html; + dapper_debug_log( 'CF7 checkbox FALLBACK append used (no or response div match)' ); + } + + dapper_debug_log( 'CF7 checkbox filter COMPLETE - insertion attempted' ); + + return $form; } // Tiny JS to set token + disable submit until checked