PluginProbe ʕ •ᴥ•ʔ
SVG Support / 2.5.16
SVG Support v2.5.16
2.5.15 2.5.16 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 trunk 1.0 2.0 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2 2.2.1 2.2.2 2.2.3 2.2.3.1 2.2.3.2 2.2.4 2.2.5 2.3 2.3.1 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.15 2.3.16 2.3.17 2.3.18 2.3.19 2.3.2 2.3.20 2.3.21 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4 2.4.1 2.4.2 2.5 2.5.1
svg-support / svg-support.php
svg-support Last commit date
admin 4 days ago css 3 years ago functions 4 days ago includes 1 year ago integrations 1 year ago js 1 year ago languages 8 years ago vendor 4 days ago readme.txt 4 days ago svg-support.php 4 days ago svg-support.png 8 years ago uninstall.php 1 year ago
svg-support.php
153 lines
1 <?php
2 /*
3 Plugin Name: SVG Support
4 Plugin URI: http://wordpress.org/plugins/svg-support/
5 Description: Upload SVG files to the Media Library and render SVG files inline for direct styling/animation of an SVG's internal elements using CSS/JS.
6 Version: 2.5.16
7 Author URI: https://benbodhi.com
8 Text Domain: svg-support
9 Domain Path: /languages
10 License: GPLv2 or later
11 License URI: http://www.gnu.org/licenses/gpl-2.0.html
12 Requires at least: 5.8
13 Requires PHP: 7.4
14 Block: true
15
16 Copyright 2013 and beyond | Benbodhi (email : wp@benbodhi.com)
17
18 */
19
20 if ( ! defined( 'ABSPATH' ) ) {
21 exit; // Exit if accessed directly
22 }
23
24 /**
25 * Global variables and constants
26 */
27 global $bodhi_svgs_options;
28 $bodhi_svgs_options = array(); // Defining global array
29 define('BODHI_SVGS_VERSION', get_file_data(__FILE__, array('Version' => 'Version'))['Version']);
30 define('BODHI_SVGS_PLUGIN_FILE', __FILE__); // define the absolute plugin file path
31 define('BODHI_SVGS_PLUGIN_PATH', plugin_dir_path(__FILE__)); // define the absolute plugin path for includes
32 define('BODHI_SVGS_PLUGIN_URL', plugin_dir_url(__FILE__)); // define the plugin url for use in enqueue
33 $bodhi_svgs_options = get_option('bodhi_svgs_settings', array()); // Retrieve our plugin settings
34
35 // ensure $bodhi_svgs_options is always an array
36 if (!is_array($bodhi_svgs_options)) {
37 $bodhi_svgs_options = [];
38 update_option('bodhi_svgs_settings', $bodhi_svgs_options);
39 }
40
41 /**
42 * SVG Sanitizer class
43 */
44 // init svg sanitizer for usage
45 use enshrined\svgSanitize\Sanitizer;
46 // svg sanitizer
47 include( BODHI_SVGS_PLUGIN_PATH . 'vendor/autoload.php' );
48 // interfaces to enable custom whitelisting of svg tags and attributes
49 include( BODHI_SVGS_PLUGIN_PATH . 'includes/svg-tags.php' );
50 include( BODHI_SVGS_PLUGIN_PATH . 'includes/svg-attributes.php' );
51 // initialize sanitizer
52 $sanitizer = new Sanitizer();
53
54 /**
55 * Includes - keeping it modular
56 */
57 include( BODHI_SVGS_PLUGIN_PATH . 'admin/admin-init.php' ); // initialize admin menu & settings page
58 include( BODHI_SVGS_PLUGIN_PATH . 'admin/plugin-action-meta-links.php' ); // add links to the plugin on the plugins page
59 include( BODHI_SVGS_PLUGIN_PATH . 'functions/mime-types.php' ); // setup mime types support for SVG (with fix for WP 4.7.1 - 4.7.2)
60 include( BODHI_SVGS_PLUGIN_PATH . 'functions/thumbnail-display.php' ); // make SVG thumbnails display correctly in media library
61 include( BODHI_SVGS_PLUGIN_PATH . 'functions/attachment.php' ); // make SVG thumbnails display correctly in attachment modals and generate attachment sizes
62 include( BODHI_SVGS_PLUGIN_PATH . 'functions/enqueue.php' ); // enqueue js & css for inline replacement & admin
63 include( BODHI_SVGS_PLUGIN_PATH . 'functions/localization.php' ); // setup localization & languages
64 include( BODHI_SVGS_PLUGIN_PATH . 'functions/attribute-control.php' ); // auto set SVG class & remove dimensions during insertion
65 include( BODHI_SVGS_PLUGIN_PATH . 'functions/featured-image.php' ); // allow inline SVG for featured images
66 include( BODHI_SVGS_PLUGIN_PATH . 'functions/meta-cleanup.php' ); // cleanup duplicate meta entries
67
68 // Include WP All Import integration only if WP All Import is active
69 // if ( defined( 'PMXI_VERSION' ) ) {
70 // include( BODHI_SVGS_PLUGIN_PATH . 'integrations/wp-all-import.php' );
71 // }
72
73 /**
74 * Handle version updates and migrations
75 *
76 * Handles version comparisons for all format types:
77 * - Single digit versions (1, 2)
78 * - Zero versions (0, 0.1, 0.5.26)
79 * - Two-digit versions (1.0, 2.1, 2.5)
80 * - Three-digit versions (1.5.17, 2.5.9)
81 * - Fresh installs ('0.0.0')
82 * - Legacy versions (null, empty, invalid)
83 */
84 function bodhi_svgs_version_updates() {
85 $stored_version = get_option('bodhi_svgs_plugin_version', '0.0.0');
86
87 if (!is_string($stored_version) || empty($stored_version)) {
88 $stored_version = '0.0.0';
89 }
90
91 // Skip if already at current version
92 if ($stored_version === BODHI_SVGS_VERSION) {
93 return;
94 }
95
96 // Store the old version for comparison
97 $old_version = $stored_version;
98
99 // Update to current version
100 update_option('bodhi_svgs_plugin_version', BODHI_SVGS_VERSION);
101
102 // If coming from before 2.5.14, run cleanup
103 if (version_compare($old_version, '2.5.14', '<')) {
104 require_once BODHI_SVGS_PLUGIN_PATH . 'functions/meta-cleanup.php';
105 bodhi_svgs_cleanup_duplicate_meta();
106 }
107 }
108 add_action('admin_init', 'bodhi_svgs_version_updates');
109
110 /**
111 * Defaults for better security in versions >= 2.5
112 */
113 // Enable 'sanitize_svg_front_end' by default
114 if ( !isset($bodhi_svgs_options['sanitize_svg_front_end']) ) {
115 $bodhi_svgs_options['sanitize_svg_front_end'] = 'on';
116 update_option( 'bodhi_svgs_settings', $bodhi_svgs_options );
117 }
118
119 // Allow only admins to upload SVGs by default
120 if ( !isset($bodhi_svgs_options['restrict']) || $bodhi_svgs_options['restrict'] == "on" ) {
121 $bodhi_svgs_options['restrict'] = array('administrator');
122 update_option( 'bodhi_svgs_settings', $bodhi_svgs_options );
123 }
124 elseif (isset($bodhi_svgs_options['restrict']) && $bodhi_svgs_options['restrict'] == "none" ) {
125 $bodhi_svgs_options['restrict'] = array("none");
126 update_option( 'bodhi_svgs_settings', $bodhi_svgs_options );
127 }
128
129 // By default sanitize on upload for everyone (no bypass roles)
130 if ( !isset($bodhi_svgs_options['sanitize_on_upload_roles']) ) {
131 $bodhi_svgs_options['sanitize_on_upload_roles'] = array();
132 update_option( 'bodhi_svgs_settings', $bodhi_svgs_options );
133 }
134 elseif ( isset($bodhi_svgs_options['sanitize_on_upload_roles']) && $bodhi_svgs_options['sanitize_on_upload_roles'] == "none") {
135 $bodhi_svgs_options['sanitize_on_upload_roles'] = array("none");
136 update_option( 'bodhi_svgs_settings', $bodhi_svgs_options );
137 }
138
139 /**
140 * Register activation and deactivation hooks
141 */
142 // Activation Hook
143 function bodhi_svgs_plugin_activation() {
144 bodhi_svgs_remove_old_sanitize_setting();
145 }
146 register_activation_hook(__FILE__, 'bodhi_svgs_plugin_activation');
147
148 // Deactivation Hook
149 function bodhi_svgs_plugin_deactivation() {
150 bodhi_svgs_remove_old_sanitize_setting();
151 }
152 register_deactivation_hook(__FILE__, 'bodhi_svgs_plugin_deactivation');
153