Skip to content

Instantly share code, notes, and snippets.

@SeanChDavis
Last active August 29, 2015 14:22
Show Gist options
  • Save SeanChDavis/1dddf586cb609e386050 to your computer and use it in GitHub Desktop.
Save SeanChDavis/1dddf586cb609e386050 to your computer and use it in GitHub Desktop.
Sort Downloads by Last Modified
<?php
/*
Plugin Name: Sort Downloads by Last Modified
Plugin URI: #
Description: Adds sortable Modified Date column to Downloads
Version: 1.0
Author: Sean Davis
Author URI: http://sdavismedia.com
*/
/**
* Register Modified Date Column for Downloads
*/
function sdm_modified_column_register( $columns ) {
$columns['modified'] = 'Modified Date';
return $columns;
}
add_filter( 'manage_edit-download_columns', 'sdm_modified_column_register' );
/**
* Display the modified date of each Download
*/
function sdm_modified_column_display( $column_name, $post_id ) {
global $post;
if ( $column_name !== 'modified' ) {
return;
}
$modified = the_modified_date();
echo $modified;
}
add_action( 'manage_download_posts_custom_column', 'sdm_modified_column_display', 10, 2 );
/**
* Register the column as sortable
*/
function sdm_modified_column_register_sortable( $columns ) {
$columns['modified'] = 'modified';
return $columns;
}
add_filter( 'manage_edit-download_sortable_columns', 'sdm_modified_column_register_sortable' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment