• I shutdown the scripts of CF7 with these lines in functions.php:

    function wpcf7_remove_assets() 
    {
    	add_filter( 'wpcf7_load_js', '__return_false' );
    	add_filter( 'wpcf7_load_css', '__return_false' );
    }
    
    add_action( 'wpcf7_init', 'wpcf7_remove_assets' );

    Then I activate them with the filter:

    function wpcf7_add_assets( $atts ) {
    	if ( !is_admin() )
    	{
    		wpcf7_enqueue_styles();
    		wpcf7_enqueue_scripts();
    
    		return $atts;
    	}
    }
    
    add_filter( 'shortcode_atts_wpcf7', 'wpcf7_add_assets' );

    But there is an error in console:

    wpcf7 is not defined.

    How to connect the scripts only on pages where shortcode is correctly?

    • This topic was modified 1 year, 11 months ago by kadikey58.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Init scripts only on pages where shorcode is’ is closed to new replies.