Allow JSON Uploads to WordPress Media Library

PHP

<?php
/**
 * Allow JSON file uploads to WordPress media library.
 *
 * @package WordPress
 *
 * @author Justin Kopepasah <[email protected]>
 */

/**
 * 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' ] );
	}
);

Source: https://koop.sh/software/allow-json-uploads-to-wordpress-media-library/

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *