Are .csv Import Entries not working for anyone else? [RESOLVED]

WordPress’s latest update saw further restrictions on uploads. The following code overrides this behaviour for JSON files:

add_filter( 'upload_mimes', function( $mime_types ) {
	$mime_types['json'] = 'application/json'; // Adding .json extension

	return $mime_types;
}, 1, 1 );

add_filter( 'wp_check_filetype_and_ext', function( $mime, $file, $filename, $mimes ) {

	$wp_filetype = wp_check_filetype( $filename, $mimes );
	if ( in_array( $wp_filetype['ext'], [ 'json' ] ) ) {
		$mime['ext']  = true;
		$mime['type'] = true;
	}

	return $mime;
}, 10, 4 );

You might want to limit this code to a specific role as it applies to any user (logged in or otherwise).

2 Likes