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 | minify/class-wp-optimize-minify-cache-functions.php +15 -2 4.6.1 → 4.7.0 View file →
@@ -353,10 +353,13 @@
353 353 continue;
354 354 }
355 355 $log[] = "cache expiration time - $expires";
356 356 $log[] = "checking if cache has expired - $d";
357 - if ($d !== $cache_time && (is_numeric($d) && $d <= $expires)) {
358 - $dir = WPO_CACHE_MIN_FILES_DIR.'/'.$d;
357 +
358 + $dir = WPO_CACHE_MIN_FILES_DIR.'/'.$d;
359 + $is_empty_dir = self::is_empty_minify_subdir($dir);
360 +
361 + if ($d !== (string) $cache_time && (is_numeric($d) && $d <= $expires || $is_empty_dir)) {
359 362 if (is_dir($dir)) {
360 363 $log[] = "deleting cache in $dir";
361 364 if (wpo_delete_files($dir)) {
362 365 $log[] = "files and folders are deleted recursively - $dir";
@@ -382,8 +385,18 @@
382 385 }
383 386 }
384 387
385 388 return $log;
389 + }
390 +
391 + /**
392 + * Checks whether the minify cache subdirectory (/ddddddddd/) is empty, i.e. whether the 'assets' and 'header' subdirectories contain no files.
393 + *
394 + * @param string $dir
395 + * @return boolean
396 + */
397 + private static function is_empty_minify_subdir($dir) {
398 + return wpo_is_empty_dir($dir . '/assets') && wpo_is_empty_dir($dir . '/header');
386 399 }
387 400
388 401 /**
389 402 * Get transients from the disk