Plugin Directory

Changeset 1591439


Ignore:
Timestamp:
02/07/2017 11:33:29 PM (9 years ago)
Author:
sterlo
Message:

Bringing down latest from GitHub which fixed WordPress 4.7.1 bug.

Location:
scalable-vector-graphics-svg/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • scalable-vector-graphics-svg/trunk/readme.txt

    r1465348 r1591439  
    22Contributors: sterlo
    33Donate link: http://www.sterlinghamilton.com/projects/scalable-vector-graphics/
    4 Tags: svg, scalable, vector, mime, type, image, graphic, file, upload
     4Tags: svg, scalable, vector, mime, type, image, graphic, file, upload, media
    55Requires at least: 3.0
    6 Tested up to: 4.5.3
     6Tested up to: 4.7.2
    77Stable tag: trunk
    88License: GPLv2 or later
     
    41411. Be in the root of your WordPress installation.
    42421. Run `wp plugin install scalable-vector-graphics-svg`.
    43 1. Run `wp activate scalable-vector-graphics-svg`.
     431. Run `wp plugin activate scalable-vector-graphics-svg`.
    4444
    4545== Changelog ==
    4646
     47= 3.3 =
     48* Add a patch for core bug introduced in 4.7.1
    4749= 3.2 =
    4850* Created End User styles to allow for the front of the site to display SVG files properly.
  • scalable-vector-graphics-svg/trunk/scalable-vector-graphics.php

    r1465348 r1591439  
    44 * Plugin URI: http://www.sterlinghamilton.com/projects/scalable-vector-graphics/
    55 * Description: Scalable Vector Graphics are two-dimensional vector graphics, that can be both static and dynamic. This plugin allows your to easily use them on your site.
    6  * Version: 3.2
     6 * Version: 3.3
    77 * Author: Sterling Hamilton
    88 * Author URI: http://www.sterlinghamilton.com/
     
    2525
    2626namespace SterlingHamilton\Plugins\ScalableVectorGraphics;
     27
     28$wordpress_version = get_bloginfo('version');
    2729
    2830// Return the accepted value for SVG mime-types in compliance with the RFC 3023.
     
    5254// Consider this the "server side" fix for dimensions.
    5355// Which is needed for the Media Grid within the Administration area.
    54 function adjust_response_for_svg( $response, $attachment, $meta ) {
     56function set_dimensions( $response, $attachment, $meta ) {
    5557    if( $response['mime'] == 'image/svg+xml' && empty( $response['sizes'] ) ) {
    5658        $svg_file_path = get_attached_file( $attachment->ID );
     
    6971    return $response;
    7072}
     73
    7174// Browsers may or may not show SVG files properly without a height/width.
    7275// WordPress specifically defines width/height as "0" if it cannot figure it out.
     
    9598}
    9699
    97 // Do work son.
     100// Restores the ability to upload non-image files in WordPress 4.7.1 and 4.7.2.
     101// Related Trac Ticket: https://core.trac.wordpress.org/ticket/39550
     102// Credit: @sergeybiryukov
     103// @TODO: Remove the plugin once WordPress 4.7.3 is available!
     104function disable_real_mime_check( $data, $file, $filename, $mimes ) {
     105    $wp_filetype = wp_check_filetype( $filename, $mimes );
     106
     107    $ext = $wp_filetype['ext'];
     108    $type = $wp_filetype['type'];
     109    $proper_filename = $data['proper_filename'];
     110
     111    return compact( 'ext', 'type', 'proper_filename' );
     112}
     113
     114if($wordpress_version < "4.7.3") {
     115    add_filter( 'wp_check_filetype_and_ext', __NAMESPACE__ . '\\disable_real_mime_check', 10, 4 );
     116}
    98117add_filter( 'upload_mimes', __NAMESPACE__ . '\\allow_svg_uploads' );
    99 add_filter( 'wp_prepare_attachment_for_js', __NAMESPACE__ . '\\adjust_response_for_svg', 10, 3 );
     118add_filter( 'wp_prepare_attachment_for_js', __NAMESPACE__ . '\\set_dimensions', 10, 3 );
    100119add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\\administration_styles' );
    101120add_action( 'wp_head', __NAMESPACE__ . '\\public_styles' );
Note: See TracChangeset for help on using the changeset viewer.