Additional Functions php

Support JSON mimes type:

<?php
 /**
* Allow additional MIME types
* Use 'text/plain' instead of 'application/json' for JSON because of a current WordPress core bug
*/
function add_upload_mimes( $types ) { 
	$types['json'] = 'text/plain';
	return $types;
}
add_filter( 'upload_mimes', 'add_upload_mimes' );

Support SVG mimes type: or use the SVG support plugin

<?php
/**
 * Add SVGs to the list of allowed mime types.
 * 
 * @param array $upload_mimes The existing allowed mime types.
 * 
 * @return array The enhanced allowed mime types.
 */
function gomo_admin_add_svg_to_upload_mimes( $upload_mimes ) {

    $file_types = array();
    $file_types['svg'] = 'image/svg+xml';
    $upload_mimes = array_merge( $file_types, $upload_mimes );
    return $upload_mimes;

}
add_filter('upload_mimes', 'gomo_admin_add_svg_to_upload_mimes');

can be useful to add this to the top of SVG files

<?xml version="1.0" encoding="utf-8"?>

Search the site


Address

123 Main Street
Town
City
P05T C0D3

Tel: 01234 567 899

Mob: 01234 567 899

Email: ben@gomopress.com


Copyright 2023. Blah blah blah Company Limited