get_admin_notices(); $has_error_notice = false; $plugin_files = array(); if (!empty($notices)) { foreach ($notices as $notice) { if (strpos($notice, 'has been deactivated due to an error: Plugin file does not exist') !== false) { // Extract plugin file from notice if (preg_match('/The plugin ([^ ]+)/', $notice, $match)) { $plugin_files[] = $match[1]; $has_error_notice = true; } } } } // Only proceed if a relevant notice was found if (!$has_error_notice || empty($plugin_files)) { return; } // Inject JavaScript with the specific plugin files ?>