mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-05 12:32:23 +08:00
https://plugins.svn.wordpress.org/cf7-optimizer/trunk/cf7-optimizer.php https://github.com/gianlucagaspari/contact-form-7-optimizer
26 lines
972 B
Text
26 lines
972 B
Text
function wpcf7_custom_enqueue_scripts() {
|
|
if ( is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) ) {
|
|
wp_dequeue_script( 'wpcf7-recaptcha' );
|
|
wp_dequeue_script( 'google-recaptcha' );
|
|
wp_dequeue_style( 'contact-form-7' );
|
|
global $post;
|
|
if ( isset( $post->post_content ) && has_shortcode( $post->post_content, 'contact-form-7' ) ) {
|
|
if ( function_exists( 'wpcf7_enqueue_scripts' ) ) {
|
|
wpcf7_enqueue_scripts();
|
|
wp_enqueue_script( 'wpcf7-recaptcha' );
|
|
wp_enqueue_script( 'google-recaptcha' );
|
|
}
|
|
if ( function_exists( 'wpcf7_enqueue_styles' ) ) {
|
|
wpcf7_enqueue_styles();
|
|
}
|
|
}
|
|
$service = WPCF7_RECAPTCHA::get_instance();
|
|
if ( ! $service->is_active() ) {
|
|
return;
|
|
}
|
|
wp_add_inline_script( 'contact-form-7', 'wpcf7.cached = 0;', 'before' );
|
|
}
|
|
}
|
|
add_filter( 'wpcf7_load_js', '__return_false' );
|
|
add_filter( 'wpcf7_load_css', '__return_false' );
|
|
add_action( 'wp_enqueue_scripts', 'wpcf7_custom_enqueue_scripts', 10000, 0 );
|