0

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.

enter image description here

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).

1

Use 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;
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.