From 628323a5f54c677f1601a4c12bf78903b37b6bd4 Mon Sep 17 00:00:00 2001 From: selul Date: Tue, 1 Sep 2026 11:34:27 +0300 Subject: [PATCH 1/3] fix: gate Jetpack conflict notice on Photon --- inc/conflicts/conflicting_plugins.php | 10 +++- tests/test-jetpack-conflicts.php | 84 +++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 tests/test-jetpack-conflicts.php diff --git a/inc/conflicts/conflicting_plugins.php b/inc/conflicts/conflicting_plugins.php index 721a3a13..d254a599 100644 --- a/inc/conflicts/conflicting_plugins.php +++ b/inc/conflicts/conflicting_plugins.php @@ -54,7 +54,7 @@ private function defined_plugins() { 'litespeed' => 'litespeed-cache/litespeed-cache.php', 'autoptimize' => 'autoptimize/autoptimize.php', 'perfmatters' => 'perfmatters/perfmatters.php', - 'jetpack_Photon' => 'jetpack/jetpack.php', + 'jetpack_Photon' => 'jetpack/jetpack.php', // 'plugin-slug' => 'plugin-folder/plugin-file.php' ]; @@ -73,6 +73,14 @@ private function get_active_plugins() { $conflicting_plugins = $this->defined_plugins(); $conflicting_plugins = array_filter( $conflicting_plugins, 'is_plugin_active' ); + + if ( + isset( $conflicting_plugins['jetpack_Photon'] ) && + ! ( new Optml_Jetpack_Photon() )->is_conflict_valid() + ) { + unset( $conflicting_plugins['jetpack_Photon'] ); + } + return apply_filters( 'optml_conflicting_active_plugins', $conflicting_plugins ); } diff --git a/tests/test-jetpack-conflicts.php b/tests/test-jetpack-conflicts.php new file mode 100644 index 00000000..daad4b67 --- /dev/null +++ b/tests/test-jetpack-conflicts.php @@ -0,0 +1,84 @@ +active_plugins = get_option( 'active_plugins', [] ); + update_option( + 'active_plugins', + array_merge( $this->active_plugins, [ 'jetpack/jetpack.php' ] ) + ); + } + + /** + * Restore active plugins after each test. + */ + public function tear_down() { + Jetpack::$photon_active = false; + update_option( 'active_plugins', $this->active_plugins ); + + parent::tear_down(); + } + + /** + * Jetpack without Photon should not be a generic conflict. + */ + public function test_jetpack_without_photon_is_not_a_generic_conflict() { + $conflicts = new Optml_Conflicting_Plugins(); + + $this->assertNotContains( 'jetpack/jetpack.php', $conflicts->get_conflicting_plugins( true ) ); + } + + /** + * Jetpack with Photon should remain a generic conflict. + */ + public function test_jetpack_with_photon_is_a_generic_conflict() { + Jetpack::$photon_active = true; + $conflicts = new Optml_Conflicting_Plugins(); + + $this->assertContains( 'jetpack/jetpack.php', $conflicts->get_conflicting_plugins( true ) ); + } +} + +if ( ! class_exists( 'Jetpack', false ) ) { + /** + * Minimal Jetpack test double. + */ + class Jetpack { + /** + * Whether Photon is active. + * + * @var bool + */ + public static $photon_active = false; + + /** + * Check whether a module is active. + * + * @param string $module Module slug. + * @return bool + */ + public static function is_module_active( $module ) { + return 'photon' === $module && self::$photon_active; + } + } +} From b32e40ccf0c56044e13b3aff69d6a4a885afcd4f Mon Sep 17 00:00:00 2001 From: selul Date: Tue, 1 Sep 2026 11:50:36 +0300 Subject: [PATCH 2/3] refactor: centralize Jetpack Photon status --- inc/conflicts/conflicting_plugins.php | 5 +++- inc/conflicts/jetpack_photon.php | 12 ++------ inc/v2/Integrations/JetpackStatus.php | 41 +++++++++++++++++++++++++++ tests/test-jetpack-conflicts.php | 5 ++++ 4 files changed, 53 insertions(+), 10 deletions(-) create mode 100644 inc/v2/Integrations/JetpackStatus.php diff --git a/inc/conflicts/conflicting_plugins.php b/inc/conflicts/conflicting_plugins.php index d254a599..e5ed5b6b 100644 --- a/inc/conflicts/conflicting_plugins.php +++ b/inc/conflicts/conflicting_plugins.php @@ -1,4 +1,7 @@ is_conflict_valid() + ! JetpackStatus::is_photon_active() ) { unset( $conflicting_plugins['jetpack_Photon'] ); } diff --git a/inc/conflicts/jetpack_photon.php b/inc/conflicts/jetpack_photon.php index 533b81e2..1d4915af 100644 --- a/inc/conflicts/jetpack_photon.php +++ b/inc/conflicts/jetpack_photon.php @@ -1,5 +1,7 @@ assertFalse( JetpackStatus::is_photon_active() ); $this->assertNotContains( 'jetpack/jetpack.php', $conflicts->get_conflicting_plugins( true ) ); } @@ -55,6 +59,7 @@ public function test_jetpack_with_photon_is_a_generic_conflict() { Jetpack::$photon_active = true; $conflicts = new Optml_Conflicting_Plugins(); + $this->assertTrue( JetpackStatus::is_photon_active() ); $this->assertContains( 'jetpack/jetpack.php', $conflicts->get_conflicting_plugins( true ) ); } } From 7a82eabe52a7b3f282347e364eea6822a7b56e73 Mon Sep 17 00:00:00 2001 From: selul Date: Tue, 1 Sep 2026 12:03:38 +0300 Subject: [PATCH 3/3] refactor: register Photon conflict as compatibility --- .../jetpack_photon_compatibility.php | 57 +++++++++++++++++++ inc/conflicts/conflicting_plugins.php | 10 ---- inc/conflicts/jetpack_photon.php | 6 +- inc/manager.php | 1 + inc/v2/Integrations/JetpackStatus.php | 41 ------------- tests/test-jetpack-conflicts.php | 20 +++++-- 6 files changed, 77 insertions(+), 58 deletions(-) create mode 100644 inc/compatibilities/jetpack_photon_compatibility.php delete mode 100644 inc/v2/Integrations/JetpackStatus.php diff --git a/inc/compatibilities/jetpack_photon_compatibility.php b/inc/compatibilities/jetpack_photon_compatibility.php new file mode 100644 index 00000000..1dfefff3 --- /dev/null +++ b/inc/compatibilities/jetpack_photon_compatibility.php @@ -0,0 +1,57 @@ + $plugins Conflicting plugin definitions. + * @return array + */ + public function add_conflicting_plugin( $plugins ) { + $plugins[ self::CONFLICT_KEY ] = self::PLUGIN_FILE; + + return $plugins; + } + + /** + * Register before the generic conflict notice is evaluated. + * + * @return bool + */ + public function should_load_early() { + return true; + } +} diff --git a/inc/conflicts/conflicting_plugins.php b/inc/conflicts/conflicting_plugins.php index e5ed5b6b..4b13a755 100644 --- a/inc/conflicts/conflicting_plugins.php +++ b/inc/conflicts/conflicting_plugins.php @@ -1,7 +1,5 @@ 'litespeed-cache/litespeed-cache.php', 'autoptimize' => 'autoptimize/autoptimize.php', 'perfmatters' => 'perfmatters/perfmatters.php', - 'jetpack_Photon' => 'jetpack/jetpack.php', // 'plugin-slug' => 'plugin-folder/plugin-file.php' ]; @@ -77,13 +74,6 @@ private function get_active_plugins() { $conflicting_plugins = $this->defined_plugins(); $conflicting_plugins = array_filter( $conflicting_plugins, 'is_plugin_active' ); - if ( - isset( $conflicting_plugins['jetpack_Photon'] ) && - ! JetpackStatus::is_photon_active() - ) { - unset( $conflicting_plugins['jetpack_Photon'] ); - } - return apply_filters( 'optml_conflicting_active_plugins', $conflicting_plugins ); } diff --git a/inc/conflicts/jetpack_photon.php b/inc/conflicts/jetpack_photon.php index 1d4915af..b545c986 100644 --- a/inc/conflicts/jetpack_photon.php +++ b/inc/conflicts/jetpack_photon.php @@ -1,7 +1,5 @@ should_load(); } } diff --git a/inc/manager.php b/inc/manager.php index ffb713c7..07020fde 100644 --- a/inc/manager.php +++ b/inc/manager.php @@ -104,6 +104,7 @@ final class Optml_Manager { 'wpsp', 'jetengine', 'jetpack', + 'jetpack_photon_compatibility', 'wp_rocket', 'wp_super_cache', 'breeze', diff --git a/inc/v2/Integrations/JetpackStatus.php b/inc/v2/Integrations/JetpackStatus.php deleted file mode 100644 index 3ebf5e86..00000000 --- a/inc/v2/Integrations/JetpackStatus.php +++ /dev/null @@ -1,41 +0,0 @@ -active_plugins = get_option( 'active_plugins', [] ); + $this->compatibility = new Optml_jetpack_photon_compatibility(); update_option( 'active_plugins', array_merge( $this->active_plugins, [ 'jetpack/jetpack.php' ] ) @@ -36,6 +42,7 @@ public function set_up() { * Restore active plugins after each test. */ public function tear_down() { + remove_filter( 'optml_conflicting_defined_plugins', [ $this->compatibility, 'add_conflicting_plugin' ] ); Jetpack::$photon_active = false; update_option( 'active_plugins', $this->active_plugins ); @@ -47,8 +54,10 @@ public function tear_down() { */ public function test_jetpack_without_photon_is_not_a_generic_conflict() { $conflicts = new Optml_Conflicting_Plugins(); + $conflict = new Optml_Jetpack_Photon(); - $this->assertFalse( JetpackStatus::is_photon_active() ); + $this->assertFalse( $this->compatibility->should_load() ); + $this->assertFalse( $conflict->is_conflict_valid() ); $this->assertNotContains( 'jetpack/jetpack.php', $conflicts->get_conflicting_plugins( true ) ); } @@ -57,9 +66,12 @@ public function test_jetpack_without_photon_is_not_a_generic_conflict() { */ public function test_jetpack_with_photon_is_a_generic_conflict() { Jetpack::$photon_active = true; + $this->compatibility->register(); $conflicts = new Optml_Conflicting_Plugins(); + $conflict = new Optml_Jetpack_Photon(); - $this->assertTrue( JetpackStatus::is_photon_active() ); + $this->assertTrue( $this->compatibility->should_load() ); + $this->assertTrue( $conflict->is_conflict_valid() ); $this->assertContains( 'jetpack/jetpack.php', $conflicts->get_conflicting_plugins( true ) ); } }