Skip to content

Instantly share code, notes, and snippets.

@PeteMall
Created June 19, 2012 20:00
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PeteMall/2956201 to your computer and use it in GitHub Desktop.
Save PeteMall/2956201 to your computer and use it in GitHub Desktop.
Display the last updated date for all plugins from the WordPress.org plugins repo.
<?php
/*
Plugin Name: Plugin Last Updated
Version: 1.0
License: GPL
Author: Pete Mall, Range
Author URI: http://petemall.com/
Description: Display the last updated date for all plugins from the <a href="http://wordpress.org/extend/plugins/">WordPress.org plugins repo</a>.
*/
add_filter( 'plugin_row_meta', 'range_plu_plugin_meta', 10, 2 );
function range_plu_plugin_meta( $plugin_meta, $plugin_file ) {
list( $slug ) = explode( '/', $plugin_file );
$last_updated = get_transient( "range_plug_{$slug}_last_updated" );
if ( false === $last_updated ) {
$last_updated = range_plu_get_last_updated( $slug );
set_transient( "range_plug_{$slug}_last_updated", $last_updated, 86400 );
}
if ( $last_updated )
$plugin_meta['last_updated'] = 'Last Updated: ' . esc_html( $last_updated );
return $plugin_meta;
}
function range_plu_get_last_updated( $slug ) {
$request = wp_remote_post(
'http://api.wordpress.org/plugins/info/1.0/',
array(
'body' => array(
'action' => 'plugin_information',
'request' => serialize(
(object) array(
'slug' => $slug,
'fields' => array( 'last_updated' => true )
)
)
)
)
);
if ( 200 != wp_remote_retrieve_response_code( $request ) )
return false;
$response = unserialize( wp_remote_retrieve_body( $request ) );
if ( isset( $response->last_updated ) )
return sanitize_text_field( $response->last_updated );
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment