Version Description
- I broke everything. I'm sorry, but it had to be done.
- Basically how I had approached the problem before was wrong. It is now being done properly using the correct mime/type.
- Shortcodes are no longer needed, you can now use SVG files as you would any other image.
- Previews now show up in the media area for SVG files.
- IMPORTANT: Anyone using the version prior to 2.0 were using shortcodes to display SVG files. You will have to go back and replace those shortcodes with actual image tags. If you're not familiar with HTML, you can just delete the shortcode out of the page/post and then insert the SVG file as you would any other image.
Download this release
Release Info
Developer | sterlo |
Plugin | Scalable Vector Graphics (SVG) |
Version | 2.0 |
Comparing to | |
See all releases |
Code changes from version 1.2 to 2.0
- readme.txt +8 -0
- scalable-vector-graphics.php +26 -31
readme.txt
CHANGED
@@ -31,3 +31,11 @@ An example of using all attributes:
|
|
31 |
* I N C E P T I O N
|
32 |
= 1.1 =
|
33 |
* Fixing a typo. This typo caused ONLY SVG files to be allowed to upload via the media uploader.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
* I N C E P T I O N
|
32 |
= 1.1 =
|
33 |
* Fixing a typo. This typo caused ONLY SVG files to be allowed to upload via the media uploader.
|
34 |
+
= 1.2 =
|
35 |
+
* One less required parameter and a graceful fail over to a valid implementation type. Props @Phil
|
36 |
+
= 2.0 =
|
37 |
+
* I broke everything. I'm sorry, but it had to be done.
|
38 |
+
* Basically how I had approached the problem before was wrong. It is now being done properly using the correct mime/type.
|
39 |
+
* Shortcodes are no longer needed, you can now use SVG files as you would any other image.
|
40 |
+
* Previews now show up in the media area for SVG files.
|
41 |
+
* IMPORTANT: Anyone using the version prior to 2.0 were using shortcodes to display SVG files. You will have to go back and replace those shortcodes with actual image tags. If you're not familiar with HTML, you can just delete the shortcode out of the page/post and then insert the SVG file as you would any other image.
|
scalable-vector-graphics.php
CHANGED
@@ -3,9 +3,9 @@
|
|
3 |
* Plugin Name: Scalable Vector Graphics (SVG)
|
4 |
* Plugin URI: http://sterlinghamilton.com/scalable-vector-graphics-plugin
|
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:
|
7 |
* Author: Sterling Hamilton
|
8 |
-
* Author URI: http://
|
9 |
* License: GPLv2 or later
|
10 |
|
11 |
* This program is free software; you can redistribute it and/or
|
@@ -25,48 +25,43 @@
|
|
25 |
|
26 |
class scalable_vector_graphics {
|
27 |
|
28 |
-
function
|
29 |
-
|
30 |
-
add_shortcode( 'svg' , array( &$this , 'process_shortcode' ) );
|
31 |
}
|
32 |
|
33 |
-
function
|
34 |
-
|
35 |
-
$new_mime_types[ 'svg' ] = 'mime/type';
|
36 |
-
|
37 |
-
return $new_mime_types;
|
38 |
}
|
39 |
|
40 |
-
function
|
41 |
-
|
|
|
|
|
|
|
|
|
42 |
|
43 |
-
|
|
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
}
|
49 |
-
}
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
default:
|
58 |
-
$content .= '<embed src="' . $atts[ 'src' ] . '" width="' . $atts[ 'width' ] . '" height="' . $atts[ 'height' ] . '" ';
|
59 |
-
$content .= 'type="image/svg+xml" pluginspage="http://www.adobe.com/svg/viewer/install/" style="' . $atts[ 'style' ] . '" /> ';
|
60 |
-
break;
|
61 |
-
}
|
62 |
|
63 |
-
return $
|
64 |
}
|
65 |
|
66 |
}
|
67 |
|
68 |
-
if ( class_exists( 'scalable_vector_graphics' ) and !isset( $scalable_vector_graphics ) ) {
|
69 |
$scalable_vector_graphics = new scalable_vector_graphics();
|
|
|
70 |
}
|
71 |
|
72 |
?>
|
3 |
* Plugin Name: Scalable Vector Graphics (SVG)
|
4 |
* Plugin URI: http://sterlinghamilton.com/scalable-vector-graphics-plugin
|
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: 2.0
|
7 |
* Author: Sterling Hamilton
|
8 |
+
* Author URI: http://sterlinghamilton.com
|
9 |
* License: GPLv2 or later
|
10 |
|
11 |
* This program is free software; you can redistribute it and/or
|
25 |
|
26 |
class scalable_vector_graphics {
|
27 |
|
28 |
+
public function execute() {
|
29 |
+
$this->_enable_svg_mime_type();
|
|
|
30 |
}
|
31 |
|
32 |
+
private function _enable_svg_mime_type() {
|
33 |
+
add_filter( 'upload_mimes', array( &$this, 'allow_svg_uploads' ) );
|
|
|
|
|
|
|
34 |
}
|
35 |
|
36 |
+
private function _sanitize_input( $input ) {
|
37 |
+
if( is_scalar( $input ) ) {
|
38 |
+
return wp_kses( $input );
|
39 |
+
} else {
|
40 |
+
$this->_error( 'Unable to sanitize given input: Not scalar: integer, float, string or boolean.' );
|
41 |
+
}
|
42 |
|
43 |
+
return false;
|
44 |
+
}
|
45 |
|
46 |
+
private function _error( $message ) {
|
47 |
+
return new WP_Error( __CLASS__, __METHOD__ . __( $message ) );
|
48 |
+
}
|
|
|
|
|
49 |
|
50 |
+
public function allow_svg_uploads( $existing_mime_types = array() ) {
|
51 |
+
return $this->_add_mime_type( $existing_mime_types );
|
52 |
+
}
|
53 |
+
|
54 |
+
private function _add_mime_type( $mime_types ) {
|
55 |
+
$mime_types[ 'svg' ] = 'image/svg+xml';
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
+
return $mime_types;
|
58 |
}
|
59 |
|
60 |
}
|
61 |
|
62 |
+
if ( class_exists( 'scalable_vector_graphics' ) and ! isset( $scalable_vector_graphics ) ) {
|
63 |
$scalable_vector_graphics = new scalable_vector_graphics();
|
64 |
+
$scalable_vector_graphics->execute();
|
65 |
}
|
66 |
|
67 |
?>
|