Skip to content

Instantly share code, notes, and snippets.

@kopepasah
Last active January 28, 2021 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kopepasah/7e5b14f772df173e46c0c96918c28c3e to your computer and use it in GitHub Desktop.
Save kopepasah/7e5b14f772df173e46c0c96918c28c3e to your computer and use it in GitHub Desktop.
Filters the WordPress mime type uploads to allow for JSON files.
<?php
/**
* Allow JSON file uploads to WordPress media library.
*
* @package WordPress
*
* @author Justin Kopepasah <justin@kopepasah.com>
*/
/**
* Filters the uploads mime types to allow JSON files.
*
* @param array $types Currently allowed types.
*
* @return array Filtered types.
*/
add_filter(
'upload_mimes',
function( $types ) {
return array_merge( $types, [ 'json' => 'text/plain' ] );
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment