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
wp-optimize / includes / dashboard / class-wp-optimize-dashboard-cache.php

class-wp-optimize-dashboard-cache.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 4.7.0, at includes/dashboard/class-wp-optimize-dashboard-cache.php

45 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) die('Access denied.');
4
5 if (!class_exists('WP_Optimize_Dashboard_Cache')) :
6
7 /**
8 * Collects all data needed to render the Page Cache dashboard card.
9 */
10 class WP_Optimize_Dashboard_Cache implements WP_Optimize_Dashboard_Interface {
11
12 /**
13 * @return WpoDashboardCacheData
14 */
15 public function collect(): array {
16 $cache_manager = WP_Optimize()->get_page_cache();
17 $config = $cache_manager->config->get();
18 $active = !empty($config['enable_page_caching']);
19
20 $size_info = $cache_manager->get_cache_size();
21
22 $preloader_status = WP_Optimize_Page_Cache_Preloader::instance()->get_status_info();
23 $file_count = is_array($preloader_status) ? ($preloader_status['file_count'] ?? 0) : 0;
24 $files_cached = is_scalar($file_count) ? (int) $file_count : 0;
25 $last_cleared = (int) ($config['last_cleared'] ?? 0);
26
27 $cache_size_bytes = isset($size_info['size']) ? (int) $size_info['size'] : 0;
28
29 $cache_size_human = size_format($cache_size_bytes, 1) ?: '0 B';
30
31 return array(
32 'active' => $active,
33 'label' => __('Page cache', 'wp-optimize'),
34 'files_cached' => $files_cached,
35 'cache_size_bytes' => $cache_size_bytes,
36 'cache_size_human' => $cache_size_bytes > 0 ? $cache_size_human : '0 B',
37 'last_cleared_human' => WP_Optimize_Utils::human_time_diff_or_never($last_cleared),
38 'gzip_active' => (bool) WP_Optimize()->get_options()->get_option('is_gzip_compression_enabled', false),
39 'country_caching' => (bool) ($config['enable_cache_per_country'] ?? false), // Premium — always false in free.
40 'is_premium' => WP_Optimize::is_premium(),
41 );
42 }
43 }
44 endif;
45