PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / 1.6.3
Image Optimizer – Compress Images and Convert to WebP or AVIF v1.6.3
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.6.3, at modules/stats/rest/get-stats.php

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