Created
April 16, 2025 20:07
-
-
Save osbre/36f250c5b8cda02f94c5e2b9979fffc5 to your computer and use it in GitHub Desktop.
Revisions
-
osbre created this gist
Apr 16, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ <?php /** * Plugin Name: SVG Upload Support * Description: Allows SVG uploads for admins only. * Version: 1.0 * Author: Ostap Brehin * Author URI: https://ostapbrehin.com */ add_filter('upload_mimes', function ($mimes) { if (current_user_can('manage_options')) { $mimes['svg'] = 'image/svg+xml'; } return $mimes; }); add_filter('wp_check_filetype_and_ext', function ($data, $file, $filename, $mimes) { if (!$data['type'] && current_user_can('manage_options') && preg_match('/\.svg$/i', $filename)) { $data['type'] = 'image/svg+xml'; $data['ext'] = 'svg'; } return $data; }, 10, 4);