function __construct()
 {
     global $whitelist;
     $this->document = new DOMDocument();
     $this->document->preserveWhiteSpace = FALSE;
     // Load in the external whitelist data.
     require_once 'data.svg-whitelist.php';
     self::$whitelist = $whitelist;
 }
 public function sanitize_svg($file)
 {
     if ($file['type'] == 'image/svg+xml') {
         require_once 'library/class.svg-sanitizer.php';
         $svg = new SvgSanitizer();
         // We read in the temporary file prior to WordPress moving it.
         $svg->load($file['tmp_name']);
         $svg->sanitize();
         $sanitized_svg = $svg->saveSVG();
         global $wp_filesystem;
         $credentials = request_filesystem_credentials(site_url() . '/wp-admin/', '', FALSE, FALSE, array());
         if (!WP_Filesystem($credentials)) {
             request_filesystem_credentials(site_url() . '/wp-admin/', '', TRUE, FALSE, NULL);
         }
         // Using the filesystem API provided by WordPress, we replace the contents of the temporary file and then let the process continue as normal.
         $replace_uploaded_file = $wp_filesystem->put_contents($file['tmp_name'], $sanitized_svg, FS_CHMOD_FILE);
     }
     return $file;
 }