This commit is contained in:
Javier Casares 2026-08-23 07:08:42 +00:00
commit e6cba7ef6a

View file

@ -511,6 +511,8 @@ function wpvulnerability_plugin_get_vulnerabilities_clean() {
*/
function wpvulnerability_plugin_show_lastupdated( $column_name, $plugin_file, $plugin_data ) {
static $plugins_data = null;
$now = time();
$year = strtotime( '-1 year', $now );
@ -533,11 +535,14 @@ function wpvulnerability_plugin_show_lastupdated( $column_name, $plugin_file, $p
if ( '' !== $plugin_slug ) {
// Retrieve the vulnerabilities for all plugins from the options table and decode the JSON.
$raw_plugins_data = is_multisite() ? get_site_option( 'wpvulnerability-plugins-data', '' ) : get_option( 'wpvulnerability-plugins-data', '' );
$plugins_data = json_decode( is_string( $raw_plugins_data ) ? $raw_plugins_data : '', true );
if ( ! is_array( $plugins_data ) ) {
$plugins_data = array();
// Retrieve the vulnerabilities for all plugins once per request; this
// callback runs for every row of the plugins list table.
if ( null === $plugins_data ) {
$raw_plugins_data = is_multisite() ? get_site_option( 'wpvulnerability-plugins-data', '' ) : get_option( 'wpvulnerability-plugins-data', '' );
$plugins_data = json_decode( is_string( $raw_plugins_data ) ? $raw_plugins_data : '', true );
if ( ! is_array( $plugins_data ) ) {
$plugins_data = array();
}
}
// Get the plugin data from the stored data.
@ -548,15 +553,11 @@ function wpvulnerability_plugin_show_lastupdated( $column_name, $plugin_file, $p
$pd_latest = is_scalar( $pd_latest_raw ) ? intval( $pd_latest_raw ) : 0;
if ( $pd_latest > 0 ) {
$timestamp = $pd_latest;
$df_raw = get_option( 'date_format', 'Y-m-d' );
$date_format = is_scalar( $df_raw ) ? (string) $df_raw : 'Y-m-d';
if ( function_exists( 'wp_date' ) ) {
$plugin_data_updated = (string) wp_date( $date_format, $timestamp );
} else {
$plugin_data_updated = gmdate( $date_format, $timestamp );
}
$plugin_data_ago = human_time_diff( $timestamp );
$timestamp = $pd_latest;
$df_raw = get_option( 'date_format', 'Y-m-d' );
$date_format = is_scalar( $df_raw ) ? (string) $df_raw : 'Y-m-d';
$plugin_data_updated = (string) wp_date( $date_format, $timestamp );
$plugin_data_ago = human_time_diff( $timestamp );
$warning_date = $pd_latest < $year;
$pd_closed_raw = $pd['closed'] ?? 0;
@ -587,7 +588,7 @@ function wpvulnerability_plugin_show_lastupdated( $column_name, $plugin_file, $p
* Adds a 'Last Updated' column to the plugins table list in the WordPress admin area.
*
* This function iterates over the existing columns in the plugins table and inserts a new column titled 'Last Updated'
* just before the 'auto-updates' column if it exists. If the 'auto-updates' column is not found, the 'Last Updated'
* just after the 'description' column if it exists. If the 'description' column is not found, the 'Last Updated'
* column is appended at the end. The function is typically hooked to the 'manage_plugins_columns' filter in WordPress
* to modify the columns of the plugins table.
*