Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Where can we see the websites in question?

    Thread Starter mjh1

    (@mjh1)

    Here’s an example:

    https://theudlapproach.com/contact/

    • This reply was modified 5 years ago by mjh1.
    Plugin Author Takayuki Miyoshi

    (@takayukister)

    What other plugins and theme do you use on the site?

    Thread Starter mjh1

    (@mjh1)

    We developed the theme, which is very simple. The theme has been tested with Theme Check.

    Plugins:
    Classic Editor
    Honeypot for Contact Form 7
    Podbean Shortcode
    Toggle wpautop
    Wordfence
    Yoast SEO

    The relevant part of the functions.php file looks like this:

    add_filter( 'wpcf7_load_js', '__return_false' );
    add_filter( 'wpcf7_load_css', '__return_false' );
    
    function loui_lord_nelson_scripts() {
    	wp_enqueue_style( 'loui-lord-nelson-google-fonts', 'https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700,700i', false );
    	wp_enqueue_style( 'loui-lord-nelson-main-styles', get_template_directory_uri() . '/css/main.css', array(), null );
    
    	if(is_page( 15 )) {
    		wp_enqueue_style( 'loui-lord-nelson-form-styles', get_template_directory_uri() . '/css/forms.css', array(), null );
    		if ( function_exists( 'wpcf7_enqueue_scripts' ) ) {
    		  wpcf7_enqueue_scripts();
    		}
    
    		if ( function_exists( 'wpcf7_enqueue_styles' ) ) {
    		  wpcf7_enqueue_styles();
    		}
    	}
    }
    add_action( 'wp_enqueue_scripts', 'loui_lord_nelson_scripts', 1 );
    • This reply was modified 5 years ago by mjh1.
    Plugin Author Takayuki Miyoshi

    (@takayukister)

    This broke in a recent plugin update and the CF7 scripts and styles are no longer loading at all.

    That is because you disable loading of the script and style here:

    add_filter( 'wpcf7_load_js', '__return_false' );
    add_filter( 'wpcf7_load_css', '__return_false' );

    It is working as intended.

    Thread Starter mjh1

    (@mjh1)

    And I’m enabling the scripts and styles again on just the Contact page here:

    	if(is_page( 15 )) {
    		wp_enqueue_style( 'loui-lord-nelson-form-styles', get_template_directory_uri() . '/css/forms.css', array(), null );
    		if ( function_exists( 'wpcf7_enqueue_scripts' ) ) {
    		  wpcf7_enqueue_scripts();
    		}
    
    		if ( function_exists( 'wpcf7_enqueue_styles' ) ) {
    		  wpcf7_enqueue_styles();
    		}
    	}

    This was working until recently, as I mentioned in my first post. Did something change with regard to enqueueing?

    Plugin Author Takayuki Miyoshi

    (@takayukister)

    See Loading JavaScript and stylesheet only when it is necessary and follow the steps in the post.

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

The topic ‘CF7 scripts and styles not loading’ is closed to new replies.