Created
December 7, 2013 09:58
-
-
Save benmay/7839222 to your computer and use it in GitHub Desktop.
Adds the ID col
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Class MediaUploaderTweak { | |
static function run() { | |
add_filter( 'manage_media_columns', array( 'MediaUploaderTweak', 'cols' ), 1 ); | |
add_action( 'manage_media_custom_column', array( 'MediaUploaderTweak', 'col' ), 1, 2 ); | |
add_action( 'admin_head-upload.php', array( 'MediaUploaderTweak', 'admin_head' ) ); | |
} | |
// Does some basic re-ordering and adds new column. | |
static function cols( $defaults ) { | |
// Define new array to store columns | |
// (need to merge the ID in after the icon. | |
$new_array = array(); | |
$new_array[ 'cb' ] = $defaults[ 'cb' ]; | |
$new_array[ 'icon' ] = $defaults[ 'icon' ]; | |
$new_array[ 'attachment_id' ] = __( 'ID' ); | |
// Remove these two as we've added in manually. | |
unset( $defaults[ 'cb' ] ); | |
unset( $defaults[ 'icon' ] ); | |
// Merge anything in else that may exist. | |
return array_merge( $new_array, $defaults ); | |
} | |
// If correct, adds the ID | |
static function col( $column_name, $id ) { | |
if ( $column_name === 'attachment_id' ) { | |
echo $id; | |
} | |
} | |
// Sets the width on the col | |
static function admin_head() { | |
echo '<style type="text/css"> #attachment_id {width: 40px; } </style>'; | |
} | |
} | |
MediaUploaderTweak::run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment