I'm trying to add Last updated
option in to the plugin description section. I've tried to use a code of one old plugin which still works, but I don't like the date format of last update.
function range_plu_plugin_meta( $plugin_meta, $plugin_file ) {
list( $slug ) = explode( '/', $plugin_file );
$slug_hash = md5( $slug );
$last_updated = get_transient( "range_plu_{$slug_hash}" );
if ( false === $last_updated ) {
$last_updated = range_plu_get_last_updated( $slug );
set_transient( "range_plu_{$slug_hash}", $last_updated, 86400 );
}
if ( $last_updated )
$plugin_meta['last_updated'] = 'Last Updated: ' . esc_html( $last_updated );
return $plugin_meta;
}
It would be nice to have different format like on the Wordpress page saying: Last updated: 3 months ago
That way user will be aware if plugin is still maintained - or in the future there will be a warning if plugin hasn't been updated more that 6 months (that's just an example).
I'm trying to add Last updated
option in to the plugin description section. I've tried to use a code of one old plugin which still works, but I don't like the date format of last update.
function range_plu_plugin_meta( $plugin_meta, $plugin_file ) {
list( $slug ) = explode( '/', $plugin_file );
$slug_hash = md5( $slug );
$last_updated = get_transient( "range_plu_{$slug_hash}" );
if ( false === $last_updated ) {
$last_updated = range_plu_get_last_updated( $slug );
set_transient( "range_plu_{$slug_hash}", $last_updated, 86400 );
}
if ( $last_updated )
$plugin_meta['last_updated'] = 'Last Updated: ' . esc_html( $last_updated );
return $plugin_meta;
}
It would be nice to have different format like on the Wordpress page saying: Last updated: 3 months ago
That way user will be aware if plugin is still maintained - or in the future there will be a warning if plugin hasn't been updated more that 6 months (that's just an example).
Share Improve this question asked Feb 20, 2020 at 7:11 mirsadmirsad 5571 gold badge4 silver badges8 bronze badges1 Answer
Reset to default 1Use this code instead:
function range_plu_plugin_meta( $plugin_meta, $plugin_file ) {
list( $slug ) = explode( '/', $plugin_file );
$slug_hash = md5( $slug );
$last_updated = get_transient( "range_plu_{$slug_hash}" );
if ( false === $last_updated ) {
$last_updated = range_plu_get_last_updated( $slug );
set_transient( "range_plu_{$slug_hash}", $last_updated, 86400 );
}
if ( $last_updated ) {
$last_updated = strtotime( $last_updated );
$last_updated = human_time_diff( $last_updated, current_time( 'timestamp' ) ) . ' ' . __( 'ago' );
$plugin_meta['last_updated'] = 'Last Updated: ' . esc_html( $last_updated );
}
return $plugin_meta;
}