@@ -109,26 +109,26 @@ public function handleAjaxGetCacheMetrics(): void {
109109 private function renderStatCards (array $ redis_stats ): void {
110110 $ stats = [
111111 [
112- 'title ' => __ ('Cache Hit Ratio ' , 'wps-cache ' ),
112+ 'title ' => __ ('Cache Hit Ratio ' , 'WPS-Cache ' ),
113113 'value ' => isset ($ redis_stats ['hit_ratio ' ]) ?
114114 number_format_i18n ($ redis_stats ['hit_ratio ' ], 2 ) . '% ' : 'N/A ' ,
115115 'metric ' => 'hit_ratio '
116116 ],
117117 [
118- 'title ' => __ ('Memory Usage ' , 'wps-cache ' ),
118+ 'title ' => __ ('Memory Usage ' , 'WPS-Cache ' ),
119119 'value ' => isset ($ redis_stats ['memory_used ' ]) ?
120120 size_format ($ redis_stats ['memory_used ' ]) : 'N/A ' ,
121121 'metric ' => 'memory_used '
122122 ],
123123 [
124- 'title ' => __ ('Cache Operations ' , 'wps-cache ' ),
124+ 'title ' => __ ('Cache Operations ' , 'WPS-Cache ' ),
125125 'value ' => number_format_i18n (
126126 ($ redis_stats ['hits ' ] ?? 0 ) + ($ redis_stats ['misses ' ] ?? 0 )
127127 ),
128128 'metric ' => 'total_ops '
129129 ],
130130 [
131- 'title ' => __ ('Server Uptime ' , 'wps-cache ' ),
131+ 'title ' => __ ('Server Uptime ' , 'WPS-Cache ' ),
132132 'value ' => isset ($ redis_stats ['uptime ' ]) ?
133133 human_time_diff (time () - $ redis_stats ['uptime ' ]) : 'N/A '
134134 ]
@@ -162,13 +162,13 @@ private function renderStatCard(array $stat): void {
162162 */
163163 private function renderDetailedMetrics (array $ redis_stats ): void {
164164 ?>
165- <h3><?php _e ('Detailed Metrics ' , 'wps-cache ' ); ?> </h3>
165+ <h3><?php esc_html_e ('Detailed Metrics ' , 'WPS-Cache ' ); ?> </h3>
166166 <table class="widefat striped">
167167 <thead>
168168 <tr>
169- <th><?php _e ('Metric ' , 'wps-cache ' ); ?> </th>
170- <th><?php _e ('Value ' , 'wps-cache ' ); ?> </th>
171- <th><?php _e ('Trend ' , 'wps-cache ' ); ?> </th>
169+ <th><?php esc_html_e ('Metric ' , 'WPS-Cache ' ); ?> </th>
170+ <th><?php esc_html_e ('Value ' , 'WPS-Cache ' ); ?> </th>
171+ <th><?php esc_html_e ('Trend ' , 'WPS-Cache ' ); ?> </th>
172172 </tr>
173173 </thead>
174174 <tbody id="detailed-metrics">
@@ -183,15 +183,15 @@ private function renderDetailedMetrics(array $redis_stats): void {
183183 */
184184 private function renderMetricsTableRows (array $ stats ): void {
185185 $ metrics = [
186- 'hits ' => __ ('Cache Hits ' , 'wps-cache ' ),
187- 'misses ' => __ ('Cache Misses ' , 'wps-cache ' ),
188- 'hit_ratio ' => __ ('Hit Ratio ' , 'wps-cache ' ),
189- 'memory_used ' => __ ('Memory Usage ' , 'wps-cache ' ),
190- 'memory_peak ' => __ ('Peak Memory ' , 'wps-cache ' ),
191- 'total_connections ' => __ ('Total Connections ' , 'wps-cache ' ),
192- 'connected_clients ' => __ ('Connected Clients ' , 'wps-cache ' ),
193- 'evicted_keys ' => __ ('Evicted Keys ' , 'wps-cache ' ),
194- 'expired_keys ' => __ ('Expired Keys ' , 'wps-cache ' ),
186+ 'hits ' => __ ('Cache Hits ' , 'WPS-Cache ' ),
187+ 'misses ' => __ ('Cache Misses ' , 'WPS-Cache ' ),
188+ 'hit_ratio ' => __ ('Hit Ratio ' , 'WPS-Cache ' ),
189+ 'memory_used ' => __ ('Memory Usage ' , 'WPS-Cache ' ),
190+ 'memory_peak ' => __ ('Peak Memory ' , 'WPS-Cache ' ),
191+ 'total_connections ' => __ ('Total Connections ' , 'WPS-Cache ' ),
192+ 'connected_clients ' => __ ('Connected Clients ' , 'WPS-Cache ' ),
193+ 'evicted_keys ' => __ ('Evicted Keys ' , 'WPS-Cache ' ),
194+ 'expired_keys ' => __ ('Expired Keys ' , 'WPS-Cache ' ),
195195 ];
196196
197197 foreach ($ metrics as $ key => $ label ) {
@@ -237,15 +237,14 @@ private function formatMetricValue(string $key, mixed $value): string {
237237 /**
238238 * Gets Redis cache statistics
239239 */
240- private function getRedisStats (): ? array {
240+ private function getRedisStats (): array {
241241 $ redis_driver = $ this ->cache_manager ->getDriver ('redis ' );
242242 if (!$ redis_driver instanceof RedisCache) {
243- return null ;
243+ return [] ;
244244 }
245-
246245 return $ redis_driver ->getStats ();
247246 }
248-
247+
249248 /**
250249 * Gets HTML cache statistics
251250 */
0 commit comments