Other plugins called twice when WP Optimize enabled
-
Issue
When enabled, WP Optimize appears to be the cause of other plugins loading twice – even when all its settings are disabled, and saved. This happens with all other plugins disabled (except HeartBeat Control, to rule out heartbeat AJAX calls loading a page). Observed under both Apache and NginX on Windows, with different PHP versions.
The environment is local development and no web-accessible page is available.
Details
Clean test environment using Laragon in Windows.
Simple test plugin My Plugin was created with a single callback to enqueue scripts, code below. A separate MU logging function loggit() is used to log what’s happening.
Logging takes place:
– when the plugin is called
– within the wp_enqueue_scripts callbackCSS and JS dummy files are loaded, containing only a single comment line. Here is the My Plugin code.
<?php is the My Plugin cde
/**
* Plugin Name: My Plugin
* Description: A simple plugin that enqueues CSS and JS files.
* Version: 1.0
* Author: Your Name
*/
// Prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
loggit('-- My Plugin called');
// Enqueue CSS and JavaScript files
function my_plugin_enqueue_scripts() {
loggit(' -- -- My Plugin: my_plugin_enqueue_scripts() called.');
// Enqueue CSS
wp_enqueue_style( 'my-plugin-style', plugin_dir_url( __FILE__ ) . 'css/my-plugin.css' );
// Enqueue JavaScript
wp_enqueue_script( 'my-plugin-script', plugin_dir_url( __FILE__ ) . 'js/my-plugin.js', array( 'jquery' ), '1.0', true );
}
// Hook to enqueue scripts
add_action( 'wp_enqueue_scripts', 'my_plugin_enqueue_scripts' );Tests with Apache (Windows)
Environment:
WordPress under Laragon (Windows 10, 64 bit)
Laragon has: MySQL 8.4.0-win64, Apache 2.4.35-win64 with PHP 7.4.5-win32Theme:
Twenty Twenty-three (no child theme)Plugins active:
– Heartbeat Control by WP Rocket (with heartbeat disabled everywhere)
– My PluginWP Optimize 3.8.0 enabled
Chrome cache cleared, Apache restarted.
WordPress Sample page loaded => My Plugin is called three times ??12/12/2024 13:39:14 Function include_once() -- My Plugin called 12/12/2024 13:39:14 Function include_once() -- My Plugin called 12/12/2024 13:39:14 Function my_plugin_enqueue_scripts() -- -- My Plugin: my_plugin_enqueue_scripts() called. 12/12/2024 13:39:15 Function include_once() -- My Plugin called 12/12/2024 13:39:15 Function my_plugin_enqueue_scripts() -- -- My Plugin: my_plugin_enqueue_scripts() called.
WP Optimize 3.8.0 disabled
Chrome cache cleared, Apache restarted.
Sample page loaded (shift+reload in Chrome) => simple My Plugin called once. ??12/12/2024 13:42:38 Function include_once() -- My Plugin called 12/12/2024 13:42:38 Function my_plugin_enqueue_scripts() -- -- My Plugin: my_plugin_enqueue_scripts() called.
Repeating the Tests with Nginx Windows
Repeat test with Apache => Nginx and a later PHP.
Laragon now has: MySQL 8.4.0-win64, Nginx 1.27.1 win, PHP 8.3.4-win32Chrome cache cleared, NginX restarted.
Sample page loaded (shift+reload in Chrome)
Results:
WP Optimize 3.8.0 disabled => My Plugin runs once, always ??
WP Optimize 3.8.0 enabled => My Plugin runs twice, always ??I absolutely love the database optimisation of the plugin (thank you!) which is the sole use I make of it in development, but am at a loss to explain why it appears to cause multiple loads of other plugins.
Your help is appreciated, thank you. ??
- You must be logged in to reply to this topic.