public static function check_filetype_and_ext_svg($checked, $file, $filename, $mimes) {
		// Only need to do something if the type is SVG.
		if ('image/svg+xml' === $checked['type']) {
			try {
				$contents = @file_get_contents($file);
				$contents = svg::sanitize($contents);

				// Overwrite the contents if we're good.
				if (is_string($contents) && $contents) {
					@file_put_contents($file, $contents);

					// In case it got renamed somewhere along the way.
					if ($checked['proper_filename']) {
						$checked['proper_filename'] = mime::update_filename_extension($checked['proper_filename'], '.svg');
					}
				}
				// Otherwise just fail the download.
				else {
					$checked['type'] = $checked['ext'] = false;
				}
			} catch (\Throwable $e) {
				error_log($e->getMessage());
				$checked['type'] = $checked['ext'] = false;
			} catch (\Exception $e) {
				$checked['type'] = $checked['ext'] = false;
			}
		}

		return $checked;
	}
public static function check_filetype_and_ext_svg($checked, $file, $filename, $mimes) {
		// Only need to do something if the type is SVG.
		if ('image/svg+xml' === $checked['type']) {
			try {
				$contents = @file_get_contents($file);
				$contents = svg::sanitize($contents);

				// Overwrite the contents if we're good.
				if (is_string($contents) && $contents) {
					@file_put_contents($file, $contents);

					// In case it got renamed somewhere along the way.
					if ($checked['proper_filename']) {
						$checked['proper_filename'] = mime::update_filename_extension($checked['proper_filename'], '.svg');
					}
				}
				// Otherwise just fail the download.
				else {
					$checked['type'] = $checked['ext'] = false;
				}
			} catch (\Throwable $e) {
				error_log($e->getMessage());
				$checked['type'] = $checked['ext'] = false;
			} catch (\Exception $e) {
				$checked['type'] = $checked['ext'] = false;
			}
		}

		return $checked;
	}
public static function check_filetype_and_ext_svg ( $ checked , $ file , $ filename , $ mimes ) { // Only need to do something if the type is SVG. if ( 'image/svg+xml' === $ checked [ 'type' ] ) { try { $ contents = @ file_get_contents ( $ file ) ; $ contents = svg :: sanitize ( $ contents ) ; // Overwrite the contents if we're good. if ( is_string ( $ contents ) && $ contents ) { @ file_put_contents ( $ file , $ contents ) ; // In case it got renamed somewhere along the way. if ( $ checked [ 'proper_filename' ] ) { $ checked [ 'proper_filename' ] = mime :: update_filename_extension ( $ checked [ 'proper_filename' ] , '.svg' ) ; } } // Otherwise just fail the download. else { $ checked [ 'type' ] = $ checked [ 'ext' ] = false ; } } catch ( \ Throwable $ e ) { error_log ( $ e -> getMessage ( ) ) ; $ checked [ 'type' ] = $ checked [ 'ext' ] = false ; } catch ( \ Exception $ e ) { $ checked [ 'type' ] = $ checked [ 'ext' ] = false ; } } return $ checked ; }
Sanitize SVG Uploads

This is triggered after our general content-based fixer, so if
something is claiming to be an SVG here, it should actually be
one.

@see wp_check_filetype_and_ext()

@param array $checked Previous check status.
@param string $file File path.
@param string $filename File name.
@param array $mimes Mimes.
@return array Checked status.
Sanitize SVG Uploads