PluginProbe
Image Optimization – Compress Images and Convert to WebP or AVIF / 1.6.6
Image Optimization – Compress Images and Convert to WebP or AVIF v1.6.6
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 1.6.6 All 32 releases
image-optimization / modules / oauth / components / checkpoint.php

checkpoint.php in Image Optimization – Compress Images and Convert to WebP or AVIF 1.6.6, at modules/oauth/components/checkpoint.php

62 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ImageOptimization\Modules\Oauth\Components;
4
5 use ImageOptimization\Classes\Utils;
6 use ImageOptimization\Modules\Oauth\Classes\Data;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 /**
13 * Class Checkpoint
14 */
15 class Checkpoint {
16
17 const ON_CONNECT = 'image-optimizer-connect';
18 const ON_DISCONNECT = 'image-optimizer-disconnect';
19 const ON_ACTIVATE = 'image-optimizer-activate';
20 const ON_DEACTIVATE = 'image-optimizer-deactivate';
21
22 /**
23 * event
24 *
25 * @param array $event_data
26 */
27 public static function event( array $event_data = [] ): void {
28 $event_name = current_action();
29 // only allow specific events
30 if ( ! in_array( $event_name, self::get_checkpoints() ) ) {
31 return;
32 }
33
34 $response = Utils::get_api_client()->make_request(
35 'POST',
36 'status/checkpoint',
37 [
38 'event_name' => $event_name,
39 'event_data' => $event_data,
40 ]
41 );
42 }
43
44 /**
45 * get_checkpoints
46 * @return string[]
47 */
48 public static function get_checkpoints(): array {
49 return [
50 self::ON_DISCONNECT,
51 self::ON_CONNECT,
52 self::ON_ACTIVATE,
53 self::ON_DEACTIVATE,
54 ];
55 }
56 public function __construct() {
57 foreach ( self::get_checkpoints() as $checkpoint ) {
58 add_action( $checkpoint, [ __CLASS__, 'event' ], 10, 0 );
59 }
60 }
61 }
62