Activating Caching Plugin breaks page
-
Hi bizswoop team,
I am using:
WP 5.4.2
WooCommerce 4.0.0
Store Hours Manager for WooCommerce 4.0.10
Theme: dt-the7 9.1.0The plugin works well, but as soon as I enable a caching plugin the site breaks when the cart is not empty.
I tried the following caching plugins: Autoptimize, WP Fastest Cache, WP Super Cache, WP-Optimize – Clean, Compress, Cache. With all plugins it’s the same problem.By ‘the site breaks’ I mean the following:
The first 350 lines of code are missing in the source code. No <html> or <head> tag. No css or js includes. No error in php log / debug.log. Everything before this code is missing:<style> .zhours_alertbutton { color: #ffffff; background-color: #fe6002; padding: 16px; font-size: 16px; } </style>
It seems to work fine, when Store Hours are open/enabled, but breaks if Store Hours are closed/disabled and the first item is added to the cart.
I tracked it down to the following line of code:
includes/Setup.php Line 62 to 67\add_action('woocommerce_after_mini_cart', function () { if (!WC()->cart->is_empty()) : \ob_end_clean(); get_alertbutton(); endif; });
If I comment out ob_end_clean(); it works as expected.
The caching plugins also use ob_start and ob_end_clean() for buffering. This seems to conflict.What is ob_start and ob_end_clean() necessary for in your plugin? Can I safely delete it?
Could you fix this in your plugin so it is compatible to future updates?Thanks in advance
- The topic ‘Activating Caching Plugin breaks page’ is closed to new replies.