Only load on relevant pages
-
Hi
Both plugins: CF7 and CF7 Condition fields, have simple methods to only have the js and css of those load on pages, where it is actually needed.
How do we do this for the Signature plugin?
Here’s my php (implemented with Snippets plugin), which handles the other two plugins:
// disable cf7 scripts and styles globally add_filter( 'wpcf7_load_js', '__return_false' ); add_filter( 'wpcf7_load_css', '__return_false' ); // disable disable cf7 conditional fields scripts and styles globally add_filter( 'wpcf7cf_load_js', '__return_false' ); add_filter( 'wpcf7cf_load_css', '__return_false' ); // load cf7 on specific pages add_action('wp_enqueue_scripts', 'load_wpcf7_scripts'); function load_wpcf7_scripts() { if ( is_page( array( 'book-now', 'indemnity', 'contact-us') ) ) { if ( function_exists( 'wpcf7_enqueue_scripts' ) ) { wpcf7_enqueue_scripts(); } if ( function_exists( 'wpcf7_enqueue_styles' ) ) { wpcf7_enqueue_styles(); } } } // load cf7 conditional fields on specific pages add_action('wp_enqueue_scripts', 'load_wpcf7cf_scripts'); function load_wpcf7cf_scripts() { if ( is_page( array( 'indemnity') ) ) { if ( function_exists( 'wpcf7cf_enqueue_scripts' ) ) { wpcf7cf_enqueue_scripts(); } if ( function_exists( 'wpcf7cf_enqueue_styles' ) ) { wpcf7cf_enqueue_styles(); } } }
The page I need help with: [log in to see the link]
- The topic ‘Only load on relevant pages’ is closed to new replies.