Skip to content
Open

Release #1137

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions inc/compatibilities/jetpack_photon_compatibility.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

/**
* Class Optml_jetpack_photon_compatibility.
*
* @reason Register Jetpack as a conflicting plugin when its image Site Accelerator is active.
*/
class Optml_jetpack_photon_compatibility extends Optml_compatibility {
/**
* Jetpack conflict key.
*/
const CONFLICT_KEY = 'jetpack_Photon';

/**
* Jetpack plugin file.
*/
const PLUGIN_FILE = 'jetpack/jetpack.php';

/**
* Check whether Jetpack's image Site Accelerator is active.
*
* @return bool Whether to load the compatibility.
*/
public function should_load() {
return class_exists( '\Jetpack', false ) && \Jetpack::is_module_active( 'photon' );
}

/**
* Register the Jetpack conflict integration.
*
* @return void
*/
public function register() {
add_filter( 'optml_conflicting_defined_plugins', [ $this, 'add_conflicting_plugin' ] );
}

/**
* Add Jetpack to the conflicting plugin definitions.
*
* @param array<string, string> $plugins Conflicting plugin definitions.
* @return array<string, string>
*/
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;
}
}
3 changes: 2 additions & 1 deletion inc/conflicts/conflicting_plugins.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* The Conflicting Plugins class, documents and displays dashboard notice for conflicting plugins.
*
Expand Down Expand Up @@ -54,7 +55,6 @@ private function defined_plugins() {
'litespeed' => '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'
];

Expand All @@ -73,6 +73,7 @@ private function get_active_plugins() {

$conflicting_plugins = $this->defined_plugins();
$conflicting_plugins = array_filter( $conflicting_plugins, 'is_plugin_active' );

return apply_filters( 'optml_conflicting_active_plugins', $conflicting_plugins );
}

Expand Down
10 changes: 2 additions & 8 deletions inc/conflicts/jetpack_photon.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,8 @@ public function define_message() {
* @access public
*/
public function is_conflict_valid() {
$compatibility = new Optml_jetpack_photon_compatibility();

if ( ! is_plugin_active( 'jetpack/jetpack.php' ) ) {
return false;
}
if ( ! class_exists( 'Jetpack', false ) ) {
return false;
}

return Jetpack::is_module_active( 'photon' );
return $compatibility->should_load();
}
}
Loading
Loading