0

I want to show the css and javascript only when the shortcode is used in that page. If the short code not present in the wordpress page then the js and css of contact form should not be shown. For that what i have done is i have pasted the following code in my active themes function.php file.

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

The above code totally removes the js and css of contact form 7 plugin. What i need is if contact form 7 shortcode is pasted then both should be shown.

J. Shabu
  • 1,013
  • 9
  • 22
  • Out of curiosity, what do you need to target IE11 for, specifically? – keithjgrant May 04 '17 at 16:51
  • Is it rendering something differently than the other browsers? I'm asking because there are not many of these bugs in IE11, and there could be a better workaround. – keithjgrant May 05 '17 at 16:20

3 Answers3

2

According to msdn microsoft site, these conditional comments are no longer valid from IE 10. Therefore, for IE 11 there is no such conditional comment.

For more info: https://msdn.microsoft.com/en-us/library/hh801214(v=vs.85).aspx

Nitesh
  • 1,490
  • 1
  • 12
  • 20
1

1) LT = less then, so its < 11, not <= IE11

2) such conditions work for IE <= 9. Not supported since 10+

3) Try to read here: Detecting IE11 using CSS Capability/Feature Detection (about IE 11 detection using other ways)

Community
  • 1
  • 1
kpower
  • 3,871
  • 4
  • 42
  • 62
0

Here is the answer for this question. You can refer this link also which was answered by me. View answer

function rjs_lwp_contactform_css_js() {
    global $post;
    if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'contact-form-7') ) {
        wp_enqueue_script('contact-form-7');
         wp_enqueue_style('contact-form-7');

    }else{
        wp_dequeue_script( 'contact-form-7' );
        wp_dequeue_style( 'contact-form-7' );
    }
}
add_action( 'wp_enqueue_scripts', 'rjs_lwp_contactform_css_js');
J. Shabu
  • 1,013
  • 9
  • 22