Changeset 1591439
- Timestamp:
- 02/07/2017 11:33:29 PM (9 years ago)
- Location:
- scalable-vector-graphics-svg/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
scalable-vector-graphics.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
scalable-vector-graphics-svg/trunk/readme.txt
r1465348 r1591439 2 2 Contributors: sterlo 3 3 Donate link: http://www.sterlinghamilton.com/projects/scalable-vector-graphics/ 4 Tags: svg, scalable, vector, mime, type, image, graphic, file, upload 4 Tags: svg, scalable, vector, mime, type, image, graphic, file, upload, media 5 5 Requires at least: 3.0 6 Tested up to: 4. 5.36 Tested up to: 4.7.2 7 7 Stable tag: trunk 8 8 License: GPLv2 or later … … 41 41 1. Be in the root of your WordPress installation. 42 42 1. Run `wp plugin install scalable-vector-graphics-svg`. 43 1. Run `wp activate scalable-vector-graphics-svg`.43 1. Run `wp plugin activate scalable-vector-graphics-svg`. 44 44 45 45 == Changelog == 46 46 47 = 3.3 = 48 * Add a patch for core bug introduced in 4.7.1 47 49 = 3.2 = 48 50 * 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 4 4 * Plugin URI: http://www.sterlinghamilton.com/projects/scalable-vector-graphics/ 5 5 * 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. 26 * Version: 3.3 7 7 * Author: Sterling Hamilton 8 8 * Author URI: http://www.sterlinghamilton.com/ … … 25 25 26 26 namespace SterlingHamilton\Plugins\ScalableVectorGraphics; 27 28 $wordpress_version = get_bloginfo('version'); 27 29 28 30 // Return the accepted value for SVG mime-types in compliance with the RFC 3023. … … 52 54 // Consider this the "server side" fix for dimensions. 53 55 // Which is needed for the Media Grid within the Administration area. 54 function adjust_response_for_svg( $response, $attachment, $meta ) {56 function set_dimensions( $response, $attachment, $meta ) { 55 57 if( $response['mime'] == 'image/svg+xml' && empty( $response['sizes'] ) ) { 56 58 $svg_file_path = get_attached_file( $attachment->ID ); … … 69 71 return $response; 70 72 } 73 71 74 // Browsers may or may not show SVG files properly without a height/width. 72 75 // WordPress specifically defines width/height as "0" if it cannot figure it out. … … 95 98 } 96 99 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! 104 function 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 114 if($wordpress_version < "4.7.3") { 115 add_filter( 'wp_check_filetype_and_ext', __NAMESPACE__ . '\\disable_real_mime_check', 10, 4 ); 116 } 98 117 add_filter( 'upload_mimes', __NAMESPACE__ . '\\allow_svg_uploads' ); 99 add_filter( 'wp_prepare_attachment_for_js', __NAMESPACE__ . '\\ adjust_response_for_svg', 10, 3 );118 add_filter( 'wp_prepare_attachment_for_js', __NAMESPACE__ . '\\set_dimensions', 10, 3 ); 100 119 add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\\administration_styles' ); 101 120 add_action( 'wp_head', __NAMESPACE__ . '\\public_styles' );
Note: See TracChangeset
for help on using the changeset viewer.