response ) ) { foreach ( $plugin_updates->response as $plugin_file => $plugin_data ) { $plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin_file ); $pending_plugins[] = array( 'name' => $plugin_info['Name'] ?? $plugin_file, 'current' => $plugin_info['Version'] ?? 'unknown', 'new_version' => $plugin_data->new_version ?? 'unknown', ); } } // Count theme updates. if ( ! empty( $theme_updates->response ) ) { foreach ( $theme_updates->response as $theme_slug => $theme_data ) { $theme = wp_get_theme( $theme_slug ); $pending_themes[] = array( 'name' => $theme->get( 'Name' ) ?: $theme_slug, 'current' => $theme->get( 'Version' ) ?: 'unknown', 'new_version' => $theme_data['new_version'] ?? 'unknown', ); } } $total_updates = count( $pending_plugins ) + count( $pending_themes ); $details = array( 'pending_plugins' => $pending_plugins, 'pending_themes' => $pending_themes, 'plugin_count' => count( $pending_plugins ), 'theme_count' => count( $pending_themes ), ); if ( 0 === $total_updates ) { return static::pass( __( 'All your plugins and themes are up to date. Great job keeping your site secure!', '0-day-analytics' ), $details ); } // Build list of what needs updating. $update_list = array(); foreach ( array_slice( $pending_plugins, 0, 3 ) as $plugin ) { $update_list[] = $plugin['name']; } foreach ( array_slice( $pending_themes, 0, 2 ) as $theme ) { $update_list[] = $theme['name']; } $remaining = $total_updates - count( $update_list ); $list_text = implode( ', ', $update_list ); if ( $remaining > 0 ) { /* translators: %d: number of additional updates */ $list_text .= sprintf( __( ' and %d more', '0-day-analytics' ), $remaining ); } if ( $total_updates >= 5 ) { return static::fail( 'high', sprintf( /* translators: 1: number of updates, 2: list of items needing updates */ __( 'You have %1$d pending updates: %2$s. Outdated plugins and themes are one of the most common ways hackers break into WordPress sites.', '0-day-analytics' ), $total_updates, $list_text ), __( 'Go to Dashboard → Updates and install all available updates. Always backup your site before updating, especially for major version changes.', '0-day-analytics' ), $details ); } if ( $total_updates >= 2 ) { return static::warning( sprintf( /* translators: 1: number of updates, 2: list of items needing updates */ __( 'You have %1$d pending updates: %2$s. Updates often include security fixes.', '0-day-analytics' ), $total_updates, $list_text ), __( 'Go to Dashboard → Updates to install available updates. Review the changelog for any breaking changes before updating.', '0-day-analytics' ), $details ); } return static::warning( sprintf( /* translators: %s: name of item needing update */ __( 'One update available: %s. Keep your site secure by staying up to date.', '0-day-analytics' ), $list_text ), __( 'Go to Dashboard → Updates to install the available update.', '0-day-analytics' ), $details ); } } }