Notifications
10 months ago
Settings
10 months ago
Config.php
1 year ago
ConflictingPlugins.php
10 months ago
Cron.php
1 year ago
NitroPack.php
11 months ago
Settings.php
10 months ago
ConflictingPlugins.php
136 lines
| 1 | <?php |
| 2 | namespace NitroPack\WordPress; |
| 3 | |
| 4 | /** |
| 5 | * Class ConflictingPlugins |
| 6 | * |
| 7 | * This class is responsible for managing conflicting plugins in WordPress. |
| 8 | * It provides methods to retrieve a list of known conflicting plugins and check if any are active. |
| 9 | */ |
| 10 | class ConflictingPlugins { |
| 11 | private static $instance = NULL; |
| 12 | public static function getInstance() { |
| 13 | if ( ! self::$instance ) { |
| 14 | self::$instance = new ConflictingPlugins(); |
| 15 | } |
| 16 | |
| 17 | return self::$instance; |
| 18 | } |
| 19 | /** |
| 20 | * Returns an array of conflicting plugins with their names and plugin paths. |
| 21 | * |
| 22 | * @return array<string, string> |
| 23 | */ |
| 24 | |
| 25 | public function nitropack_get_conflicting_plugins() { |
| 26 | $clashingPlugins = array(); |
| 27 | |
| 28 | if ( defined( 'BREEZE_PLUGIN_DIR' ) ) { |
| 29 | $clashingPlugins[] = array( 'name' => 'Breeze', 'plugin' => 'breeze/breeze.php' ); |
| 30 | } |
| 31 | |
| 32 | if ( defined( 'WP_ROCKET_VERSION' ) ) { |
| 33 | $clashingPlugins[] = array( 'name' => 'WP-Rocket', 'plugin' => 'wp-rocket/wp-rocket.php' ); |
| 34 | } |
| 35 | |
| 36 | if ( defined( 'W3TC' ) ) { |
| 37 | $clashingPlugins[] = array( 'name' => 'W3 Total Cache', 'plugin' => 'w3-total-cache/w3-total-cache.php' ); |
| 38 | } |
| 39 | |
| 40 | if ( defined( 'WPFC_MAIN_PATH' ) ) { |
| 41 | $clashingPlugins[] = array( 'name' => 'WP Fastest Cache', 'plugin' => 'wp-fastest-cache/wpFastestCache.php' ); |
| 42 | } |
| 43 | |
| 44 | if ( defined( 'PHASTPRESS_VERSION' ) ) { |
| 45 | $clashingPlugins[] = array( 'name' => 'PhastPress', 'plugin' => 'phastpress/phastpress.php' ); |
| 46 | } |
| 47 | |
| 48 | if ( defined( 'WPCACHEHOME' ) && function_exists( "wp_cache_phase2" ) ) { |
| 49 | $clashingPlugins[] = array( 'name' => 'WP Super Cache', 'plugin' => 'wp-super-cache/wp-cache.php' ); |
| 50 | } |
| 51 | |
| 52 | if ( defined( 'LSCACHE_ADV_CACHE' ) || defined( 'LSCWP_DIR' ) ) { |
| 53 | $clashingPlugins[] = array( 'name' => 'LiteSpeed Cache', 'plugin' => 'litespeed-cache/litespeed-cache.php' ); |
| 54 | } |
| 55 | |
| 56 | if ( class_exists( 'Swift_Performance' ) || class_exists( 'Swift_Performance_Lite' ) ) { |
| 57 | $clashingPlugins[] = array( 'name' => 'Swift Performance Lite', 'plugin' => 'swift-performance-lite/performance.php' ); |
| 58 | } |
| 59 | |
| 60 | if ( class_exists( 'PagespeedNinja' ) ) { |
| 61 | $clashingPlugins[] = array( 'name' => 'PageSpeed Ninja', 'plugin' => 'psn-pagespeed-ninja/pagespeedninja.php' ); |
| 62 | } |
| 63 | |
| 64 | if ( defined( 'AUTOPTIMIZE_PLUGIN_VERSION' ) ) { |
| 65 | $clashingPlugins[] = array( 'name' => 'Autoptimize', 'plugin' => 'autoptimize/autoptimize.php' ); |
| 66 | } |
| 67 | |
| 68 | if ( class_exists( 'WP_Hummingbird' ) || class_exists( 'Hummingbird\\WP_Hummingbird' ) ) { |
| 69 | $clashingPlugins[] = array( 'name' => 'Hummingbird', 'plugin' => 'hummingbird-performance/wp-hummingbird.php' ); |
| 70 | } |
| 71 | |
| 72 | if ( defined( 'WP_SMUSH_VERSION' ) ) { |
| 73 | //free version |
| 74 | $name = 'Smush'; |
| 75 | $plugin_path = 'wp-smushit/wp-smush.php'; |
| 76 | if ( is_plugin_active( 'wp-smush-pro/wp-smush.php' ) ) { |
| 77 | $name = 'Smush Pro'; |
| 78 | $plugin_path = 'wp-smush-pro/wp-smush.php'; |
| 79 | } |
| 80 | if ( class_exists( 'Smush\\Core\\Settings' ) && defined( 'WP_SMUSH_PREFIX' ) ) { |
| 81 | $smushLazy = \Smush\Core\Settings::get_instance()->get( 'lazy_load' ); |
| 82 | if ( $smushLazy ) { |
| 83 | $clashingPlugins[] = array( 'name' => $name . ' - Lazy Load', 'plugin' => $plugin_path ); |
| 84 | } |
| 85 | } else { |
| 86 | $clashingPlugins[] = array( 'name' => $name, 'plugin' => $plugin_path ); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | if ( defined( 'COMET_CACHE_PLUGIN_FILE' ) ) { |
| 91 | $clashingPlugins[] = array( 'name' => 'Comet Cache', 'plugin' => 'comet-cache/comet-cache.php' ); |
| 92 | } |
| 93 | |
| 94 | if ( defined( 'WPO_VERSION' ) && class_exists( 'WPO_Cache_Config' ) ) { |
| 95 | $wpo_cache_config = \WPO_Cache_Config::instance(); |
| 96 | if ( $wpo_cache_config->get_option( 'enable_page_caching', false ) ) { |
| 97 | $clashingPlugins[] = array( 'name' => 'WP Optimize page caching', 'plugin' => 'wp-optimize/wp-optimize.php' ); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | if ( class_exists( 'BJLL' ) ) { |
| 102 | $clashingPlugins[] = array( 'name' => 'BJ Lazy Load', 'plugin' => 'bj-lazy-load/bj-lazy-load.php' ); |
| 103 | } |
| 104 | |
| 105 | if ( defined( 'SHORTPIXEL_IMAGE_OPTIMISER_VERSION' ) && class_exists( '\ShortPixel\ShortPixelPlugin' ) ) { |
| 106 | $sp_config = \ShortPixel\ShortPixelPlugin::getInstance(); |
| 107 | if ( $sp_config->settings()->createWebp ) { |
| 108 | $clashingPlugins[] = array( 'name' => 'ShortPixel Image Optimizer', 'plugin' => 'shortpixel-image-optimiser/shortpixel-plugin.php' ); |
| 109 | } |
| 110 | } |
| 111 | if ( defined( 'RAPIDLOAD_PLUGIN_URL' ) ) { |
| 112 | $clashingPlugins[] = array( 'name' => 'RapidLoad AI', 'plugin' => 'unusedcss/unusedcss.php' ); |
| 113 | } |
| 114 | if ( defined( 'JETPACK_BOOST_VERSION' ) ) { |
| 115 | $clashingPlugins[] = array( 'name' => 'Jetpack Boost', 'plugin' => 'jetpack-boost/jetpack-boost.php' ); |
| 116 | } |
| 117 | if ( defined( 'SiteGround_Optimizer\VERSION' ) ) { |
| 118 | $clashingPlugins[] = array( 'name' => 'SiteGround Optimizer', 'plugin' => 'sg-cachepress/sg-cachepress.php' ); |
| 119 | } |
| 120 | if ( defined( 'A3_LAZY_VERSION' ) ) { |
| 121 | $clashingPlugins[] = array( 'name' => 'a3 Lazy Load', 'plugin' => 'a3-lazy-load/a3-lazy-load.php' ); |
| 122 | } |
| 123 | |
| 124 | return $clashingPlugins; |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Checks if any conflicting plugin is active. |
| 129 | * |
| 130 | * @return bool |
| 131 | */ |
| 132 | public function nitropack_is_conflicting_plugin_active() { |
| 133 | $conflictingPlugins = $this->nitropack_get_conflicting_plugins(); |
| 134 | return ! empty( $conflictingPlugins ); |
| 135 | } |
| 136 | } |