Coder Social home page Coder Social logo

wp-svg-upload's Introduction

Installation Instructions

Install with Composer composer require digimix/wp-svg-upload

Install manually

  1. Clone or copy the files into your WordPress plugins directory
  2. Activate the plugin from the dashboard or using WP CLI

Once the plugin is activated, you're good to go. Your WordPress media library will support uploading SVG files.

##Logic Breakdown

    1. We need the whole page, but only if we are in the backend (hence admin_init hook)
    1. We would like to grab all output (ob_start within admin_init as nothing should echo before that, we should not interfere with things that do)
    1. We want to grab the content on shutdown, concatenate all output buffers, then filter
    1. Search for placeholders which should exist and replace the text
  • Downsides
    1. Not permanent fix (for perma fix WP core would need to be editable or native filtering added)
    1. A bit resource munchy (it's locked to the admin side, so IMHO who cares)
    1. This is just to get SVG into WP core... Luckily the find replace is that simple in /wp-includes/media-template.php (Patch it Mullweng & Co!)

Changes...

  • Re-factored function declaration and calls to make compatible with lesser PHP versions, despite believing anyone using such versions is dangerous
  • Added param for mime-types to filter_mimes function
  • Moved into a namespace and class to make the whole thing less hack-and-slash
  • Updated to use short-array syntax (Breaking change update your PHP or don't use)
  • Deleted some dead code I never noticed before

Credits

wp-svg-upload's People

Stargazers

Digimix avatar

Watchers

James Cloos avatar Digimix avatar

wp-svg-upload's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.