PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 4.7.0
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v4.7.0
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
← All changes | cache/class-wpo-cache-rules.php +20 -0 4.5.2 → 4.7.0 View file →
@@ -52,8 +52,10 @@
52 52
53 53 add_action('woocommerce_variation_set_stock', array($this, 'purge_product_page'), 10, 1);
54 54 add_action('woocommerce_product_set_stock', array($this, 'purge_product_page'), 10, 1);
55 55
56 + add_filter('wpo_page_cache_preloader_dont_close_browser_connection', array($this, 'preloader_dont_close_browser_connection'), 10, 1);
57 +
56 58 /**
57 59 * List of hooks for which when executed, the cache will be purged
58 60 *
59 61 * @param array $actions The actions
@@ -432,8 +434,26 @@
432 434 if (!empty($this->config['enable_page_caching'])) {
433 435 wpo_cache_flush();
434 436 WPO_Page_Cache::instance()->file_log("Full Cache Purge triggered by action: " . current_filter());
435 437 }
438 + }
439 +
440 + /**
441 + * Filter to set the flag to not close the browser connection when running via AJAX in the preloader.
442 + *
443 + * @param bool $dont_close_browser_connection The current value of the flag to not close the browser connection. Default is false.
444 + *
445 + * @return bool
446 + */
447 + public function preloader_dont_close_browser_connection($dont_close_browser_connection) {
448 + if ($dont_close_browser_connection) return $dont_close_browser_connection;
449 +
450 + // In WooCommerce, when the stock is updated for a product or a variation, it triggers an AJAX request in the background.
451 + // In this case, we want to avoid closing the browser connection in the preloader, to allow the product edit page to receive the response.
452 + if (did_action('woocommerce_variation_set_stock') || did_action('woocommerce_product_set_stock')) {
453 + return true;
454 + }
455 + return false;
436 456 }
437 457
438 458 /**
439 459 * Triggered by wpo_cache_config_updated.