PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / 1.7.7
Image Optimizer – Compress Images and Convert to WebP or AVIF v1.7.7
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
← All changes | modules/stats/rest/get-stats.php +12 -2 1.0.0 → 1.7.7 View file →
@@ -1,14 +1,18 @@
1 1 <?php
2 2
3 -namespace ImageOptimizer\Modules\Stats\Rest;
3 +namespace ImageOptimization\Modules\Stats\Rest;
4 4
5 -use ImageOptimizer\Modules\Stats\Classes\{
5 +use ImageOptimization\Modules\Stats\Classes\{
6 6 Route_Base,
7 7 Stats
8 8 };
9 9 use Throwable;
10 10
11 +if ( ! defined( 'ABSPATH' ) ) {
12 + exit; // Exit if accessed directly.
13 +}
14 +
11 15 class Get_Stats extends Route_Base {
12 16 protected string $path = '';
13 17
14 18 public function get_name(): string {
@@ -19,8 +23,14 @@
19 23 return [ 'GET' ];
20 24 }
21 25
22 26 public function GET() {
27 + $error = $this->verify_capability();
28 +
29 + if ( $error ) {
30 + return $error;
31 + }
32 +
23 33 try {
24 34 return $this->respond_success_json( Stats::calculate_global_stats() );
25 35 } catch ( Throwable $t ) {
26 36 return $this->respond_error_json([