Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • In addition to my previous post..

    In case you’re using any scripts optimization plugins (WP Rocket, Autoptimize, etc.) and your are facing CF7 (5.4) related console errors, you should exclude from defer the following scripts:

    /jquery-?[0-9.]*(.min|.slim|.slim.min)?\.js
    /wp-includes/js/dist/vendor/wp-polyfill.min.js
    /wp-includes/js/dist/vendor/lodash.min.js
    /wp-includes/js/dist/api-fetch.min.js
    /wp-includes/js/dist/url.min.js

    After the 5.4 update, if you want to load CF7’s JS and CSS only on pages/posts where a CF7 shortcode is present you can put the following code in your child-theme’s functions.php (backup it first!).

    Hope this helps.

    /**
     * Conditionally Load CF7's Scripts and Styles Only Where Needed
     */
     
    /**
     * Dequeue:
     * 
     * contact-form-7
     * wp-i18n
     * lodash
     * wp-url
     * wp-hooks
     * wp-api-fetch
     * wp-polyfill (To completely dequeue this, also dequeue recaptcha scripts - see below)
     */
    add_filter( 'wpcf7_load_js', '__return_false' );
    
    // Dequeue contact-form-7 CSS
    add_filter( 'wpcf7_load_css', '__return_false' );
    
    function conditionally_enqueue_cf7_js_css() {
    
    	// Dequeue wpcf7-recaptcha
        wp_dequeue_script('wpcf7-recaptcha');
    	
    	// Dequeue google-recaptcha
    	wp_dequeue_script( 'google-recaptcha' );
    
        // If current post has cf7 shortcode, enqueue everything back
        global $post;
        if ( isset( $post->post_content ) AND 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();
    		}
        }
    }
    add_action( 'wp_enqueue_scripts', 'conditionally_enqueue_cf7_js_css', 20, 0 );
    Thread Starter Daniram

    (@daniram)

    @onlyincebu Thanks for your reply.

    ALL of installed plugins are up to date.

    On my staging site I only have 3 plugins activated (please read my first post) and the theme is a custom (very basic) one which did not give any problems or (JS/jQuery) conflicts after WordPress 5.5 update.

    Already checked Health Check & Troubleshooting plugin and nothing partcular is showing up there.

    If I revert to Yoast SEO 14.8.1 everything is working back again normally (here again, please read my first post and screenshots…).

    So the only variable here would seem to be Yoast SEO 14.9.

    Also, I noticed that in Yoast SEO 14.9 you made some modification on how DB queries are performed. Might that be the culprit?

    Thanks,
    Dan

    Thread Starter Daniram

    (@daniram)

    @devnihil Thanks for your reply.

    Forgot to mention that installed WordPress version is 5.5.1. Sorry for that.

    Here you can see two slow queries which shows up in Query Monitor after updating Yoast SEO to 14.9: https://ibb.co/7zFbPk6.

    Hope this helps,
    Dan

    Thread Starter Daniram

    (@daniram)

    Just wanted to add a quick note that I was able to add_action to wp_head succesfully with the following code:

    add_action( 'wp', function() {
    
    	remove_action( 'wp_print_footer_scripts', array( 'PLL_Cache_Compat', 'add_cookie_script' ) ); /*NOT WORKING!*/
    
    	add_action( 'wp_head', array(new PLL_Cache_Compat, 'add_cookie_script' ) ); /*WORKING FINE*/
    
    });

    But unfortunately I am not able to remove_action from wp_print_footer_scripts, is there a way to remove it?

    Thanks!

    Thread Starter Daniram

    (@daniram)

    Thank you for your reply. This make sense to me. I verified at whatismyipaddress.com/proxy-check and ‘Header test’ resulted positive, so the client is using a proxy server.

    I know which is the real IP address as I whitelisted it in the .htaccess.
    Wordfence notifies the real IP, while Sucuri the fake one (proxy).

    One last question though. How is it possible that the fake IP address has access to the /wp-admin area which is protected by the .htaccess rule (see my previous post)?

    Thanks again for you help.

Viewing 7 replies - 1 through 7 (of 7 total)