Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter rolturn

    (@rolturn)

    
    ACF Content Analysis for Yoast SEO
    Advanced Custom Fields PRO
    Advanced Custom Fields: Extended
    Advanced Editor Tools
    Aurora Heatmap
    Classic Editor
    Conditional Fields for Contact Form 7
    Contact Form 7
    Contact Form Entries
    Drag and Drop Multiple File Upload - Contact Form 7
    Duplicate Menu
    Gutenslider — The last WordPress slider you will ever need.
    Integration for Contact Form 7 and Pardot Pro
    Simple Custom Post Order
    Smart Slider 3
    Unbounce Landing Pages
    WP Mail SMTP Pro
    WP Migrate
    WP Pusher
    Yoast Duplicate Post
    Yoast SEO Premium

    Here is the list of Active plugins

    Here is the solution I have in place.

    function ew_register_cf7_js() {
      // Dequeue cf5 and recaptcha scripts, preventing them from loading everywhere
      add_filter( 'wpcf7_load_js', '__return_false' ); // Might as well use their filter
      wp_dequeue_script( 'google-recaptcha' );
      wp_dequeue_script( 'wpcf7-recaptcha' );
    
      // If current post has cf7 shortcode, enqueue!
      global $post;
    
      if (get_field('modules', $post->ID)) {
        $modules = get_field('modules', $post->ID);
        foreach($modules as $field) {
          if ($field['acf_fc_layout'] === "form") {
            if ( function_exists( 'wpcf7_enqueue_scripts' ) ) {
                wpcf7_enqueue_scripts();
                wp_enqueue_script( 'google-recaptcha' );
                wp_enqueue_script( 'wpcf7-recaptcha' );
            }
            break;
          }
        }
      }
    }
    add_action( 'wp_enqueue_scripts', 'ew_register_cf7_js' );

    To me it looks like WPCF7 has 2 scripts enqueuing the badge now and if you get one of the scripts it is still loading from the other.

    Sidenote: for those of you who want a way to identify when a form is loaded and don’t use shortcodes. I load all my forms via an ACF repeater field so that content entry is easier for the team managing copy and I just leverage that field to identify when to load the scripts. Not saying this solution will work for everyone, but I am saying you could figure out a methodology to identify when forms are loaded to make sure you load the badge when forms load.

    @jules-colle I am having the same issue. The drag and drop file upload field created by, Drag and Drop Multiple File Upload – Contact Form 7, plugin seems to be required when the field is required yet hidden. Is there anything I can do to resolve this?

    @rejeanlepage, if you added the code within the file, wp-content/plugins/contact-form-7/includes/functions.php, it will be overwritten if you update the CF7 plugin. That code can be added into your theme functions.php or a separate custom plugin then it would “safe” on update, but you also would not be able to tell if a patch was created to resolve this issue. Solutions to issues like this is just personal preference. I added my solution to my theme functions.php and will test to see if it is still necessary after the next update of CF7.

    @florianziegler Thanks for the suggestion, worked perfectly after I made accommodations for ACF.

    Seems like the CSS version of this could get very messy and could lead to breaking the recaptcha “Terms of Service”, or at least my understanding of it, https://stackoverflow.com/a/44543771.

    You are also loading the recaptcha JS unnecessarily if you are concerned with loading speeds this could be an issue.

Viewing 5 replies - 1 through 5 (of 5 total)