SVG Support - Version 2.1

Version Description

  • Updates to language files for localization.
Download this release

Release Info

Developer Benbodhi
Plugin Icon 128x128 SVG Support
Version 2.1
Comparing to
See all releases

Code changes from version 1.0 to 2.1

admin/admin-init.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /********************************************
3
+ * ADMIN INIT
4
+ ********************************************/
5
+
6
+ // add menu item to wp-admin
7
+ add_action( 'admin_menu', 'bodhi_svgs_admin_menu' );
8
+
9
+ function bodhi_svgs_admin_menu() {
10
+
11
+ add_options_page(
12
+ __('SVG Support Options and Instructions', 'svgsupport'),
13
+ __('SVG Support', 'svgsupport'),
14
+ 'manage_options',
15
+ 'svg-support',
16
+ 'bodhi_svg_support_settings_page'
17
+ );
18
+
19
+ }
20
+
21
+ // create settings page
22
+ function bodhi_svg_support_settings_page() {
23
+
24
+ if( ! current_user_can( 'manage_options' ) ) {
25
+
26
+ wp_die( __('You can\'t play with this.', 'svgsupport') );
27
+
28
+ }
29
+
30
+ global $bodhi_svgs_options;
31
+
32
+ require( BODHI_SVGS_PLUGIN_PATH . 'admin/svgs-settings-page.php' );
33
+
34
+ }
35
+
36
+ // register settings in the database
37
+ add_action('admin_init', 'bodhi_svgs_register_settings');
38
+
39
+ function bodhi_svgs_register_settings() {
40
+
41
+ register_setting('bodhi_svgs_settings_group', 'bodhi_svgs_settings');
42
+
43
+ }
44
+
45
+ ?>
admin/svgs-settings-page.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+
3
+ <div id="icon-upload" class="icon32"></div>
4
+ <h2><?php _e( 'SVG Support Settings and Usage', 'svgsupport' ); ?><span class="svgs-version">Ver <?php global $plugin_version; echo $plugin_version; ?></span></h2>
5
+
6
+ <div id="poststuff">
7
+
8
+ <div class="meta-box-sortables ui-sortable">
9
+
10
+ <div class="postbox">
11
+
12
+ <h3><span><?php _e( 'Introduction', 'svgsupport' ); ?></span></h3>
13
+ <div class="inside">
14
+
15
+ <p><?php _e( 'When using SVG images on your WordPress site, it can be hard to style elements within the SVG using CSS. <strong>Now you can, easily!</strong>', 'svgsupport' ); ?></p>
16
+ <p><?php _e( 'This plugin not only provides SVG Support like the name says, it also allows you to easily embed your full SVG file\'s code using a simple IMG tag. By adding the class <code>style-svg</code> to your IMG elements, this plugin dynamically replaces any IMG elements containing the <code>style-svg</code> class with your complete SVG.', 'svgsupport' ); ?></p>
17
+ <p><?php _e( 'The main purpose of this is to allow styling of SVG elements. Usually your styling options are restricted when using <code>embed</code>, <code>object</code> or <code>img</code> tags alone.', 'svgsupport' ); ?></p>
18
+
19
+ </div> <!-- .inside -->
20
+
21
+ </div> <!-- .postbox -->
22
+
23
+ </div> <!-- .meta-box-sortables .ui-sortable -->
24
+
25
+ <div id="post-body" class="metabox-holder columns-2">
26
+
27
+ <!-- main content -->
28
+ <div id="post-body-content">
29
+
30
+ <div class="meta-box-sortables ui-sortable">
31
+
32
+ <div class="postbox">
33
+
34
+ <h3><span><?php _e( 'Settings', 'svgsupport' ); ?></span></h3>
35
+ <div class="inside">
36
+
37
+ <form name="bodhi_svgs_settings_form" method="post" action="options.php">
38
+ <!-- <input type="hidden" name="bodhi_svgs_settings_form_submitted" value="Y"> -->
39
+
40
+ <?php settings_fields('bodhi_svgs_settings_group'); ?>
41
+
42
+ <table class="form-table">
43
+ <tr valign="top">
44
+ <!-- Swap with future feature: Multiselect Roles -->
45
+ <th scope="row">
46
+ <label for="bodhi_svgs_settings[restrict]"><strong><?php _e( 'Restrict to Administrators', 'svgsupport' ); ?></strong></label>
47
+ </th>
48
+ <td>
49
+ <?php printf(
50
+ '<input id="bodhi_svgs_settings[restrict]" name="bodhi_svgs_settings[restrict]" type="checkbox" %2$s />', 'bodhi_svgs_settings_restrict', checked( isset( $bodhi_svgs_options['restrict'] ), true, false ) ); ?>
51
+ <?php _e( 'Yes', 'svgsupport' ); ?><br /><small class="description"><?php _e(' Restricts SVG upload priveledges to Administrators.', 'svgsupport' ); ?></small>
52
+ </td>
53
+ </tr>
54
+ <tr valign="top">
55
+ <th scope="row">
56
+ <label for="bodhi_svgs_settings[css_target]"><strong><?php _e( 'CSS Class to target', 'svgsupport' ); ?></strong></label>
57
+ </th>
58
+ <td>
59
+ <input id="bodhi_svgs_settings[css_target]" class="all-options code" name="bodhi_svgs_settings[css_target]" type="text" value="<?php echo $bodhi_svgs_options['css_target']; ?>"><br><small class="description"><?php _e( 'The default target class is <code>style-svg</code>. You can change it to your own class such as <code>my-class</code> by typing it here.<br />Leave blank to use the default class.', 'svgsupport' ); ?></small>
60
+ </td>
61
+ </tr>
62
+ </table>
63
+
64
+ <p>
65
+ <input class="button-primary" type="submit" name="bodhi_svgs_settings_submit" value="<?php _e( 'Save Changes', 'svgsupport' ); ?>" />
66
+ </p>
67
+
68
+ </form>
69
+
70
+ </div> <!-- .inside -->
71
+
72
+ </div> <!-- .postbox -->
73
+
74
+ <div class="postbox">
75
+
76
+ <h3><span><?php _e( 'Usage', 'svgsupport' ); ?></span></h3>
77
+ <div class="inside">
78
+
79
+ <p><?php _e( 'You can simply upload SVG images to your media library like any other file.', 'svgsupport' ); ?><br />
80
+ <?php _e( 'Now, embed your SVG image like a standard image with the addition of adding the class <code>style-svg</code> (or your custom class from above) to any IMG tags that you want this plugin to swap out with your actual SVG code.', 'svgsupport' ); ?><br />
81
+ <?php _e( 'For example:', 'svgsupport' ); ?></p>
82
+
83
+ <pre><code>&lt;img class="style-svg" alt="alt-text" src="image-source.svg" /&gt;</code></pre>
84
+ <?php _e( 'or', 'svgsupport' ); ?>
85
+ <pre><code>&lt;img class="your-custom-class" alt="alt-text" src="image-source.svg" /&gt;</code></pre>
86
+
87
+ <p><?php _e( 'The whole IMG tag element will now be dynamically replaced by the actual code of your SVG, making the inner content targetable.', 'svgsupport' ); ?><br />
88
+ <?php _e( 'This allows you to target elements within your SVG using CSS.', 'svgsupport' ); ?></p>
89
+
90
+ <p><em><?php _e( 'Note: Your uploaded image needs to be an SVG file for this plugin to replace the img tag with the inline SVG code. It will not create SVG files for you.', 'svgsupport' ); ?></em></p>
91
+
92
+ </div> <!-- .inside -->
93
+
94
+ </div> <!-- .postbox -->
95
+
96
+ </div> <!-- .meta-box-sortables .ui-sortable -->
97
+
98
+ </div> <!-- post-body-content -->
99
+
100
+ <!-- sidebar -->
101
+ <div id="postbox-container-1" class="postbox-container">
102
+
103
+ <div class="meta-box-sortables">
104
+
105
+ <div class="postbox">
106
+
107
+ <h3><span><?php _e( 'Features', 'svgsupport' ); ?></span></h3>
108
+ <div class="inside">
109
+ <ul>
110
+ <li><?php _e( 'SVG Support for your media library', 'svgsupport' ); ?></li>
111
+ <li><?php _e( 'Style SVG elements directly using CSS', 'svgsupport' ); ?></li>
112
+ <li><?php _e( 'Restrict to Administrators only', 'svgsupport' ); ?></li>
113
+ <li><strong><?php _e( 'Extremely Simple To Use', 'svgsupport' ); ?></strong></li>
114
+ </ul>
115
+ </div> <!-- .inside -->
116
+
117
+ </div> <!-- .postbox -->
118
+
119
+ <div class="postbox">
120
+
121
+ <h3><span><?php _e( 'About the plugin', 'svgsupport' ); ?></span></h3>
122
+ <div class="inside">
123
+ <p><?php _e( 'You can read about this plugin in detail on', 'svgsupport' ); ?> <a target="_blank" href="http://wordpress.org/plugins/svg-support/"><?php _e( 'The WordPress Plugin Repository', 'svgsupport' ); ?></a>.</p>
124
+ <p><?php _e( 'Need help?', 'svgsupport' ); ?> <a target="_blank" href="http://wordpress.org/support/plugin/svg-support"><?php _e( 'Visit Support', 'svgsupport' ); ?></a>.</p>
125
+ <p>&copy; <a target="_blank" href="http://benbodhi.com">Benbodhi</a> <?php _e( 'from', 'svgsupport' ); ?> <a target="_blank" href="http://gowebben.com">GoWebben</a>.
126
+ </div> <!-- .inside -->
127
+
128
+ </div> <!-- .postbox -->
129
+
130
+ </div> <!-- .meta-box-sortables -->
131
+
132
+ </div> <!-- #postbox-container-1 .postbox-container -->
133
+
134
+ </div> <!-- #post-body .metabox-holder .columns-2 -->
135
+
136
+ <br class="clear">
137
+ </div> <!-- #poststuff -->
138
+
139
+ </div> <!-- .wrap -->
css/svgs-admin.css ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ .svgs-version {
2
+ font-size: 10px;
3
+ margin-left: 7px;
4
+ }
functions/enqueue.php CHANGED
@@ -1,8 +1,45 @@
1
  <?php
