PluginProbe
Elementor Website Builder – more than just a page builder / 3.26.0-dev5
Elementor Website Builder – more than just a page builder v3.26.0-dev5
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / core / files / assets / svg / svg-handler.php

svg-handler.php in Elementor Website Builder – more than just a page builder 3.26.0-dev5, at core/files/assets/svg/svg-handler.php

246 lines 6.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Files\Assets\Svg;
3
4 use Elementor\Core\Files\Assets\Files_Upload_Handler;
5 use Elementor\Core\Files\File_Types\Svg;
6 use Elementor\Core\Files\Uploads_Manager;
7 use Elementor\Plugin;
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly.
11 }
12
13 /**
14 * SVG Handler
15 *
16 * @deprecated 3.5.0 Use `Elementor\Core\Files\File_Types\Svg` instead, accessed by calling: `Plugin::$instance->uploads_manager->get_file_type_handlers( 'svg' );`
17 */
18 class Svg_Handler extends Files_Upload_Handler {
19
20 /**
21 * Inline svg attachment meta key
22 *
23 * @deprecated 3.5.0
24 */
25 const META_KEY = '_elementor_inline_svg';
26
27 /**
28 * @deprecated 3.5.0
29 */
30 const SCRIPT_REGEX = '/(?:\w+script|data):/xi';
31
32 /**
33 * Attachment ID.
34 *
35 * Holds the current attachment ID.
36 *
37 * @deprecated 3.5.0
38 *
39 * @var int
40 */
41 private $attachment_id;
42
43 /**
44 * @deprecated 3.5.0
45 */
46 public static function get_name() {
47 return 'svg-handler';
48 }
49
50 /**
51 * get_meta
52 *
53 * @deprecated 3.5.0
54 *
55 * @return mixed
56 */
57 protected function get_meta() {
58 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0' );
59
60 return get_post_meta( $this->attachment_id, self::META_KEY, true );
61 }
62
63 /**
64 * update_meta
65 *
66 * @deprecated 3.5.0
67 *
68 * @param $meta
69 */
70 protected function update_meta( $meta ) {
71 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0' );
72
73 update_post_meta( $this->attachment_id, self::META_KEY, $meta );
74 }
75
76 /**
77 * delete_meta
78 *
79 * @deprecated 3.5.0
80 */
81 protected function delete_meta() {
82 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0' );
83
84 delete_post_meta( $this->attachment_id, self::META_KEY );
85 }
86
87 /**
88 * @deprecated 3.5.0
89 */
90 public function get_mime_type() {
91 return 'image/svg+xml';
92 }
93
94 /**
95 * @deprecated 3.5.0
96 */
97 public function get_file_type() {
98 return 'svg';
99 }
100
101 /**
102 * delete_meta_cache
103 *
104 * @deprecated 3.5.0 Use `Plugin::$instance->uploads_manager->get_file_type_handlers( 'svg' )->delete_meta_cache()` instead.
105 */
106 public function delete_meta_cache() {
107 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0', 'Plugin::$instance->uploads_manager->get_file_type_handlers( \'svg\' )->delete_meta_cache()' );
108
109 /** @var Svg $svg_handler */
110 $svg_handler = Plugin::$instance->uploads_manager->get_file_type_handlers( 'svg' );
111
112 $svg_handler->delete_meta_cache();
113 }
114
115 /**
116 * get_inline_svg
117 *
118 * @deprecated 3.5.0 Use `Elementor\Core\Files\File_Types\Svg::get_inline_svg()` instead.
119 *
120 * @param $attachment_id
121 *
122 * @return bool|mixed|string
123 */
124 public static function get_inline_svg( $attachment_id ) {
125 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0', 'Elementor\Core\Files\File_Types\Svg::get_inline_svg()' );
126
127 return Svg::get_inline_svg( $attachment_id );
128 }
129
130 /**
131 * sanitize_svg
132 *
133 * @deprecated 3.5.0 Use `Plugin::$instance->uploads_manager->get_file_type_handlers( 'svg' )->delete_meta_cache()->sanitize_svg()` instead.
134 *
135 * @param $filename
136 *
137 * @return bool
138 */
139 public function sanitize_svg( $filename ) {
140 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0', 'Plugin::$instance->uploads_manager->get_file_type_handlers( \'svg\' )->delete_meta_cache()->sanitize_svg()' );
141
142 /** @var Svg $svg_handler */
143 $svg_handler = Plugin::$instance->uploads_manager->get_file_type_handlers( 'svg' );
144
145 return $svg_handler->sanitize_svg( $filename );
146 }
147
148 /**
149 * sanitizer
150 *
151 * @deprecated 3.5.0 Use `Plugin::$instance->uploads_manager->get_file_type_handlers( 'svg' )->sanitizer()` instead.
152 *
153 * @param $content
154 *
155 * @return bool|string
156 */
157 public function sanitizer( $content ) {
158 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0', 'Plugin::$instance->uploads_manager->get_file_type_handlers( \'svg\' )->sanitizer()' );
159
160 /** @var Svg $svg_handler */
161 $svg_handler = Plugin::$instance->uploads_manager->get_file_type_handlers( 'svg' );
162
163 return $svg_handler->sanitizer( $content );
164 }
165
166 /**
167 * wp_prepare_attachment_for_js
168 *
169 * @deprecated 3.5.0 Use `Plugin::$instance->uploads_manager->get_file_type_handlers( 'svg' )->wp_prepare_attachment_for_js()` instead.
170 *
171 * @param $attachment_data
172 * @param $attachment
173 * @param $meta
174 *
175 * @return mixed
176 */
177 public function wp_prepare_attachment_for_js( $attachment_data, $attachment, $meta ) {
178 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0', 'Plugin::$instance->uploads_manager->get_file_type_handlers( \'svg\' )->wp_prepare_attachment_for_js()' );
179
180 /** @var Svg $svg_handler */
181 $svg_handler = Plugin::$instance->uploads_manager->get_file_type_handlers( 'svg' );
182
183 return $svg_handler->wp_prepare_attachment_for_js( $attachment_data, $attachment, $meta );
184 }
185
186 /**
187 * set_attachment_id
188 *
189 * @deprecated 3.5.0
190 *
191 * @param $attachment_id
192 *
193 * @return int
194 */
195 public function set_attachment_id( $attachment_id ) {
196 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0' );
197
198 $this->attachment_id = $attachment_id;
199 return $this->attachment_id;
200 }
201
202 /**
203 * get_attachment_id
204 *
205 * @deprecated 3.5.0
206 *
207 * @return int
208 */
209 public function get_attachment_id() {
210 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0' );
211
212 return $this->attachment_id;
213 }
214
215 /**
216 * set_svg_meta_data
217 *
218 * @deprecated 3.5.0 Use `Plugin::$instance->uploads_manager->get_file_type_handlers( 'svg' )->set_svg_meta_data()` instead.
219 *
220 * @return mixed
221 */
222 public function set_svg_meta_data( $data, $id ) {
223 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0', 'Plugin::$instance->uploads_manager->get_file_type_handlers( \'svg\' )->set_svg_meta_data()' );
224
225 /** @var Svg $svg_handler */
226 $svg_handler = Plugin::$instance->uploads_manager->get_file_type_handlers( 'svg' );
227
228 return $svg_handler->set_svg_meta_data( $data, $id );
229 }
230
231 /**
232 * handle_upload_prefilter
233 *
234 * @deprecated 3.5.0 Use `Elementor\Plugin::$instance->uploads_manager->handle_elementor_wp_media_upload()` instead.
235 *
236 * @param $file
237 *
238 * @return mixed
239 */
240 public function handle_upload_prefilter( $file ) {
241 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.5.0', 'Elementor\Plugin::$instance->uploads_manager->handle_elementor_wp_media_upload()' );
242
243 return Plugin::$instance->uploads_manager->handle_elementor_wp_media_upload( $file );
244 }
245 }
246