PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / trunk
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization vtrunk
4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 2.5.5 2.5.6 2.5.7 3.0.0 3.0.1 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.11.0 3.11.1 3.11.2 3.11.3 3.12.0 All 135 releases
optimole-wp / inc / compatibilities / jetpack_photon_compatibility.php

jetpack_photon_compatibility.php in Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization trunk, at inc/compatibilities/jetpack_photon_compatibility.php

58 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class Optml_jetpack_photon_compatibility.
5 *
6 * @reason Register Jetpack as a conflicting plugin when its image Site Accelerator is active.
7 */
8 class Optml_jetpack_photon_compatibility extends Optml_compatibility {
9 /**
10 * Jetpack conflict key.
11 */
12 const CONFLICT_KEY = 'jetpack_Photon';
13
14 /**
15 * Jetpack plugin file.
16 */
17 const PLUGIN_FILE = 'jetpack/jetpack.php';
18
19 /**
20 * Check whether Jetpack's image Site Accelerator is active.
21 *
22 * @return bool Whether to load the compatibility.
23 */
24 public function should_load() {
25 return class_exists( '\Jetpack', false ) && \Jetpack::is_module_active( 'photon' );
26 }
27
28 /**
29 * Register the Jetpack conflict integration.
30 *
31 * @return void
32 */
33 public function register() {
34 add_filter( 'optml_conflicting_defined_plugins', [ $this, 'add_conflicting_plugin' ] );
35 }
36
37 /**
38 * Add Jetpack to the conflicting plugin definitions.
39 *
40 * @param array<string, string> $plugins Conflicting plugin definitions.
41 * @return array<string, string>
42 */
43 public function add_conflicting_plugin( $plugins ) {
44 $plugins[ self::CONFLICT_KEY ] = self::PLUGIN_FILE;
45
46 return $plugins;
47 }
48
49 /**
50 * Register before the generic conflict notice is evaluated.
51 *
52 * @return bool
53 */
54 public function should_load_early() {
55 return true;
56 }
57 }
58