| @@ -1,10 +1,10 @@ | ||
| 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\Page_Assets\Data_Managers\Font_Icon_Svg as Font_Icon_Svg_Data_Manager; | |
| 5 | +use Elementor\Core\Page_Assets\Managers\Font_Icon_Svg\Manager as Font_Icon_Svg_Manager; | |
| 6 | +use Elementor\Core\Files\Assets\Svg\Svg_Handler; | |
| 7 | 7 | |
| 8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | 9 | exit; // Exit if accessed directly. |
| 10 | 10 | } |
| @@ -22,11 +22,8 @@ | ||
| 22 | 22 | |
| 23 | 23 | const FONT_ICON_SVG_CLASS_NAME = 'e-font-icon-svg'; |
| 24 | 24 | |
| 25 | 25 | const LOAD_FA4_SHIM_OPTION_KEY = 'elementor_load_fa4_shim'; |
| 26 | - | |
| 27 | - const ELEMENTOR_ICONS_VERSION = '5.53.0'; | |
| 28 | - | |
| 29 | 26 | /** |
| 30 | 27 | * Tabs. |
| 31 | 28 | * |
| 32 | 29 | * Holds the list of all the tabs. |
| @@ -39,47 +36,16 @@ | ||
| 39 | 36 | private static $tabs; |
| 40 | 37 | |
| 41 | 38 | private static $data_manager; |
| 42 | 39 | |
| 40 | + private static $font_icon_svg_symbols = []; | |
| 41 | + | |
| 43 | 42 | private static function get_needs_upgrade_option() { |
| 44 | 43 | return get_option( 'elementor_' . self::NEEDS_UPDATE_OPTION, null ); |
| 45 | 44 | } |
| 46 | 45 | |
| 47 | 46 | /** |
| 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 | |
| 47 | + * register styles | |
| 82 | 48 | * |
| 83 | 49 | * Used to register all icon types stylesheets so they could be enqueued later by widgets |
| 84 | 50 | */ |
| 85 | 51 | public function register_styles() { |
| @@ -93,9 +59,9 @@ | ||
| 93 | 59 | } |
| 94 | 60 | $dependencies = []; |
| 95 | 61 | if ( ! empty( $icon_type['enqueue'] ) ) { |
| 96 | 62 | foreach ( (array) $icon_type['enqueue'] as $font_css_url ) { |
| 97 | - if ( ! in_array( $font_css_url, array_keys( $shared_styles ), true ) ) { | |
| 63 | + if ( ! in_array( $font_css_url, array_keys( $shared_styles ) ) ) { | |
| 98 | 64 | $style_handle = 'elementor-icons-shared-' . count( $shared_styles ); |
| 99 | 65 | wp_register_style( |
| 100 | 66 | $style_handle, |
| 101 | 67 | $font_css_url, |
| @@ -125,9 +91,9 @@ | ||
| 125 | 91 | * @static |
| 126 | 92 | * @since 2.4.0 |
| 127 | 93 | */ |
| 128 | 94 | private static function init_tabs() { |
| 129 | - $initial_tabs = [ | |
| 95 | + self::$tabs = apply_filters( 'elementor/icons_manager/native', [ | |
| 130 | 96 | 'fa-regular' => [ |
| 131 | 97 | 'name' => 'fa-regular', |
| 132 | 98 | 'label' => esc_html__( 'Font Awesome - Regular', 'elementor' ), |
| 133 | 99 | 'url' => self::get_fa_asset_url( 'regular' ), |
| @@ -162,25 +128,13 @@ | ||
| 162 | 128 | 'ver' => '5.15.3', |
| 163 | 129 | 'fetchJson' => self::get_fa_asset_url( 'brands', 'js', false ), |
| 164 | 130 | 'native' => true, |
| 165 | 131 | ], |
| 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; | |
| 132 | + ] ); | |
| 178 | 133 | } |
| 179 | 134 | |
| 180 | 135 | /** |
| 181 | 136 | * Get Icon Manager Tabs |
| 182 | - * | |
| 183 | 137 | * @return array |
| 184 | 138 | */ |
| 185 | 139 | public static function get_icon_manager_tabs() { |
| 186 | 140 | if ( self::is_font_icon_inline_svg() && ! Plugin::$instance->editor->is_edit_mode() && ! Plugin::$instance->preview->is_preview_mode() ) { |
| @@ -188,24 +142,14 @@ | ||
| 188 | 142 | } elseif ( ! self::$tabs ) { |
| 189 | 143 | self::init_tabs(); |
| 190 | 144 | } |
| 191 | 145 | |
| 192 | - $additional_tabs = []; | |
| 146 | + $additional_tabs = apply_filters( 'elementor/icons_manager/additional_tabs', [] ); | |
| 193 | 147 | |
| 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 ); | |
| 148 | + return array_merge( self::$tabs, $additional_tabs ); | |
| 204 | 149 | } |
| 205 | 150 | |
| 206 | 151 | public static function enqueue_shim() { |
| 207 | - //phpcs:ignore WordPress.WP.EnqueuedResourceParameters.NotInFooter | |
| 208 | 152 | wp_enqueue_script( |
| 209 | 153 | 'font-awesome-4-shim', |
| 210 | 154 | self::get_fa_asset_url( 'v4-shims', 'js' ), |
| 211 | 155 | [], |
| @@ -230,9 +174,9 @@ | ||
| 230 | 174 | |
| 231 | 175 | private static function get_fa_asset_url( $filename, $ext_type = 'css', $add_suffix = true ) { |
| 232 | 176 | static $is_test_mode = null; |
| 233 | 177 | if ( null === $is_test_mode ) { |
| 234 | - $is_test_mode = Utils::is_script_debug() || Utils::is_elementor_tests(); | |
| 178 | + $is_test_mode = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined( 'ELEMENTOR_TESTS' ) && ELEMENTOR_TESTS; | |
| 235 | 179 | } |
| 236 | 180 | $url = ELEMENTOR_ASSETS_URL . 'lib/font-awesome/' . $ext_type . '/' . $filename; |
| 237 | 181 | if ( ! $is_test_mode && $add_suffix ) { |
| 238 | 182 | $url .= '.min'; |
| @@ -253,24 +197,49 @@ | ||
| 253 | 197 | |
| 254 | 198 | return array_values( array_merge( $tabs, self::get_icon_manager_tabs() ) ); |
| 255 | 199 | } |
| 256 | 200 | |
| 201 | + /** | |
| 202 | + * is_font_awesome_inline | |
| 203 | + * | |
| 204 | + * @return bool | |
| 205 | + */ | |
| 257 | 206 | private static function is_font_icon_inline_svg() { |
| 258 | 207 | return Plugin::$instance->experiments->is_feature_active( 'e_font_icon_svg' ); |
| 259 | 208 | } |
| 260 | 209 | |
| 261 | 210 | /** |
| 262 | - * @deprecated 3.8.0 | |
| 211 | + * render_svg_symbols | |
| 212 | + * | |
| 263 | 213 | */ |
| 264 | - public static function render_svg_symbols() {} | |
| 214 | + public static function render_svg_symbols() { | |
| 215 | + if ( ! self::$font_icon_svg_symbols ) { | |
| 216 | + return; | |
| 217 | + } | |
| 265 | 218 | |
| 219 | + $svg = '<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">'; | |
| 220 | + | |
| 221 | + foreach ( self::$font_icon_svg_symbols as $symbol_id => $symbol ) { | |
| 222 | + $svg .= '<symbol id="' . $symbol_id . '" viewBox="0 0 ' . esc_attr( $symbol['width'] ) . ' ' . esc_attr( $symbol['height'] ) . '">'; | |
| 223 | + $svg .= '<path d="' . esc_attr( $symbol['path'] ) . '"></path>'; | |
| 224 | + $svg .= '</symbol>'; | |
| 225 | + } | |
| 226 | + | |
| 227 | + $svg .= '</svg>'; | |
| 228 | + | |
| 229 | + Utils::print_unescaped_internal_string( $svg ); | |
| 230 | + } | |
| 231 | + | |
| 266 | 232 | public static function get_icon_svg_data( $icon ) { |
| 267 | - return self::$data_manager->get_font_icon_svg_data( $icon ); | |
| 233 | + $font_family_manager = Font_Icon_Svg_Manager::get_font_family_manager( $icon['font_family'] ); | |
| 234 | + | |
| 235 | + $config = $font_family_manager::get_config( $icon ); | |
| 236 | + | |
| 237 | + return self::$data_manager->get_asset_data( $config ); | |
| 268 | 238 | } |
| 269 | 239 | |
| 270 | 240 | /** |
| 271 | 241 | * Get font awesome svg. |
| 272 | - * | |
| 273 | 242 | * @param $icon array [ 'value' => string, 'library' => string ] |
| 274 | 243 | * |
| 275 | 244 | * @return bool|mixed|string |
| 276 | 245 | */ |
| @@ -281,22 +250,31 @@ | ||
| 281 | 250 | if ( ! $icon_data['path'] ) { |
| 282 | 251 | return ''; |
| 283 | 252 | } |
| 284 | 253 | |
| 254 | + // Add the icon data to the symbols array for later use in page rendering process. | |
| 255 | + if ( ! in_array( $icon_data['key'], self::$font_icon_svg_symbols, true ) ) { | |
| 256 | + self::$font_icon_svg_symbols[ $icon_data['key'] ] = $icon_data; | |
| 257 | + } | |
| 258 | + | |
| 285 | 259 | if ( ! empty( $attributes['class'] ) && ! is_array( $attributes['class'] ) ) { |
| 286 | 260 | $attributes['class'] = [ $attributes['class'] ]; |
| 287 | 261 | } |
| 288 | 262 | |
| 289 | 263 | $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 | 264 | |
| 294 | - return ( | |
| 295 | - '<svg ' . Utils::render_html_attributes( $attributes ) . '>' . | |
| 296 | - '<path d="' . esc_attr( $icon_data['path'] ) . '"></path>' . | |
| 297 | - '</svg>' | |
| 298 | - ); | |
| 265 | + /** | |
| 266 | + * If in edit mode inline the full svg, otherwise use the symbol. | |
| 267 | + * Will be displayed only after page update or widget "blur". | |
| 268 | + */ | |
| 269 | + if ( Plugin::$instance->editor->is_edit_mode() ) { | |
| 270 | + return '<svg xmlns="http://www.w3.org/2000/svg" ' . Utils::render_html_attributes( $attributes ) . ' | |
| 271 | + viewBox="0 0 ' . esc_attr( $icon_data['width'] ) . ' ' . esc_attr( $icon_data['height'] ) . '"> | |
| 272 | + <path d="' . esc_attr( $icon_data['path'] ) . '"></path> | |
| 273 | + </svg>'; | |
| 274 | + } | |
| 275 | + | |
| 276 | + return '<svg ' . Utils::render_html_attributes( $attributes ) . '><use xlink:href="#' . esc_attr( $icon_data['key'] ) . '" /></svg>'; | |
| 299 | 277 | } |
| 300 | 278 | |
| 301 | 279 | public static function render_uploaded_svg_icon( $value ) { |
| 302 | 280 | if ( ! isset( $value['id'] ) ) { |
| @@ -302,9 +280,9 @@ | ||
| 302 | 280 | if ( ! isset( $value['id'] ) ) { |
| 303 | 281 | return ''; |
| 304 | 282 | } |
| 305 | 283 | |
| 306 | - return Svg::get_inline_svg( $value['id'] ); | |
| 284 | + return Svg_Handler::get_inline_svg( $value['id'] ); | |
| 307 | 285 | } |
| 308 | 286 | |
| 309 | 287 | public static function render_font_icon( $icon, $attributes = [], $tag = 'i' ) { |
| 310 | 288 | $icon_types = self::get_icon_manager_tabs(); |
| @@ -314,9 +292,9 @@ | ||
| 314 | 292 | } |
| 315 | 293 | |
| 316 | 294 | $content = ''; |
| 317 | 295 | |
| 318 | - $font_icon_svg_family = self::is_font_icon_inline_svg() ? Font_Icon_Svg_Data_Manager::get_font_family( $icon['library'] ) : ''; | |
| 296 | + $font_icon_svg_family = self::is_font_icon_inline_svg() ? Font_Icon_Svg_Manager::get_font_family( $icon['library'] ) : ''; | |
| 319 | 297 | |
| 320 | 298 | if ( $font_icon_svg_family ) { |
| 321 | 299 | $icon['font_family'] = $font_icon_svg_family; |
| 322 | 300 | |
| @@ -329,12 +307,14 @@ | ||
| 329 | 307 | |
| 330 | 308 | if ( ! $content ) { |
| 331 | 309 | if ( empty( $attributes['class'] ) ) { |
| 332 | 310 | $attributes['class'] = $icon['value']; |
| 333 | - } elseif ( is_array( $attributes['class'] ) ) { | |
| 311 | + } else { | |
| 312 | + if ( is_array( $attributes['class'] ) ) { | |
| 334 | 313 | $attributes['class'][] = $icon['value']; |
| 335 | - } else { | |
| 336 | - $attributes['class'] .= ' ' . $icon['value']; | |
| 314 | + } else { | |
| 315 | + $attributes['class'] .= ' ' . $icon['value']; | |
| 316 | + } | |
| 337 | 317 | } |
| 338 | 318 | } |
| 339 | 319 | |
| 340 | 320 | return '<' . $tag . ' ' . Utils::render_html_attributes( $attributes ) . '>' . $content . '</' . $tag . '>'; |
| @@ -343,13 +323,12 @@ | ||
| 343 | 323 | /** |
| 344 | 324 | * Render Icon |
| 345 | 325 | * |
| 346 | 326 | * Used to render Icon for \Elementor\Controls_Manager::ICONS |
| 327 | + * @param array $icon Icon Type, Icon value | |
| 328 | + * @param array $attributes Icon HTML Attributes | |
| 329 | + * @param string $tag Icon HTML tag, defaults to <i> | |
| 347 | 330 | * |
| 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 | 331 | * @return mixed|string |
| 353 | 332 | */ |
| 354 | 333 | public static function render_icon( $icon, $attributes = [], $tag = 'i' ) { |
| 355 | 334 | if ( empty( $icon['library'] ) ) { |
| @@ -355,10 +334,20 @@ | ||
| 355 | 334 | if ( empty( $icon['library'] ) ) { |
| 356 | 335 | return false; |
| 357 | 336 | } |
| 358 | 337 | |
| 359 | - $output = static::get_icon_html( $icon, $attributes, $tag ); | |
| 338 | + $output = ''; | |
| 360 | 339 | |
| 340 | + /** | |
| 341 | + * When the library value is svg it means that it's a SVG media attachment uploaded by the user. | |
| 342 | + * Otherwise, it's the name of the font family that the icon belongs to. | |
| 343 | + */ | |
| 344 | + if ( 'svg' === $icon['library'] ) { | |
| 345 | + $output = self::render_uploaded_svg_icon( $icon['value'] ); | |
| 346 | + } else { | |
| 347 | + $output = self::render_font_icon( $icon, $attributes, $tag ); | |
| 348 | + } | |
| 349 | + | |
| 361 | 350 | Utils::print_unescaped_internal_string( $output ); |
| 362 | 351 | |
| 363 | 352 | return true; |
| 364 | 353 | } |
| @@ -365,9 +354,9 @@ | ||
| 365 | 354 | |
| 366 | 355 | /** |
| 367 | 356 | * Font Awesome 4 to font Awesome 5 Value Migration |
| 368 | 357 | * |
| 369 | - * Used to convert string value of Icon control to array value of Icons control | |
| 358 | + * used to convert string value of Icon control to array value of Icons control | |
| 370 | 359 | * ex: 'fa fa-star' => [ 'value' => 'fas fa-star', 'library' => 'fa-solid' ] |
| 371 | 360 | * |
| 372 | 361 | * @param $value |
| 373 | 362 | * |
| @@ -381,9 +370,9 @@ | ||
| 381 | 370 | 'library' => '', |
| 382 | 371 | ]; |
| 383 | 372 | } |
| 384 | 373 | if ( false === $migration_dictionary ) { |
| 385 | - $migration_dictionary = json_decode( Utils::file_get_contents( ELEMENTOR_ASSETS_PATH . 'lib/font-awesome/migration/mapping.js' ), true ); | |
| 374 | + $migration_dictionary = json_decode( file_get_contents( ELEMENTOR_ASSETS_PATH . 'lib/font-awesome/migration/mapping.js' ), true ); | |
| 386 | 375 | } |
| 387 | 376 | if ( isset( $migration_dictionary[ $value ] ) ) { |
| 388 | 377 | return $migration_dictionary[ $value ]; |
| 389 | 378 | } |
| @@ -394,15 +383,14 @@ | ||
| 394 | 383 | ]; |
| 395 | 384 | } |
| 396 | 385 | |
| 397 | 386 | /** |
| 398 | - * On_import_migration | |
| 387 | + * on_import_migration | |
| 388 | + * @param array $element settings array | |
| 389 | + * @param string $old_control old control id | |
| 390 | + * @param string $new_control new control id | |
| 391 | + * @param bool $remove_old boolean weather to remove old control or not | |
| 399 | 392 | * |
| 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 | 393 | * @return array |
| 406 | 394 | */ |
| 407 | 395 | public static function on_import_migration( array $element, $old_control = '', $new_control = '', $remove_old = false ) { |
| 408 | 396 | |
| @@ -422,9 +410,9 @@ | ||
| 422 | 410 | } |
| 423 | 411 | |
| 424 | 412 | $element['settings'][ $new_control ] = $new_value; |
| 425 | 413 | |
| 426 | - // remove old value | |
| 414 | + //remove old value | |
| 427 | 415 | if ( $remove_old ) { |
| 428 | 416 | unset( $element['settings'][ $old_control ] ); |
| 429 | 417 | } |
| 430 | 418 | |
| @@ -430,8 +418,12 @@ | ||
| 430 | 418 | |
| 431 | 419 | return $element; |
| 432 | 420 | } |
| 433 | 421 | |
| 422 | + /** | |
| 423 | + * is_migration_allowed | |
| 424 | + * @return bool | |
| 425 | + */ | |
| 434 | 426 | public static function is_migration_allowed() { |
| 435 | 427 | static $migration_allowed = false; |
| 436 | 428 | if ( false === $migration_allowed ) { |
| 437 | 429 | $migration_allowed = null === self::get_needs_upgrade_option(); |
| @@ -436,13 +428,9 @@ | ||
| 436 | 428 | if ( false === $migration_allowed ) { |
| 437 | 429 | $migration_allowed = null === self::get_needs_upgrade_option(); |
| 438 | 430 | |
| 439 | 431 | /** |
| 440 | - * Is icon migration allowed. | |
| 441 | - * | |
| 442 | - * Filters whether the icons migration allowed. | |
| 443 | - * | |
| 444 | - * @param bool $migration_allowed Is icon migration is allowed. | |
| 432 | + * allowed to filter migration allowed | |
| 445 | 433 | */ |
| 446 | 434 | $migration_allowed = apply_filters( 'elementor/icons_manager/migration_allowed', $migration_allowed ); |
| 447 | 435 | } |
| 448 | 436 | return $migration_allowed; |
| @@ -450,10 +438,9 @@ | ||
| 450 | 438 | |
| 451 | 439 | /** |
| 452 | 440 | * Register_Admin Settings |
| 453 | 441 | * |
| 454 | - * Adds Font Awesome migration / update admin settings | |
| 455 | - * | |
| 442 | + * adds Font Awesome migration / update admin settings | |
| 456 | 443 | * @param Settings $settings |
| 457 | 444 | */ |
| 458 | 445 | public function register_admin_settings( Settings $settings ) { |
| 459 | 446 | $settings->add_field( |
| @@ -463,9 +450,9 @@ | ||
| 463 | 450 | [ |
| 464 | 451 | 'label' => esc_html__( 'Load Font Awesome 4 Support', 'elementor' ), |
| 465 | 452 | 'field_args' => [ |
| 466 | 453 | 'type' => 'select', |
| 467 | - 'std' => '', | |
| 454 | + 'std' => 'yes', | |
| 468 | 455 | 'options' => [ |
| 469 | 456 | '' => esc_html__( 'No', 'elementor' ), |
| 470 | 457 | 'yes' => esc_html__( 'Yes', 'elementor' ), |
| 471 | 458 | ], |
| @@ -481,29 +468,28 @@ | ||
| 481 | 468 | $settings->add_section( 'fontawesome4_migration', 'fontawesome4_migration', [ |
| 482 | 469 | 'callback' => function() { |
| 483 | 470 | echo '<h2>' . esc_html__( 'Font Awesome Upgrade', 'elementor' ) . '</h2>'; |
| 484 | 471 | 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 | |
| 472 | + __( 'Access 1,500+ amazing Font Awesome 5 icons and enjoy faster performance and design flexibility.', 'elementor' ) . '<br>' . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 473 | + __( '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 | |
| 487 | 474 | '</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 | |
| 475 | + __( '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 | |
| 489 | 476 | '</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 | |
| 477 | + __( 'The upgrade process includes a database update', 'elementor' ) . ' - ' . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 478 | + __( 'We highly recommend backing up your database before performing this upgrade.', 'elementor' ) . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 492 | 479 | '</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 | |
| 480 | + __( 'This action is not reversible and cannot be undone by rolling back to previous versions.', 'elementor' ) . // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 494 | 481 | '</p>'; |
| 495 | 482 | }, |
| 496 | 483 | 'fields' => [ |
| 497 | 484 | [ |
| 498 | - 'label' => esc_html__( 'Font Awesome Upgrade', 'elementor' ), | |
| 485 | + 'label' => esc_html__( 'Font Awesome Upgrade', 'elementor' ), | |
| 499 | 486 | 'field_args' => [ |
| 500 | 487 | '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>', | |
| 488 | + 'html' => sprintf( '<span data-action="%s" data-_nonce="%s" class="button" id="elementor_upgrade_fa_button">%s</span>', | |
| 502 | 489 | self::NEEDS_UPDATE_OPTION . '_upgrade', |
| 503 | 490 | wp_create_nonce( self::NEEDS_UPDATE_OPTION ), |
| 504 | - esc_url( $this->get_upgrade_redirect_url() ), | |
| 505 | - esc_html__( 'Upgrade To Font Awesome 5', 'elementor' ) | |
| 491 | + __( 'Upgrade To Font Awesome 5', 'elementor' ) | |
| 506 | 492 | ), |
| 507 | 493 | ], |
| 508 | 494 | ], |
| 509 | 495 | ], |
| @@ -510,51 +496,20 @@ | ||
| 510 | 496 | ] ); |
| 511 | 497 | } |
| 512 | 498 | |
| 513 | 499 | /** |
| 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 | 500 | * Ajax Upgrade to FontAwesome 5 |
| 541 | 501 | */ |
| 542 | 502 | public function ajax_upgrade_to_fa5() { |
| 543 | 503 | check_ajax_referer( self::NEEDS_UPDATE_OPTION, '_nonce' ); |
| 544 | 504 | |
| 545 | - if ( ! current_user_can( 'manage_options' ) ) { | |
| 546 | - wp_send_json_error( 'Permission denied' ); | |
| 547 | - } | |
| 548 | - | |
| 549 | 505 | delete_option( 'elementor_' . self::NEEDS_UPDATE_OPTION ); |
| 550 | 506 | |
| 551 | - wp_send_json_success( [ 'message' => esc_html__( 'Hurray! The upgrade process to Font Awesome 5 was completed successfully.', 'elementor' ) ] ); | |
| 507 | + wp_send_json_success( [ 'message' => '<p>' . esc_html__( 'Hurray! The upgrade process to Font Awesome 5 was completed successfully.', 'elementor' ) . '</p>' ] ); | |
| 552 | 508 | } |
| 553 | 509 | |
| 554 | 510 | /** |
| 555 | 511 | * Add Update Needed Flag |
| 556 | - * | |
| 557 | 512 | * @param array $settings |
| 558 | 513 | * |
| 559 | 514 | * @return array; |
| 560 | 515 | */ |
| @@ -570,9 +525,9 @@ | ||
| 570 | 525 | $current_filter = current_filter(); |
| 571 | 526 | $load_shim = get_option( self::LOAD_FA4_SHIM_OPTION_KEY, false ); |
| 572 | 527 | if ( 'elementor/editor/after_enqueue_styles' === $current_filter ) { |
| 573 | 528 | self::enqueue_shim(); |
| 574 | - } elseif ( 'yes' === $load_shim ) { | |
| 529 | + } else if ( 'yes' === $load_shim ) { | |
| 575 | 530 | self::enqueue_shim(); |
| 576 | 531 | } |
| 577 | 532 | } |
| 578 | 533 | } |
| @@ -586,8 +541,24 @@ | ||
| 586 | 541 | return []; |
| 587 | 542 | } |
| 588 | 543 | |
| 589 | 544 | /** |
| 545 | + * @since 3.0.0 | |
| 546 | + * @deprecated 3.0.0 | |
| 547 | + */ | |
| 548 | + public function register_ajax_actions() { | |
| 549 | + _deprecated_function( __METHOD__, '3.0.0' ); | |
| 550 | + } | |
| 551 | + | |
| 552 | + /** | |
| 553 | + * @since 3.0.0. | |
| 554 | + * @deprecated 3.0.0 | |
| 555 | + */ | |
| 556 | + public function ajax_enable_svg_uploads() { | |
| 557 | + _deprecated_function( __METHOD__, '3.0.0' ); | |
| 558 | + } | |
| 559 | + | |
| 560 | + /** | |
| 590 | 561 | * Icons Manager constructor |
| 591 | 562 | */ |
| 592 | 563 | public function __construct() { |
| 593 | 564 | if ( is_admin() ) { |
| @@ -596,8 +567,10 @@ | ||
| 596 | 567 | } |
| 597 | 568 | |
| 598 | 569 | if ( self::is_font_icon_inline_svg() ) { |
| 599 | 570 | self::$data_manager = new Font_Icon_Svg_Data_Manager(); |
| 571 | + | |
| 572 | + add_action( 'wp_footer', [ $this, 'render_svg_symbols' ], 10 ); | |
| 600 | 573 | } |
| 601 | 574 | |
| 602 | 575 | add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'enqueue_fontawesome_css' ] ); |
| 603 | 576 | add_action( 'elementor/frontend/after_register_styles', [ $this, 'register_styles' ] ); |