Plugin Directory

Changeset 2574499


Ignore:
Timestamp:
07/29/2021 08:21:04 AM (4 years ago)
Author:
gianlucagaspari
Message:

1.0.1 version

Location:
cf7-optimizer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cf7-optimizer/trunk/cf7-optimizer.php

    r2574486 r2574499  
    44 * Plugin URI: https://github.com/gianlucagaspari/contact-form-7-optimizer
    55 * Description: Removes js, css and ajax behaviors from Contact Form 7 that may slow the site
    6  * Version: 1.0
    7  * Author: Gianluca
     6 * Version: 1.0.1
     7 * Author: Five Studio
    88 * Author URI: https://www.fivestudio.it
    99 * Tested up to: 5.8
     
    1414 */
    1515function wpcf7_custom_enqueue_scripts() {
    16     wp_dequeue_script( 'wpcf7-recaptcha' );
    17     wp_dequeue_script( 'google-recaptcha' );
    18     wp_dequeue_style( 'contact-form-7' );
    19     global $post;
    20     if ( isset( $post->post_content ) && has_shortcode( $post->post_content, 'contact-form-7' ) ) {
    21         if ( function_exists( 'wpcf7_enqueue_scripts' ) ) {
    22             wpcf7_enqueue_scripts();
    23             wp_enqueue_script( 'wpcf7-recaptcha' );
    24             wp_enqueue_script( 'google-recaptcha' );
     16    if ( is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) ) {
     17        wp_dequeue_script( 'wpcf7-recaptcha' );
     18        wp_dequeue_script( 'google-recaptcha' );
     19        wp_dequeue_style( 'contact-form-7' );
     20        global $post;
     21        if ( isset( $post->post_content ) && has_shortcode( $post->post_content, 'contact-form-7' ) ) {
     22            if ( function_exists( 'wpcf7_enqueue_scripts' ) ) {
     23                wpcf7_enqueue_scripts();
     24                wp_enqueue_script( 'wpcf7-recaptcha' );
     25                wp_enqueue_script( 'google-recaptcha' );
     26            }
     27            if ( function_exists( 'wpcf7_enqueue_styles' ) ) {
     28                wpcf7_enqueue_styles();
     29            }
    2530        }
    26         if ( function_exists( 'wpcf7_enqueue_styles' ) ) {
    27             wpcf7_enqueue_styles();
     31        $service = WPCF7_RECAPTCHA::get_instance();
     32        if ( ! $service->is_active() ) {
     33            return;
    2834        }
     35        wp_add_inline_script( 'contact-form-7', 'wpcf7.cached = 0;', 'before' );
    2936    }
    30     $service = WPCF7_RECAPTCHA::get_instance();
    31     if ( ! $service->is_active() ) {
    32         return;
    33     }
    34     wp_add_inline_script( 'contact-form-7', 'wpcf7.cached = 0;', 'before' );
    3537}
    36 if ( is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) ) {
    37     add_filter( 'wpcf7_load_js', '__return_false' );
    38     add_filter( 'wpcf7_load_css', '__return_false' );
    39     add_action( 'wp_enqueue_scripts', 'wpcf7_custom_enqueue_scripts', 20, 0 );
    40 }
     38add_filter( 'wpcf7_load_js', '__return_false' );
     39add_filter( 'wpcf7_load_css', '__return_false' );
     40add_action( 'wp_enqueue_scripts', 'wpcf7_custom_enqueue_scripts', 10000, 0 );
  • cf7-optimizer/trunk/readme.txt

    r2574486 r2574499  
    44Requires PHP: 5.6
    55Tested up to: 5.8
    6 Stable tag: 1.0
     6Stable tag: 1.0.1
    77License: GPLv3 or later
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    2828= Version 1.0 - 28.07.2021 =
    2929* Initial release
     30
     31= Version 1.0.1 - 29.07.2021 =
     32* Fixed is_plugin_active potential error
Note: See TracChangeset for help on using the changeset viewer.