Plugin Directory

Changeset 2967898


Ignore:
Timestamp:
09/17/2023 04:49:36 AM (2 years ago)
Author:
ashikcse
Message:

Added SVG Sanitize Feature.

Location:
cits-support-svg-webp-media-upload/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cits-support-svg-webp-media-upload/trunk/init.php

    r2953455 r2967898  
    55Author: Ashik
    66Author URI: https://ashik.me
    7 Description: WordPress doesn't allow the .svg,.webp format for media upload and .ttf,.otf fonts files upload gives an error. Active the Plugin and Enjoy. uploads your Svg, Webp Images, TTF, OTF fonts file Safely without Erros.
    8 Tags: Support svg, Support webp, cits support svg,  cits support webp,CITS Support svg, webp Media Upload, fonts file upload support, ttf upload, otf upload, eot upload, woff upload.
    9 Version: 2.1.0
     7Description:  Enhance your WordPress media capabilities with "Active the Plugin and Enjoy." This plugin extends your media library to support not only SVG and WebP images but also TTF, OTF, EOT, and WOFF font files. Safety is our top priority; that's why we've included an SVG sanitization feature to keep your site secure while you enjoy broader media upload options. Take control of your media and start uploading without errors today!
     8Tags: svg support, safe svg, webp support, support webp, cits support svg, cits support webp, CITS Support svg, webp media upload, font file upload support, ttf upload, otf upload, eot upload, woff upload.
     9Version: 3.0
    1010Requires at least:5.0
    11 Tested up to: 6.3
     11Tested up to: 6.3.1
    1212Requires PHP version: 7.0
    1313License: GPL2
     
    2121        add_filter( 'wp_check_filetype_and_ext', array($this,'cits_check_types'), 10, 4 );
    2222        add_filter( 'wp_check_filetype_and_ext', array($this,'cits_allow_svg_upload'), 10, 4 );
     23        add_filter( 'wp_handle_upload_prefilter', array($this,'cits_sanitize_svg')); 
    2324    }
     25   
    2426    function cits_upload_media_mimes($cits_mimes) {
    2527        $cits_mimes['webp'] = 'image/webp';
     
    108110        return (object) array( 'width' => $width, 'height' => $height );
    109111    }
    110  
     112    function cits_sanitize_svg($file) {
     113        // Check if file is SVG
     114        if($file['type'] === 'image/svg+xml') {
     115            $file_content = file_get_contents($file['tmp_name']);
     116            $dom = new DOMDocument();
     117            $dom->loadXML($file_content, LIBXML_NONET);
     118
     119            // Remove script elements
     120            $scripts = $dom->getElementsByTagName('script');
     121            $length = $scripts->length;
     122            for ($i = 0; $i < $length; $i++) {
     123                $scripts->item($i)->parentNode->removeChild($scripts->item($i));
     124            }
     125           
     126            // Save the cleaned-up SVG content back to the temporary file
     127            file_put_contents($file['tmp_name'], $dom->saveXML());
     128        }
     129        return $file;
     130    }
    111131
    112132}
  • cits-support-svg-webp-media-upload/trunk/readme.txt

    r2953455 r2967898  
    11=== CITS Support svg, webp Media and TTF,OTF File Upload ===
    22Contributors: ashikcse
    3 Tags: Support svg, Support webp, cits support svg,  cits support webp,CITS Support svg, webp Media Upload, fonts file upload support, ttf upload, otf upload, eot upload, woff upload.
     3Tags: svg support, safe svg, webp support, support webp, cits support svg, cits support webp, CITS Support svg, webp media upload, font file upload support, ttf upload, otf upload, eot upload, woff upload.
    44Requires at least: 5.0
    55Stable tag: 1.0.0
    6 Tested up to: 6.3
     6Tested up to: 6.3.1
    77Requires PHP: 7.0
    8 Version: 2.1.0
     8Version: 3.0
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    1414== Description ==
    1515
    16 WordPress doesn't allow the .svg,.webp format for media upload and .ttf,.otf fonts files upload gives an error. Active the Plugin and Enjoy. uploads your Svg, Webp Images, TTF, OTF fonts file Safely without Erros. Speed up website you need to add svg, webp images on your Website. upload and use your custom fonts files.
     16Enhance your WordPress media capabilities with "Active the Plugin and Enjoy." This plugin extends your media library to support not only SVG and WebP images but also TTF, OTF, EOT, and WOFF font files. Safety is our top priority; that's why we've included an SVG sanitization feature to keep your site secure while you enjoy broader media upload options. Take control of your media and start uploading without errors today!
    1717
    1818*  New Update 2.0
    1919*  Supports TTF, OTF, WOFF fonts file upload.
     20*  New Update 3.0
     21*  SVG Sanitize -  keep secure your website
    2022
    2123== Installation ==
Note: See TracChangeset for help on using the changeset viewer.