PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.4
Elementor Website Builder – more than just a page builder v3.0.4
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
← All changes | includes/managers/icons.php +89 -238 4.1.0-dev23.0.4 View file →
@@ -1,10 +1,8 @@
1 1 <?php
2 2 namespace Elementor;
3 3
4 -use Elementor\Core\Files\File_Types\Svg;
5 -use Elementor\Core\Page_Assets\Data_Managers\Font_Icon_Svg\Manager as Font_Icon_Svg_Data_Manager;
6 -use Elementor\Utils;
4 +use Elementor\Core\Files\Assets\Svg\Svg_Handler;
7 5
8 6 if ( ! defined( 'ABSPATH' ) ) {
9 7 exit; // Exit if accessed directly.
10 8 }
@@ -18,15 +16,8 @@
18 16 */
19 17 class Icons_Manager {
20 18
21 19 const NEEDS_UPDATE_OPTION = 'icon_manager_needs_update';
22 -
23 - const FONT_ICON_SVG_CLASS_NAME = 'e-font-icon-svg';
24 -
25 - const LOAD_FA4_SHIM_OPTION_KEY = 'elementor_load_fa4_shim';
26 -
27 - const ELEMENTOR_ICONS_VERSION = '5.49.0';
28 -
29 20 /**
30 21 * Tabs.
31 22 *
32 23 * Holds the list of all the tabs.
@@ -37,49 +28,14 @@
37 28 * @var array
38 29 */
39 30 private static $tabs;
40 31
41 - private static $data_manager;
42 -
43 32 private static function get_needs_upgrade_option() {
44 33 return get_option( 'elementor_' . self::NEEDS_UPDATE_OPTION, null );
45 34 }
46 35
47 36 /**
48 - * @param array $icon
49 - * @param array $attributes
50 - * @param string $tag
51 - * @return bool|mixed|string
52 - */
53 - public static function try_get_icon_html( $icon, $attributes = [], $tag = 'i' ) {
54 - if ( empty( $icon['library'] ) ) {
55 - return '';
56 - }
57 -
58 - return static::get_icon_html( $icon, $attributes, $tag );
59 - }
60 -
61 - /**
62 - * @param array $icon
63 - * @param array $attributes
64 - * @param string $tag
65 - * @return bool|mixed|string
66 - */
67 - private static function get_icon_html( array $icon, array $attributes, $tag ) {
68 - /**
69 - * When the library value is svg it means that it's a SVG media attachment uploaded by the user.
70 - * Otherwise, it's the name of the font family that the icon belongs to.
71 - */
72 - if ( 'svg' === $icon['library'] ) {
73 - $output = self::render_uploaded_svg_icon( $icon['value'] );
74 - } else {
75 - $output = self::render_font_icon( $icon, $attributes, $tag );
76 - }
77 - return $output;
78 - }
79 -
80 - /**
81 - * Register styles
37 + * register styles
82 38 *
83 39 * Used to register all icon types stylesheets so they could be enqueued later by widgets
84 40 */
85 41 public function register_styles() {
@@ -93,9 +49,9 @@
93 49 }
94 50 $dependencies = [];
95 51 if ( ! empty( $icon_type['enqueue'] ) ) {
96 52 foreach ( (array) $icon_type['enqueue'] as $font_css_url ) {
97 - if ( ! in_array( $font_css_url, array_keys( $shared_styles ), true ) ) {
53 + if ( ! in_array( $font_css_url, array_keys( $shared_styles ) ) ) {
98 54 $style_handle = 'elementor-icons-shared-' . count( $shared_styles );
99 55 wp_register_style(
100 56 $style_handle,
101 57 $font_css_url,
@@ -125,87 +81,61 @@
125 81 * @static
126 82 * @since 2.4.0
127 83 */
128 84 private static function init_tabs() {
129 - $initial_tabs = [
85 + self::$tabs = apply_filters( 'elementor/icons_manager/native', [
130 86 'fa-regular' => [
131 87 'name' => 'fa-regular',
132 - 'label' => esc_html__( 'Font Awesome - Regular', 'elementor' ),
88 + 'label' => __( 'Font Awesome - Regular', 'elementor' ),
133 89 'url' => self::get_fa_asset_url( 'regular' ),
134 90 'enqueue' => [ self::get_fa_asset_url( 'fontawesome' ) ],
135 91 'prefix' => 'fa-',
136 92 'displayPrefix' => 'far',
137 93 'labelIcon' => 'fab fa-font-awesome-alt',
138 - 'ver' => '5.15.3',
94 + 'ver' => '5.12.0',
139 95 'fetchJson' => self::get_fa_asset_url( 'regular', 'js', false ),
140 96 'native' => true,
141 97 ],
142 98 'fa-solid' => [
143 99 'name' => 'fa-solid',
144 - 'label' => esc_html__( 'Font Awesome - Solid', 'elementor' ),
100 + 'label' => __( 'Font Awesome - Solid', 'elementor' ),
145 101 'url' => self::get_fa_asset_url( 'solid' ),
146 102 'enqueue' => [ self::get_fa_asset_url( 'fontawesome' ) ],
147 103 'prefix' => 'fa-',
148 104 'displayPrefix' => 'fas',
149 105 'labelIcon' => 'fab fa-font-awesome',
150 - 'ver' => '5.15.3',
106 + 'ver' => '5.12.0',
151 107 'fetchJson' => self::get_fa_asset_url( 'solid', 'js', false ),
152 108 'native' => true,
153 109 ],
154 110 'fa-brands' => [
155 111 'name' => 'fa-brands',
156 - 'label' => esc_html__( 'Font Awesome - Brands', 'elementor' ),
112 + 'label' => __( 'Font Awesome - Brands', 'elementor' ),
157 113 'url' => self::get_fa_asset_url( 'brands' ),
158 114 'enqueue' => [ self::get_fa_asset_url( 'fontawesome' ) ],
159 115 'prefix' => 'fa-',
160 116 'displayPrefix' => 'fab',
161 117 'labelIcon' => 'fab fa-font-awesome-flag',
162 - 'ver' => '5.15.3',
118 + 'ver' => '5.12.0',
163 119 'fetchJson' => self::get_fa_asset_url( 'brands', 'js', false ),
164 120 'native' => true,
165 121 ],
166 - ];
167 -
168 - /**
169 - * Initial icon manager tabs.
170 - *
171 - * Filters the list of initial icon manager tabs.
172 - *
173 - * @param array $icon_manager_tabs Initial icon manager tabs.
174 - */
175 - $initial_tabs = apply_filters( 'elementor/icons_manager/native', $initial_tabs );
176 -
177 - self::$tabs = $initial_tabs;
122 + ] );
178 123 }
179 124
180 125 /**
181 126 * Get Icon Manager Tabs
182 - *
183 127 * @return array
184 128 */
185 129 public static function get_icon_manager_tabs() {
186 - if ( self::is_font_icon_inline_svg() && ! Plugin::$instance->editor->is_edit_mode() && ! Plugin::$instance->preview->is_preview_mode() ) {
187 - self::$tabs = [];
188 - } elseif ( ! self::$tabs ) {
130 + if ( ! self::$tabs ) {
189 131 self::init_tabs();
190 132 }
191 -
192 - $additional_tabs = [];
193 -
194 - /**
195 - * Additional icon manager tabs.
196 - *
197 - * Filters additional icon manager tabs.
198 - *
199 - * @param array $additional_tabs Additional icon manager tabs. Default is an empty array.
200 - */
201 - $additional_tabs = apply_filters( 'elementor/icons_manager/additional_tabs', $additional_tabs );
202 -
203 - return array_replace( self::$tabs, $additional_tabs );
133 + $additional_tabs = apply_filters( 'elementor/icons_manager/additional_tabs', [] );
134 + return array_merge( self::$tabs, $additional_tabs );
204 135 }
205 136
206 137 public static function enqueue_shim() {
207 - //phpcs:ignore WordPress.WP.EnqueuedResourceParameters.NotInFooter
208 138 wp_enqueue_script(
209 139 'font-awesome-4-shim',
210 140 self::get_fa_asset_url( 'v4-shims', 'js' ),
211 141 [],
@@ -230,15 +160,14 @@
230 160
231 161 private static function get_fa_asset_url( $filename, $ext_type = 'css', $add_suffix = true ) {
232 162 static $is_test_mode = null;
233 163 if ( null === $is_test_mode ) {
234 - $is_test_mode = Utils::is_script_debug() || Utils::is_elementor_tests();
164 + $is_test_mode = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined( 'ELEMENTOR_TESTS' ) && ELEMENTOR_TESTS;
235 165 }
236 166 $url = ELEMENTOR_ASSETS_URL . 'lib/font-awesome/' . $ext_type . '/' . $filename;
237 167 if ( ! $is_test_mode && $add_suffix ) {
238 168 $url .= '.min';
239 169 }
240 -
241 170 return $url . '.' . $ext_type;
242 171 }
243 172
244 173 public static function get_icon_manager_tabs_config() {
@@ -244,9 +173,9 @@
244 173 public static function get_icon_manager_tabs_config() {
245 174 $tabs = [
246 175 'all' => [
247 176 'name' => 'all',
248 - 'label' => esc_html__( 'All Icons', 'elementor' ),
177 + 'label' => __( 'All Icons', 'elementor' ),
249 178 'labelIcon' => 'eicon-filter',
250 179 'native' => true,
251 180 ],
252 181 ];
@@ -253,92 +182,32 @@
253 182
254 183 return array_values( array_merge( $tabs, self::get_icon_manager_tabs() ) );
255 184 }
256 185
257 - private static function is_font_icon_inline_svg() {
258 - return Plugin::$instance->experiments->is_feature_active( 'e_font_icon_svg' );
259 - }
260 -
261 - /**
262 - * @deprecated 3.8.0
263 - */
264 - public static function render_svg_symbols() {}
265 -
266 - public static function get_icon_svg_data( $icon ) {
267 - return self::$data_manager->get_font_icon_svg_data( $icon );
268 - }
269 -
270 - /**
271 - * Get font awesome svg.
272 - *
273 - * @param $icon array [ 'value' => string, 'library' => string ]
274 - *
275 - * @return bool|mixed|string
276 - */
277 - public static function get_font_icon_svg( $icon, $attributes = [] ) {
278 - // Load the SVG from the database.
279 - $icon_data = self::get_icon_svg_data( $icon );
280 -
281 - if ( ! $icon_data['path'] ) {
282 - return '';
283 - }
284 -
285 - if ( ! empty( $attributes['class'] ) && ! is_array( $attributes['class'] ) ) {
286 - $attributes['class'] = [ $attributes['class'] ];
287 - }
288 -
289 - $attributes['class'][] = self::FONT_ICON_SVG_CLASS_NAME;
290 - $attributes['class'][] = 'e-' . $icon_data['key'];
291 - $attributes['viewBox'] = '0 0 ' . $icon_data['width'] . ' ' . $icon_data['height'];
292 - $attributes['xmlns'] = 'http://www.w3.org/2000/svg';
293 -
294 - return (
295 - '<svg ' . Utils::render_html_attributes( $attributes ) . '>' .
296 - '<path d="' . esc_attr( $icon_data['path'] ) . '"></path>' .
297 - '</svg>'
298 - );
299 - }
300 -
301 - public static function render_uploaded_svg_icon( $value ) {
186 + private static function render_svg_icon( $value ) {
302 187 if ( ! isset( $value['id'] ) ) {
303 188 return '';
304 189 }
305 190
306 - return Svg::get_inline_svg( $value['id'] );
191 + return Svg_Handler::get_inline_svg( $value['id'] );
307 192 }
308 193
309 - public static function render_font_icon( $icon, $attributes = [], $tag = 'i' ) {
194 + private static function render_icon_html( $icon, $attributes = [], $tag = 'i' ) {
310 195 $icon_types = self::get_icon_manager_tabs();
311 -
312 196 if ( isset( $icon_types[ $icon['library'] ]['render_callback'] ) && is_callable( $icon_types[ $icon['library'] ]['render_callback'] ) ) {
313 197 return call_user_func_array( $icon_types[ $icon['library'] ]['render_callback'], [ $icon, $attributes, $tag ] );
314 198 }
315 199
316 - $content = '';
317 -
318 - $font_icon_svg_family = self::is_font_icon_inline_svg() ? Font_Icon_Svg_Data_Manager::get_font_family( $icon['library'] ) : '';
319 -
320 - if ( $font_icon_svg_family ) {
321 - $icon['font_family'] = $font_icon_svg_family;
322 -
323 - $content = self::get_font_icon_svg( $icon, $attributes );
324 -
325 - if ( $content ) {
326 - return $content;
327 - }
328 - }
329 -
330 - if ( ! $content ) {
331 - if ( empty( $attributes['class'] ) ) {
332 - $attributes['class'] = $icon['value'];
333 - } elseif ( is_array( $attributes['class'] ) ) {
334 - $attributes['class'][] = $icon['value'];
200 + if ( empty( $attributes['class'] ) ) {
201 + $attributes['class'] = $icon['value'];
202 + } else {
203 + if ( is_array( $attributes['class'] ) ) {
204 + $attributes['class'][] = $icon['value'];
335 205 } else {
336 206 $attributes['class'] .= ' ' . $icon['value'];
337 207 }
338 208 }
339 -
340 - return '<' . $tag . ' ' . Utils::render_html_attributes( $attributes ) . '>' . $content . '</' . $tag . '>';
209 + return '<' . $tag . ' ' . Utils::render_html_attributes( $attributes ) . '></' . $tag . '>';
341 210 }
342 211
343 212 /**
344 213 * Render Icon
@@ -343,13 +212,12 @@
343 212 /**
344 213 * Render Icon
345 214 *
346 215 * Used to render Icon for \Elementor\Controls_Manager::ICONS
216 + * @param array $icon Icon Type, Icon value
217 + * @param array $attributes Icon HTML Attributes
218 + * @param string $tag Icon HTML tag, defaults to <i>
347 219 *
348 - * @param array $icon Icon Type, Icon value.
349 - * @param array $attributes Icon HTML Attributes.
350 - * @param string $tag Icon HTML tag, defaults to <i>.
351 - *
352 220 * @return mixed|string
353 221 */
354 222 public static function render_icon( $icon, $attributes = [], $tag = 'i' ) {
355 223 if ( empty( $icon['library'] ) ) {
@@ -354,13 +222,18 @@
354 222 public static function render_icon( $icon, $attributes = [], $tag = 'i' ) {
355 223 if ( empty( $icon['library'] ) ) {
356 224 return false;
357 225 }
226 + $output = '';
227 + // handler SVG Icon
228 + if ( 'svg' === $icon['library'] ) {
229 + $output = self::render_svg_icon( $icon['value'] );
230 + } else {
231 + $output = self::render_icon_html( $icon, $attributes, $tag );
232 + }
358 233
359 - $output = static::get_icon_html( $icon, $attributes, $tag );
234 + echo $output;
360 235
361 - Utils::print_unescaped_internal_string( $output );
362 -
363 236 return true;
364 237 }
365 238
366 239 /**
@@ -365,9 +238,9 @@
365 238
366 239 /**
367 240 * Font Awesome 4 to font Awesome 5 Value Migration
368 241 *
369 - * Used to convert string value of Icon control to array value of Icons control
242 + * used to convert string value of Icon control to array value of Icons control
370 243 * ex: 'fa fa-star' => [ 'value' => 'fas fa-star', 'library' => 'fa-solid' ]
371 244 *
372 245 * @param $value
373 246 *
@@ -381,9 +254,9 @@
381 254 'library' => '',
382 255 ];
383 256 }
384 257 if ( false === $migration_dictionary ) {
385 - $migration_dictionary = json_decode( Utils::file_get_contents( ELEMENTOR_ASSETS_PATH . 'lib/font-awesome/migration/mapping.js' ), true );
258 + $migration_dictionary = json_decode( file_get_contents( ELEMENTOR_ASSETS_PATH . 'lib/font-awesome/migration/mapping.js' ), true );
386 259 }
387 260 if ( isset( $migration_dictionary[ $value ] ) ) {
388 261 return $migration_dictionary[ $value ];
389 262 }
@@ -394,15 +267,14 @@
394 267 ];
395 268 }
396 269
397 270 /**
398 - * On_import_migration
271 + * on_import_migration
272 + * @param array $element settings array
273 + * @param string $old_control old control id
274 + * @param string $new_control new control id
275 + * @param bool $remove_old boolean weather to remove old control or not
399 276 *
400 - * @param array $element settings array.
401 - * @param string $old_control old control id.
402 - * @param string $new_control new control id.
403 - * @param bool $remove_old boolean whether to remove old control or not.
404 - *
405 277 * @return array
406 278 */
407 279 public static function on_import_migration( array $element, $old_control = '', $new_control = '', $remove_old = false ) {
408 280
@@ -422,9 +294,9 @@
422 294 }
423 295
424 296 $element['settings'][ $new_control ] = $new_value;
425 297
426 - // remove old value
298 + //remove old value
427 299 if ( $remove_old ) {
428 300 unset( $element['settings'][ $old_control ] );
429 301 }
430 302
@@ -430,8 +302,12 @@
430 302
431 303 return $element;
432 304 }
433 305
306 + /**
307 + * is_migration_allowed
308 + * @return bool
309 + */
434 310 public static function is_migration_allowed() {
435 311 static $migration_allowed = false;
436 312 if ( false === $migration_allowed ) {
437 313 $migration_allowed = null === self::get_needs_upgrade_option();
@@ -436,13 +312,9 @@
436 312 if ( false === $migration_allowed ) {
437 313 $migration_allowed = null === self::get_needs_upgrade_option();
438 314
439 315 /**
440 - * Is icon migration allowed.
441 - *
442 - * Filters whether the icons migration allowed.
443 - *
444 - * @param bool $migration_allowed Is icon migration is allowed.
316 + * allowed to filter migration allowed
445 317 */
446 318 $migration_allowed = apply_filters( 'elementor/icons_manager/migration_allowed', $migration_allowed );
447 319 }
448 320 return $migration_allowed;
@@ -450,10 +322,9 @@
450 322
451 323 /**
452 324 * Register_Admin Settings
453 325 *
454 - * Adds Font Awesome migration / update admin settings
455 - *
326 + * adds Font Awesome migration / update admin settings
456 327 * @param Settings $settings
457 328 */
458 329 public function register_admin_settings( Settings $settings ) {
459 330 $settings->add_field(
@@ -460,17 +331,17 @@
460 331 Settings::TAB_ADVANCED,
461 332 Settings::TAB_ADVANCED,
462 333 'load_fa4_shim',
463 334 [
464 - 'label' => esc_html__( 'Load Font Awesome 4 Support', 'elementor' ),
335 + 'label' => __( 'Load Font Awesome 4 Support', 'elementor' ),
465 336 'field_args' => [
466 337 'type' => 'select',
467 - 'std' => '',
338 + 'std' => 1,
468 339 'options' => [
469 - '' => esc_html__( 'No', 'elementor' ),
470 - 'yes' => esc_html__( 'Yes', 'elementor' ),
340 + '' => __( 'No', 'elementor' ),
341 + 'yes' => __( 'Yes', 'elementor' ),
471 342 ],
472 - 'desc' => esc_html__( 'Font Awesome 4 support script (shim.js) is a script that makes sure all previously selected Font Awesome 4 icons are displayed correctly while using Font Awesome 5 library.', 'elementor' ),
343 + 'desc' => __( 'Font Awesome 4 support script (shim.js) is a script that makes sure all previously selected Font Awesome 4 icons are displayed correctly while using Font Awesome 5 library.', 'elementor' ),
473 344 ],
474 345 ]
475 346 );
476 347 }
@@ -475,35 +346,34 @@
475 346 );
476 347 }
477 348
478 349 public function register_admin_tools_settings( Tools $settings ) {
479 - $settings->add_tab( 'fontawesome4_migration', [ 'label' => esc_html__( 'Font Awesome Upgrade', 'elementor' ) ] );
350 + $settings->add_tab( 'fontawesome4_migration', [ 'label' => __( 'Font Awesome Upgrade', 'elementor' ) ] );
480 351
481 352 $settings->add_section( 'fontawesome4_migration', 'fontawesome4_migration', [
482 353 'callback' => function() {
483 354 echo '<h2>' . esc_html__( 'Font Awesome Upgrade', 'elementor' ) . '</h2>';
484 - echo '<p>' . // PHPCS - Plain Text
485 - esc_html__( 'Access 1,500+ amazing Font Awesome 5 icons and enjoy faster performance and design flexibility.', 'elementor' ) . '<br>' . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
486 - esc_html__( 'By upgrading, whenever you edit a page containing a Font Awesome 4 icon, Elementor will convert it to the new Font Awesome 5 icon.', 'elementor' ) . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
355 + echo '<p>' .
356 + __( 'Access 1,500+ amazing Font Awesome 5 icons and enjoy faster performance and design flexibility.', 'elementor' ) . '<br>' .
357 + __( 'By upgrading, whenever you edit a page containing a Font Awesome 4 icon, Elementor will convert it to the new Font Awesome 5 icon.', 'elementor' ) .
487 358 '</p><p><strong>' .
488 - esc_html__( 'Please note that the upgrade process may cause some of the previously used Font Awesome 4 icons to look a bit different due to minor design changes made by Font Awesome.', 'elementor' ) . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
359 + __( 'Please note that the upgrade process may cause some of the previously used Font Awesome 4 icons to look a bit different due to minor design changes made by Font Awesome.', 'elementor' ) .
489 360 '</strong></p><p>' .
490 - esc_html__( 'The upgrade process includes a database update', 'elementor' ) . ' - ' . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
491 - esc_html__( 'We highly recommend backing up your database before performing this upgrade.', 'elementor' ) . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
361 + __( 'The upgrade process includes a database update', 'elementor' ) . ' - ' .
362 + __( 'We highly recommend backing up your database before performing this upgrade.', 'elementor' ) .
492 363 '</p>' .
493 - esc_html__( 'This action is not reversible and cannot be undone by rolling back to previous versions.', 'elementor' ) . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
364 + __( 'This action is not reversible and cannot be undone by rolling back to previous versions.', 'elementor' ) .
494 365 '</p>';
495 366 },
496 367 'fields' => [
497 368 [
498 - 'label' => esc_html__( 'Font Awesome Upgrade', 'elementor' ),
369 + 'label' => __( 'Font Awesome Upgrade', 'elementor' ),
499 370 'field_args' => [
500 371 'type' => 'raw_html',
501 - 'html' => sprintf( '<span data-action="%s" data-_nonce="%s" data-redirect-url="%s" class="button" id="elementor_upgrade_fa_button">%s</span>',
372 + 'html' => sprintf( '<span data-action="%s" data-_nonce="%s" class="button" id="elementor_upgrade_fa_button">%s</span>',
502 373 self::NEEDS_UPDATE_OPTION . '_upgrade',
503 374 wp_create_nonce( self::NEEDS_UPDATE_OPTION ),
504 - esc_url( $this->get_upgrade_redirect_url() ),
505 - esc_html__( 'Upgrade To Font Awesome 5', 'elementor' )
375 + __( 'Upgrade To Font Awesome 5', 'elementor' )
506 376 ),
507 377 ],
508 378 ],
509 379 ],
@@ -510,51 +380,20 @@
510 380 ] );
511 381 }
512 382
513 383 /**
514 - * Get redirect URL when upgrading font awesome.
515 - *
516 - * @return string
517 - */
518 - public function get_upgrade_redirect_url() {
519 -
520 - if ( ! wp_verify_nonce( Utils::get_super_global_value( $_GET, '_wpnonce' ), 'tools-page-from-editor' ) ) {
521 - return '';
522 - }
523 -
524 - $document_id = ! empty( $_GET['redirect_to_document'] ) ? absint( $_GET['redirect_to_document'] ) : null;
525 -
526 - if ( ! $document_id ) {
527 - return '';
528 - }
529 -
530 - $document = Plugin::$instance->documents->get( $document_id );
531 -
532 - if ( ! $document ) {
533 - return '';
534 - }
535 -
536 - return $document->get_edit_url();
537 - }
538 -
539 - /**
540 384 * Ajax Upgrade to FontAwesome 5
541 385 */
542 386 public function ajax_upgrade_to_fa5() {
543 387 check_ajax_referer( self::NEEDS_UPDATE_OPTION, '_nonce' );
544 388
545 - if ( ! current_user_can( 'manage_options' ) ) {
546 - wp_send_json_error( 'Permission denied' );
547 - }
548 -
549 389 delete_option( 'elementor_' . self::NEEDS_UPDATE_OPTION );
550 390
551 - wp_send_json_success( [ 'message' => esc_html__( 'Hurray! The upgrade process to Font Awesome 5 was completed successfully.', 'elementor' ) ] );
391 + wp_send_json_success( [ 'message' => '<p>' . __( 'Hurray! The upgrade process to Font Awesome 5 was completed successfully.', 'elementor' ) . '</p>' ] );
552 392 }
553 393
554 394 /**
555 395 * Add Update Needed Flag
556 - *
557 396 * @param array $settings
558 397 *
559 398 * @return array;
560 399 */
@@ -567,24 +406,37 @@
567 406 if ( ! self::is_migration_allowed() ) {
568 407 wp_enqueue_style( 'font-awesome' );
569 408 } else {
570 409 $current_filter = current_filter();
571 - $load_shim = get_option( self::LOAD_FA4_SHIM_OPTION_KEY, false );
410 + $load_shim = get_option( 'elementor_load_fa4_shim', false );
572 411 if ( 'elementor/editor/after_enqueue_styles' === $current_filter ) {
573 412 self::enqueue_shim();
574 - } elseif ( 'yes' === $load_shim ) {
413 + } else if ( 'yes' === $load_shim ) {
575 414 self::enqueue_shim();
576 415 }
577 416 }
578 417 }
579 418
419 + public function add_admin_strings( $settings ) {
420 + $settings['i18n']['confirm_fa_migration_admin_modal_body'] = __( 'I understand that by upgrading to Font Awesome 5,', 'elementor' ) . '<br>' . __( 'I acknowledge that some changes may affect my website and that this action cannot be undone.', 'elementor' );
421 + $settings['i18n']['confirm_fa_migration_admin_modal_head'] = __( 'Font Awesome 5 Migration', 'elementor' );
422 + return $settings;
423 + }
424 +
580 425 /**
581 - * @deprecated 3.1.0
426 + * @since 3.0.0
427 + * @deprecated 3.0.0
582 428 */
583 - public function add_admin_strings() {
584 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0' );
429 + public function register_ajax_actions() {
430 + _deprecated_function( __METHOD__, '3.0.0' );
431 + }
585 432
586 - return [];
433 + /**
434 + * @since 3.0.0.
435 + * @deprecated 3.0.0
436 + */
437 + public function ajax_enable_svg_uploads() {
438 + _deprecated_function( __METHOD__, '3.0.0' );
587 439 }
588 440
589 441 /**
590 442 * Icons Manager constructor
@@ -592,15 +444,14 @@
592 444 public function __construct() {
593 445 if ( is_admin() ) {
594 446 // @todo: remove once we deprecate fa4
595 447 add_action( 'elementor/admin/after_create_settings/' . Settings::PAGE_ID, [ $this, 'register_admin_settings' ], 100 );
448 + add_action( 'elementor/admin/localize_settings', [ $this, 'add_admin_strings' ] );
596 449 }
597 450
598 - if ( self::is_font_icon_inline_svg() ) {
599 - self::$data_manager = new Font_Icon_Svg_Data_Manager();
600 - }
451 + add_action( 'elementor/editor/after_enqueue_styles', [ $this, 'enqueue_fontawesome_css' ] );
452 + add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'enqueue_fontawesome_css' ] );
601 453
602 - add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'enqueue_fontawesome_css' ] );
603 454 add_action( 'elementor/frontend/after_register_styles', [ $this, 'register_styles' ] );
604 455
605 456 if ( ! self::is_migration_allowed() ) {
606 457 add_filter( 'elementor/editor/localize_settings', [ $this, 'add_update_needed_flag' ] );