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

' . 'PageSpeed Ninja' . '

' . '' ); } } /** * Handle plugin activation. * * @since 4.7 * @param string $plugin Plugin path. * @param bool $network_wide Whether activated network-wide. * @return void */ public static function activated_plugin( $plugin, $network_wide ) { self::incompatible_plugin_notice($plugin, $network_wide, 'activated'); } /** * Handle plugin deactivation. * * @since 4.7 * @param string $plugin Plugin path. * @param bool $network_wide Whether deactivated network-wide. * @return void */ 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. * * @since 4.7 * @param string $plugin Plugin path. * @param bool $_network_wide Whether action is network-wide. * @param string $action Action type (activated|deactivated). * @return void */ public static function incompatible_plugin_notice( $plugin, $_network_wide, $action ) { self::update_messages(); $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( '
' . __('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. * * @since 4.7 * @return void */ 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; } } } } }