' . esc_html__('Please consider disabling the following detected plugins, as they may conflict with LiteSpeed Cache:', 'litespeed-cache') . '

' . 'PageSpeed Ninja' . '

' . '', false, true ); } } public static function activated_plugin($plugin, $network_wide) { self::incompatible_plugin_notice($plugin, $network_wide, 'activated'); } public static function deactivated_plugin($plugin, $network_wide) { self::incompatible_plugin_notice($plugin, $network_wide, 'deactivated'); } /** * Detect any incompatible plugins that are currently `active` and `valid`. * Show a notification if there are any. */ public static function incompatible_plugin_notice($plugin, $_network_wide, $action) { self::update_messages(); /** * The 'deactivated_plugin' action fires before * `wp_get_active_and_valid_plugins` can see the change, so we'll need to * remove `$plugin` from the list. */ $deactivated = 'deactivated' === $action ? array($plugin) : array(); $incompatible_plugins = array_map(function ($plugin) { return WP_PLUGIN_DIR . '/' . $plugin; }, array_diff(self::$_incompatible_plugins, $deactivated)); $active_incompatible_plugins = array_map(function ($plugin) { $plugin = get_plugin_data($plugin, false, true); return $plugin['Name']; }, array_intersect($incompatible_plugins, wp_get_active_and_valid_plugins())); if (empty($active_incompatible_plugins)) { return; } \LiteSpeed\Admin_Display::error( '
' . esc_html__('Please consider disabling the following detected plugins, as they may conflict with LiteSpeed Cache:', 'litespeed-cache') . '

' . implode(', ', $active_incompatible_plugins) . '

' . '
', false, true ); } /** * Prevent multiple incompatible plugin notices, in case an admin (de)activates * a number of incompatible plugins in succession without dismissing the * notice(s). */ private static function update_messages() { $messages = \LiteSpeed\Admin_Display::get_option(\LiteSpeed\Admin_Display::DB_MSG_PIN, array()); if (is_array($messages)) { foreach ($messages as $index => $message) { if (strpos($message, self::$_msg_id) !== false) { unset($messages[$index]); if (!$messages) { $messages = -1; } \LiteSpeed\Admin_Display::update_option(\LiteSpeed\Admin_Display::DB_MSG_PIN, $messages); break; } } } } }