2
- add_action( 'wp_enqueue_scripts', 'bodhi_gc_svg_inline' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- function bodhi_gc_svg_inline() {
5
- wp_register_script('bodhi_gc_svg_inline', plugins_url('svg-support/js/svg-inline.js'), array(), '1.0.0', false );
6
- wp_enqueue_script('bodhi_gc_svg_inline');
7
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  ?>
1
  <?php
2
+ /********************************************
3
+ * ENQUEUE SCRIPTS AND STYLES
4
+ ********************************************/
5
+
6
+ // enqueue and localize JS for IMG tag replacement
7
+ add_action( 'wp_enqueue_scripts', 'bodhi_svgs_inline' );
8
+
9
+ function bodhi_svgs_inline() {
10
+
11
+ global $bodhi_svgs_options;
12
+
13
+ $css_target = 'img.'. $bodhi_svgs_options['css_target']; // sets the custom class for use in JS
14
+
15
+ wp_register_script('bodhi_svg_inline', plugins_url('svg-support/js/svg-inline.js'), array(), '1.0.0', false );
16
+ wp_enqueue_script('bodhi_svg_inline');
17
+ wp_localize_script( 'bodhi_svg_inline', 'cssTarget', $css_target );
18
 
 
 
 
19
  }
20
+
21
+ // Check if we're on our settings page for conditional loading
22
+ function bodhi_svgs_setings_page_only() {
23
+
24
+ $screen = get_current_screen();
25
+
26
+ if( is_object($screen) && $screen->id == 'settings_page_svg-support' ) {
27
+ return true;
28
+ } else {
29
+ return false;
30
+ }
31
+
32
+ }
33
+
34
+ // enqueue admin settings css only on our settings page
35
+ add_action( 'admin_enqueue_scripts', 'bodhi_svgs_admin_style' );
36
+
37
+ function bodhi_svgs_admin_style() {
38
+
39
+ if( bodhi_svgs_setings_page_only() ) {
40
+ wp_enqueue_style( 'bodhi_svgs_admin_style', plugins_url('svg-support/css/svgs-admin.css') );
41
+ }
42
+
43
+ }
44
+
45
  ?>
functions/localization.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /********************************************
3
+ * INTERNATIONALIZATION / LOCALIZATION
4
+ ********************************************/
5
+
6
+ add_action( 'plugins_loaded', 'bodhi_svgs_localization' );
7
+
8
+ function bodhi_svgs_localization() {
9
+ load_plugin_textdomain( 'svgsupport', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
10
+ }
11
+
12
+ ?>
functions/mime-types.php CHANGED
@@ -1,8 +1,22 @@
1
  <?php
2
- add_filter( 'upload_mimes', 'bodhi_gc_upload_mimes' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- function bodhi_gc_upload_mimes($mimes = array()) {
5
- $mimes['svg'] = 'image/svg+xml'; // allow SVG file upload
6
- return $mimes;
7
  }
 
8
  ?>
1
  <?php
2
+ /********************************************
3
+ * ADD MIME TYPES
4
+ ********************************************/
5
+
6
+ add_filter( 'upload_mimes', 'bodhi_svgs_upload_mimes' );
7
+
8
+ function bodhi_svgs_upload_mimes($mimes = array()) {
9
+
10
+ global $bodhi_svgs_options;
11
+
12
+ if( empty( $bodhi_svgs_options['restrict'] ) || current_user_can( 'administrator' ) ) {
13
+ // allow SVG file upload
14
+ $mimes['svg'] = 'image/svg+xml';
15
+ return $mimes;
16
+ } else {
17
+ return $mimes;
18
+ }
19
 
 
 
 
20
  }
21
+
22
  ?>
js/svg-inline.js CHANGED
@@ -1,30 +1,67 @@
1
  jQuery(document).ready(function ($) {
2
- jQuery('img.style-svg').each(function(){
3
- var $img = jQuery(this);
4
- var imgID = $img.attr('id');
5
- var imgClass = $img.attr('class');
6
- var imgURL = $img.attr('src');
7
-
8
- jQuery.get(imgURL, function(data) {
9
- // Get the SVG tag, ignore the rest
10
- var $svg = jQuery(data).find('svg');
11
-
12
- // Add replaced image's ID to the new SVG
13
- if(typeof imgID !== 'undefined') {
14
- $svg = $svg.attr('id', imgID);
15
- }
16
- // Add replaced image's classes to the new SVG
17
- if(typeof imgClass !== 'undefined') {
18
- $svg = $svg.attr('class', imgClass+' replaced-svg');
19
- }
20
-
21
- // Remove any invalid XML tags as per http://validator.w3.org
22
- $svg = $svg.removeAttr('xmlns:a');
23
-
24
- // Replace image with new SVG
25
- $img.replaceWith($svg);
26
-
27
- }, 'xml');
28
-
29
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  });
1
  jQuery(document).ready(function ($) {
2
+
3
+ if( cssTarget != "" ) { // first check if custom class field is not empty
4
+
5
+ jQuery( cssTarget ).each(function(){
6
+ var $img = jQuery(this);
7
+ var imgID = $img.attr('id');
8
+ var imgClass = $img.attr('class');
9
+ var imgURL = $img.attr('src');
10
+
11
+ jQuery.get(imgURL, function(data) {
12
+ // Get the SVG tag, ignore the rest
13
+ var $svg = jQuery(data).find('svg');
14
+
15
+ // Add replaced image's ID to the new SVG
16
+ if(typeof imgID !== 'undefined') {
17
+ $svg = $svg.attr('id', imgID);
18
+ }
19
+ // Add replaced image's classes to the new SVG
20
+ if(typeof imgClass !== 'undefined') {
21
+ $svg = $svg.attr('class', imgClass+' replaced-svg');
22
+ }
23
+
24
+ // Remove any invalid XML tags as per http://validator.w3.org
25
+ $svg = $svg.removeAttr('xmlns:a');
26
+
27
+ // Replace image with new SVG
28
+ $img.replaceWith($svg);
29
+
30
+ }, 'xml');
31
+
32
+ });
33
+
34
+ } else { // use the default class if field was empty
35
+
36
+ jQuery('img.style-svg').each(function(){
37
+ var $img = jQuery(this);
38
+ var imgID = $img.attr('id');
39
+ var imgClass = $img.attr('class');
40
+ var imgURL = $img.attr('src');
41
+
42
+ jQuery.get(imgURL, function(data) {
43
+ // Get the SVG tag, ignore the rest
44
+ var $svg = jQuery(data).find('svg');
45
+
46
+ // Add replaced image's ID to the new SVG
47
+ if(typeof imgID !== 'undefined') {
48
+ $svg = $svg.attr('id', imgID);
49
+ }
50
+ // Add replaced image's classes to the new SVG
51
+ if(typeof imgClass !== 'undefined') {
52
+ $svg = $svg.attr('class', imgClass+' replaced-svg');
53
+ }
54
+
55
+ // Remove any invalid XML tags as per http://validator.w3.org
56
+ $svg = $svg.removeAttr('xmlns:a');
57
+
58
+ // Replace image with new SVG
59
+ $img.replaceWith($svg);
60
+
61
+ }, 'xml');
62
+
63
+ });
64
+
65
+ }
66
+
67
  });
languages/svg-support-en_AU.po DELETED
@@ -1,58 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: SVG Support v1.0\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: \n"
6
- "PO-Revision-Date: 2014-07-22 06:51:40+0000\n"
7
- "Last-Translator: GoWebben <info@gowebben.com>\n"
8
- "Language-Team: \n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
- "X-Generator: CSL v1.x\n"
14
- "X-Poedit-Language: English\n"
15
- "X-Poedit-Country: AUSTRALIA\n"
16
- "X-Poedit-SourceCharset: utf-8\n"
17
- "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
18
- "X-Poedit-Basepath: ../\n"
19
- "X-Poedit-Bookmarks: \n"
20
- "X-Poedit-SearchPath-0: .\n"
21
- "X-Textdomain-Support: yes"
22
-
23
- #. translators: plugin header field 'Name'
24
- #: svg-support.php:0
25
- #@ svg-support
26
- msgid "SVG Support"
27
- msgstr ""
28
-
29
- #. translators: plugin header field 'PluginURI'
30
- #: svg-support.php:0
31
- #@ svg-support
32
- msgid "http://gowebben.com/"
33
- msgstr ""
34
-
35
- #. translators: plugin header field 'Description'
36
- #: svg-support.php:0
37
- #@ svg-support
38
- msgid "Allows SVG file uploads plus direct styling of SVG elements using CSS."
39
- msgstr ""
40
-
41
- #. translators: plugin header field 'Author'
42
- #: svg-support.php:0
43
- #@ svg-support
44
- msgid "Benbodhi"
45
- msgstr ""
46
-
47
- #. translators: plugin header field 'AuthorURI'
48
- #: svg-support.php:0
49
- #@ svg-support
50
- msgid "http://benbodhi.com"
51
- msgstr ""
52
-
53
- #. translators: plugin header field 'Version'
54
- #: svg-support.php:0
55
- #@ svg-support
56
- msgid "1.0"
57
- msgstr ""
58
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/{svg-support-en_AU.mo → svgsupport-en_AU.mo} RENAMED
Binary file
languages/svgsupport-en_AU.po ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: SVG Support v2.1\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: 2014-07-23 11:21:54+0000\n"
7
+ "Last-Translator: \n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
+ "X-Generator: CSL v1.x\n"
14
+ "X-Poedit-Language: \n"
15
+ "X-Poedit-Country: \n"
16
+ "X-Poedit-SourceCharset: utf-8\n"
17
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
18
+ "X-Poedit-Basepath: \n"
19
+ "X-Poedit-Bookmarks: \n"
20
+ "X-Poedit-SearchPath-0: .\n"
21
+ "X-Textdomain-Support: yes"
22
+
23
+ #: admin/admin-init.php:12
24
+ #@ svgsupport
25
+ msgid "SVG Support Options and Instructions"
26
+ msgstr ""
27
+
28
+ #. translators: plugin header field 'Name'
29
+ #: admin/admin-init.php:13
30
+ #: svg-support.php:0
31
+ #@ svgsupport
32
+ msgid "SVG Support"
33
+ msgstr ""
34
+
35
+ #: admin/admin-init.php:26
36
+ #@ svgsupport
37
+ msgid "You can't play with this."
38
+ msgstr ""
39
+
40
+ #: admin/svgs-settings-page.php:4
41
+ #@ svgsupport
42
+ msgid "SVG Support Settings and Usage"
43
+ msgstr ""
44
+
45
+ #: admin/svgs-settings-page.php:12
46
+ #@ svgsupport
47
+ msgid "Introduction"
48
+ msgstr ""
49
+
50
+ #: admin/svgs-settings-page.php:15
51
+ #@ svgsupport
52
+ msgid "When using SVG images on your WordPress site, it can be hard to style elements within the SVG using CSS. <strong>Now you can, easily!</strong>"
53
+ msgstr ""
54
+
55
+ #: admin/svgs-settings-page.php:16
56
+ #@ svgsupport
57
+ msgid "This plugin not only provides SVG Support like the name says, it also allows you to easily embed your full SVG file's code using a simple IMG tag. By adding the class <code>style-svg</code> to your IMG elements, this plugin dynamically replaces any IMG elements containing the <code>style-svg</code> class with your complete SVG."
58
+ msgstr ""
59
+
60
+ #: admin/svgs-settings-page.php:17
61
+ #@ svgsupport
62
+ msgid "The main purpose of this is to allow styling of SVG elements. Usually your styling options are restricted when using <code>embed</code>, <code>object</code> or <code>img</code> tags alone."
63
+ msgstr ""
64
+
65
+ #: admin/svgs-settings-page.php:34
66
+ #@ svgsupport
67
+ msgid "Settings"
68
+ msgstr ""
69
+
70
+ #: admin/svgs-settings-page.php:46
71
+ #@ svgsupport
72
+ msgid "Restrict to Administrators"
73
+ msgstr ""
74
+
75
+ #: admin/svgs-settings-page.php:51
76
+ #@ svgsupport
77
+ msgid "Yes"
78
+ msgstr ""
79
+
80
+ #: admin/svgs-settings-page.php:51
81
+ #@ svgsupport
82
+ msgid " Restricts SVG upload priveledges to Administrators."
83
+ msgstr ""
84
+
85
+ #: admin/svgs-settings-page.php:56
86
+ #@ svgsupport
87
+ msgid "CSS Class to target"
88
+ msgstr ""
89
+
90
+ #: admin/svgs-settings-page.php:59
91
+ #@ svgsupport
92
+ msgid "The default target class is <code>style-svg</code>. You can change it to your own class such as <code>my-class</code> by typing it here.<br />Leave blank to use the default class."
93
+ msgstr ""
94
+
95
+ #: admin/svgs-settings-page.php:65
96
+ #@ svgsupport
97
+ msgid "Save Changes"
98
+ msgstr ""
99
+
100
+ #: admin/svgs-settings-page.php:76
101
+ #@ svgsupport
102
+ msgid "Usage"
103
+ msgstr ""
104
+
105
+ #: admin/svgs-settings-page.php:79
106
+ #@ svgsupport
107
+ msgid "You can simply upload SVG images to your media library like any other file."
108
+ msgstr ""
109
+
110
+ #: admin/svgs-settings-page.php:80
111
+ #@ svgsupport
112
+ msgid "Now, embed your SVG image like a standard image with the addition of adding the class <code>style-svg</code> (or your custom class from above) to any IMG tags that you want this plugin to swap out with your actual SVG code."
113
+ msgstr ""
114
+
115
+ #: admin/svgs-settings-page.php:81
116
+ #@ svgsupport
117
+ msgid "For example:"
118
+ msgstr ""
119
+
120
+ #: admin/svgs-settings-page.php:84
121
+ #@ svgsupport
122
+ msgid "or"
123
+ msgstr ""
124
+
125
+ #: admin/svgs-settings-page.php:87
126
+ #@ svgsupport
127
+ msgid "The whole IMG tag element will now be dynamically replaced by the actual code of your SVG, making the inner content targetable."
128
+ msgstr ""
129
+
130
+ #: admin/svgs-settings-page.php:88
131
+ #@ svgsupport
132
+ msgid "This allows you to target elements within your SVG using CSS."
133
+ msgstr ""
134
+
135
+ #: admin/svgs-settings-page.php:90
136
+ #@ svgsupport
137
+ msgid "Note: Your uploaded image needs to be an SVG file for this plugin to replace the img tag with the inline SVG code. It will not create SVG files for you."
138
+ msgstr ""
139
+
140
+ #: admin/svgs-settings-page.php:107
141
+ #@ svgsupport
142
+ msgid "Features"
143
+ msgstr ""
144
+
145
+ #: admin/svgs-settings-page.php:110
146
+ #@ svgsupport
147
+ msgid "SVG Support for your media library"
148
+ msgstr ""
149
+
150
+ #: admin/svgs-settings-page.php:111
151
+ #@ svgsupport
152
+ msgid "Style SVG elements directly using CSS"
153
+ msgstr ""
154
+
155
+ #: admin/svgs-settings-page.php:112
156
+ #@ svgsupport
157
+ msgid "Restrict to Administrators only"
158
+ msgstr ""
159
+
160
+ #: admin/svgs-settings-page.php:113
161
+ #@ svgsupport
162
+ msgid "Extremely Simple To Use"
163
+ msgstr ""
164
+
165
+ #: admin/svgs-settings-page.php:121
166
+ #@ svgsupport
167
+ msgid "About the plugin"
168
+ msgstr ""
169
+
170
+ #: admin/svgs-settings-page.php:123
171
+ #@ svgsupport
172
+ msgid "You can read about this plugin in detail on"
173
+ msgstr ""
174
+
175
+ #: admin/svgs-settings-page.php:123
176
+ #@ svgsupport
177
+ msgid "The WordPress Plugin Repository"
178
+ msgstr ""
179
+
180
+ #: admin/svgs-settings-page.php:124
181
+ #@ svgsupport
182
+ msgid "Need help?"
183
+ msgstr ""
184
+
185
+ #: admin/svgs-settings-page.php:124
186
+ #@ svgsupport
187
+ msgid "Visit Support"
188
+ msgstr ""
189
+
190
+ #: admin/svgs-settings-page.php:125
191
+ #@ svgsupport
192
+ msgid "from"
193
+ msgstr ""
194
+
195
+ #. translators: plugin header field 'PluginURI'
196
+ #: svg-support.php:0
197
+ #@ svgsupport
198
+ msgid "http://wordpress.org/plugins/svg-support/"
199
+ msgstr ""
200
+
201
+ #. translators: plugin header field 'Description'
202
+ #: svg-support.php:0
203
+ #@ svgsupport
204
+ msgid "Allow SVG file uploads using the WordPress Media Library uploader plus direct styling of SVG elements using CSS."
205
+ msgstr ""
206
+
207
+ #. translators: plugin header field 'Author'
208
+ #: svg-support.php:0
209
+ #@ svgsupport
210
+ msgid "Benbodhi"
211
+ msgstr ""
212
+
213
+ #. translators: plugin header field 'AuthorURI'
214
+ #: svg-support.php:0
215
+ #@ svgsupport
216
+ msgid "http://benbodhi.com"
217
+ msgstr ""
218
+
219
+ #. translators: plugin header field 'Version'
220
+ #: svg-support.php:0
221
+ #@ svgsupport
222
+ msgid "2.1"
223
+ msgstr ""
224
+
readme.txt CHANGED
@@ -4,11 +4,11 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: svg, vector, css, style, mime, mime type, embed, img, inline
5
  Requires at least: 3.4
6
  Tested up to: 3.9.1
7
- Stable tag: 1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Allows SVG file uploads plus direct styling of SVG elements using CSS.
12
 
13
  == Description ==
14
 
@@ -23,19 +23,27 @@ The main purpose of this is to allow styling of SVG elements. Usually your styli
23
 
24
  = Features =
25
 
26
- * Adds mime type support for SVG uploads to your media library
27
- * Allows you to style SVG files and their elements directly using CSS
28
- * No settings, no menu - it just works
 
 
 
29
 
30
  = Usage =
31
 
32
  Firstly, install SVG Support (this plugin) and activate it.
 
33
  Once activated, you can simply upload SVG images to your media library like any other file.
34
 
35
- Now, embed your SVG image like a standard image with the addition of adding the class `"style-svg"` to your IMG tags that you want this plugin to swap out with your actual SVG code.<br />
 
 
36
  For example:
37
 
38
  `<img class="style-svg" alt="alt-text" src="image-source.svg" />`
 
 
39
 
40
  The whole IMG tag element will now be dynamically replaced by the actual code of your SVG, making the inner content targetable.<br />
41
  This allows you to target elements within your SVG using CSS.
@@ -44,7 +52,7 @@ This allows you to target elements within your SVG using CSS.
44
 
45
  = Security =
46
 
47
- As with allowing uploads of any files, there is potential risks involved. Only allow users to upload SVG files if you trust them. I will be adding the ability to choose which roles can upload SVG files in the future.
48
 
49
  = Translations =
50
 
@@ -93,19 +101,40 @@ I will put the answers to any questions asked here.
93
 
94
  == Screenshots ==
95
 
96
- 1. Activated plugin (everything works behind the scenes)
 
97
 
98
  == Changelog ==
99
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  = 1.0 =
101
 
102
  * Initial Release.
103
 
104
  == Upgrade Notice ==
105
 
 
 
 
 
 
 
 
 
106
  = 1.0 =
107
 
108
- Initial Release.
109
 
110
  == Translations ==
111
 
@@ -115,11 +144,13 @@ Initial Release.
115
  *Note:* This plugin is localized/translateable by default. This is very important for all users worldwide. So please contribute your language to the plugin to make it even more useful. For translating I recommend the awesome ["Codestyling Localization" plugin](http://wordpress.org/extend/plugins/codestyling-localization/) and for validating the ["Poedit Editor"](http://www.poedit.net/).
116
 
117
  == Additional Info ==
118
- **Idea Behind / Philosophy:** I needed an easy way to include this support in sites that I build instead of having to copy paste the code for each one. I found a [really cool snippet](http://stackoverflow.com/questions/11978995/how-to-change-color-of-svg-image-using-css-jquery-svg-image-replacement) of jQuery written by Drew Baker a while ago and have used it (modified for WordPress) a few times until I decided to put it all into a plugin for ease of use and to share with others. Now styling SVG elements is super easy :)
119
 
120
  == Future Features ==
121
- * Help / Instructions Page
122
- * Ability to choose user roles allowed to upload SVG format (eg. restrict to administrator)
 
 
123
  Again, feel free to [shoot me suggestions](mailto:wp@benbodhi.com)
124
 
125
  == Credits ==
4
  Tags: svg, vector, css, style, mime, mime type, embed, img, inline
5
  Requires at least: 3.4
6
  Tested up to: 3.9.1
7
+ Stable tag: 2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Allow SVG file uploads using the WordPress Media Library uploader plus direct styling of SVG elements using CSS.
12
 
13
  == Description ==
14
 
23
 
24
  = Features =
25
 
26
+ * SVG Support for your media library
27
+ * Style SVG elements directly using CSS
28
+ * Super easy settings page with instructions
29
+ * Restrict SVG upload ability to Administrators only
30
+ * Set custom css target class
31
+ * **Extremely Simple To Use**
32
 
33
  = Usage =
34
 
35
  Firstly, install SVG Support (this plugin) and activate it.
36
+
37
  Once activated, you can simply upload SVG images to your media library like any other file.
38
 
39
+ As an administrator, you can go to the admin settings page 'Settings' > 'SVG Support' and restrict SVG file uploads to administrators only and even define a custom class to target if you wish.
40
+
41
+ Now, embed your SVG images just like you would a standard image with the addition of adding the class `"style-svg"` (or the custom class you defined) to your IMG tags that you want this plugin to swap out with your actual SVG code.<br />
42
  For example:
43
 
44
  `<img class="style-svg" alt="alt-text" src="image-source.svg" />`
45
+ or
46
+ `<img class="your-custom-class" alt="alt-text" src="image-source.svg" />`
47
 
48
  The whole IMG tag element will now be dynamically replaced by the actual code of your SVG, making the inner content targetable.<br />
49
  This allows you to target elements within your SVG using CSS.
52
 
53
  = Security =
54
 
55
+ As with allowing uploads of any files, there is potential risks involved. Only allow users to upload SVG files if you trust them. You have the option to restrict SVG usage to Administrators only from the settings page. By default, anyone with Media Library access or upload_files capability will be able to upload SVG files (that is Administrators, Authors and Editors).
56
 
57
  = Translations =
58
 
101
 
102
  == Screenshots ==
103
 
104
+ 1. Activated plugin
105
+ 2. Admin settings page
106
 
107
  == Changelog ==
108
 
109
+ = 2.1 =
110
+
111
+ * Updates to language files for localization.
112
+
113
+ = 2.0 =
114
+
115
+ * Add admin settings page with instructions plus options for restricting to admin use only and setting a custom CSS target class.
116
+ * Whole plugin completely re-written and re-structured.
117
+ * Added option to restrict SVG uploads to administrators only.
118
+ * Added field for custom CSS target class.
119
+ * Added stylesheet to admin settings page.
120
+
121
  = 1.0 =
122
 
123
  * Initial Release.
124
 
125
  == Upgrade Notice ==
126
 
127
+ = 2.1 =
128
+
129
+ * Updated language files for localization that were missed in version 2.0.
130
+
131
+ = 2.0 =
132
+
133
+ * SVG Support has been completely re-written and re-structured. It now includes an admin settings page with instructions, plus options for restricting to admin use only and setting a custom CSS target class.
134
+
135
  = 1.0 =
136
 
137
+ * Initial Release.
138
 
139
  == Translations ==
140
 
144
  *Note:* This plugin is localized/translateable by default. This is very important for all users worldwide. So please contribute your language to the plugin to make it even more useful. For translating I recommend the awesome ["Codestyling Localization" plugin](http://wordpress.org/extend/plugins/codestyling-localization/) and for validating the ["Poedit Editor"](http://www.poedit.net/).
145
 
146
  == Additional Info ==
147
+ **Idea Behind / Philosophy:** I needed an easy way to include SVG support in sites instead of having to copy and paste the code for each one. I found a [really cool snippet](http://stackoverflow.com/questions/11978995/how-to-change-color-of-svg-image-using-css-jquery-svg-image-replacement) of jQuery written by Drew Baker a while ago and have used it (modified for WordPress) a few times until I was inspired to build it all into a plugin for ease of use and to share with others. Now styling SVG elements is super easy :)
148
 
149
  == Future Features ==
150
+ * Help / Instructions Page **ADDED in 2.0**
151
+ * Ability to choose user roles allowed to upload SVG format (eg. restrict to administrator) **ADDED in 2.0**
152
+ * Option to choose specific user ID's and restrict usage for everyone else (helpful if you have multiple administrators)
153
+
154
  Again, feel free to [shoot me suggestions](mailto:wp@benbodhi.com)
155
 
156
  == Credits ==
svg-support.php CHANGED
@@ -2,44 +2,43 @@
2
  /*
3
  Plugin Name: SVG Support
4
  Plugin URI: http://wordpress.org/plugins/svg-support/
5
- Description: Allows SVG file uploads plus direct styling of SVG elements using CSS.
6
  Author: Benbodhi
7
  Author URI: http://benbodhi.com
8
- Text Domain: svg-support
9
  Domain Path: /languages
10
  License: GPL2
11
- Version: 1.0
12
  */
13
  /* Copyright 2013 Benbodhi (email : wp@benbodhi.com)
14
 
15
- This program is free software; you can redistribute it and/or modify
16
- it under the terms of the GNU General Public License, version 2, as
17
- published by the Free Software Foundation.
18
 
19
- This program is distributed in the hope that it will be useful,
20
- but WITHOUT ANY WARRANTY; without even the implied warranty of
21
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
- GNU General Public License for more details.
23
 
24
- You should have received a copy of the GNU General Public License
25
- along with this program; if not, write to the Free Software
26
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
  */
28
 
29
- /********************************************
30
- * INTERNATIONALIZATION / LOCALIZATION
31
- ********************************************/
32
- load_plugin_textdomain('svg-support', false, basename( dirname( __FILE__ ) ) . '/languages' );
33
-
34
  /********************************************
35
  * GLOBAL VARIABLES
36
  ********************************************/
 
37
  define( 'BODHI_SVGS_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); // define the absolute plugin path for includes
 
38
 
39
  /********************************************
40
  * INCLUDES - keeping it modular
41
  ********************************************/
42
- include( BODHI_SVGS_PLUGIN_PATH . 'functions/mime-types.php' ); // include mime types support file
43
- include( BODHI_SVGS_PLUGIN_PATH . 'functions/enqueue.php' ); // include enqueues file
 
 
44
 
45
  ?>
2
  /*
3
  Plugin Name: SVG Support
4
  Plugin URI: http://wordpress.org/plugins/svg-support/
5
+ Description: Allow SVG file uploads using the WordPress Media Library uploader plus direct styling of SVG elements using CSS.
6
  Author: Benbodhi
7
  Author URI: http://benbodhi.com
8
+ Text Domain: svgsupport
9
  Domain Path: /languages
10
  License: GPL2
11
+ Version: 2.1
12
  */
13
  /* Copyright 2013 Benbodhi (email : wp@benbodhi.com)
14
 
15
+ This program is free software; you can redistribute it and/or modify
16
+ it under the terms of the GNU General Public License, version 2, as
17
+ published by the Free Software Foundation.
18
 
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
 
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
  */
28
 
 
 
 
 
 
29
  /********************************************
30
  * GLOBAL VARIABLES
31
  ********************************************/
32
+ $plugin_version = '2.1'; // for use on admin pages
33
  define( 'BODHI_SVGS_PLUGIN_PATH', plugin_dir_path( __FILE__ ) ); // define the absolute plugin path for includes
34
+ $bodhi_svgs_options = get_option('bodhi_svgs_settings'); // retrieve our plugin settings from the options table
35
 
36
  /********************************************
37
  * INCLUDES - keeping it modular
38
  ********************************************/
39
+ include( BODHI_SVGS_PLUGIN_PATH . 'functions/localization.php' ); // setup localization & languages
40
+ include( BODHI_SVGS_PLUGIN_PATH . 'admin/admin-init.php' ); // initialize admin menu & settings
41
+ include( BODHI_SVGS_PLUGIN_PATH . 'functions/mime-types.php' ); // setup mime types support for SVG
42
+ include( BODHI_SVGS_PLUGIN_PATH . 'functions/enqueue.php' ); // enqueue js & css for inline replacement
43
 
44
  ?>