Skip to content

Instantly share code, notes, and snippets.

@stephanieleary
Last active August 29, 2015 14:14
Show Gist options
  • Save stephanieleary/cbb4dd88c2a71df4a90b to your computer and use it in GitHub Desktop.
Save stephanieleary/cbb4dd88c2a71df4a90b to your computer and use it in GitHub Desktop.
Add filters for PDF, Word, and Excel files in the media library
<?php
/*
Plugin Name: Show MIMEs
Description: A tiny plugin to add more file type filters in the media library screens.
Author: Stephanie Leary
Version: 1.1
Author URI: http://sillybean.net/
*/
function tvmdl_show_mime_types( $post_mime_types ) {
$new_mime_types = array( // array( adj, noun )
'application/pdf' => array( __( 'PDFs' ), __( 'Manage PDFs' ), _n_noop( 'PDF <span class="count">(%s)</span>', 'PDFs <span class="count">(%s)</span>' ) ),
'application/msword' => array( __( 'Word Docs' ), __( 'Manage Word Docs' ), _n_noop( 'Word Doc <span class="count">(%s)</span>', 'Word Docs <span class="count">(%s)</span>' ) ),
'application/vnd.ms-excel' => array( __( 'Spreadsheets' ), __( 'Manage Spreadsheets' ), _n_noop( 'Spreadsheet <span class="count">(%s)</span>', 'Spreadsheets <span class="count">(%s)</span>' ) ),
);
return array_merge( $post_mime_types, $new_mime_types );
}
add_filter( 'post_mime_types', 'tvmdl_show_mime_types' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment