dispatch_hooks(); add_filter( 'upload_mimes', [ $self, 'allow_lottie_json_uploads' ] ); add_filter( 'upload_mimes', [ $self, 'allow_svg_uploads' ] ); add_filter( 'wp_check_filetype_and_ext', function ( $data, $file, $filename ) { $ext = pathinfo( $filename, PATHINFO_EXTENSION ); if ( 'json' === $ext ) { $data['ext'] = 'json'; $data['type'] = 'application/json'; } elseif ( 'svg' === strtolower( $ext ) && current_user_can( 'unfiltered_html' ) ) { $data['ext'] = 'svg'; $data['type'] = 'image/svg+xml'; } return $data; }, 10, 3 ); } function allow_lottie_json_uploads( $mimes ) { $mimes['json'] = 'application/json'; $mimes['lottie'] = 'application/json'; return $mimes; } // Gated to unfiltered_html (administrators, by default) rather than opened // for every role: an SVG file can carry a