Contact Form 7: Load scripts and styles only when there is shortcode? [closed]

This isn’t based on shortcode detection, but you could try

// Add the Contact Form 7 scripts only on the contact page
function deregister_cf7_js() {
    if ( !is_page('contact')) {
        wp_deregister_script( 'contact-form-7');
    }
}
add_action( 'wp_print_scripts', 'deregister_cf7_js' );

function deregister_ct7_styles() {
    wp_deregister_style( 'contact-form-7');
}
add_action( 'wp_print_styles', 'deregister_ct7_styles');

from
http://wptheming.com/2009/12/optimize-plug-in-script-wordpress/

I think you could change the wp_print_styles and wp_print_scripts hooks to wp_enqueue_scripts, but I haven’t tested that.

I just wrote the following for a custom plugin I am working on:

/**
 * Is User listing?
 *
 * @access public
 * @return boolean
 */
function is_user_listing(){
    global $post;

    $listing = false;

    if( is_page() && isset($post->post_content) && false !== stripos($post->post_content, '[userlist')) {
        $listing = true;
    }

    return apply_filters( 'sul_is_user_listing', $listing );
}

The premise being that is is searching the post’s content for a shortcode that begins with [userlist. Maybe you can adapt it (or at least the conditional) to search for the contact7 shortcode.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)