PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / 1.0.0
Image Optimizer – Compress Images and Convert to WebP or AVIF v1.0.0
1.7.7 1.7.6 1.7.5 1.7.4 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 All 33 releases
image-optimization / modules / stats / rest / get-stats.php

get-stats.php in Image Optimizer – Compress Images and Convert to WebP or AVIF 1.0.0, at modules/stats/rest/get-stats.php

33 lines 595 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ImageOptimizer\Modules\Stats\Rest;
4
5 use ImageOptimizer\Modules\Stats\Classes\{
6 Route_Base,
7 Stats
8 };
9 use Throwable;
10
11 class Get_Stats extends Route_Base {
12 protected string $path = '';
13
14 public function get_name(): string {
15 return 'get-stats';
16 }
17
18 public function get_methods(): array {
19 return [ 'GET' ];
20 }
21
22 public function GET() {
23 try {
24 return $this->respond_success_json( Stats::calculate_global_stats() );
25 } catch ( Throwable $t ) {
26 return $this->respond_error_json([
27 'message' => $t->getMessage(),
28 'code' => 'internal_server_error',
29 ]);
30 }
31 }
32 }
33