| 1 |
<?php |
| 2 |
namespace Elementor\Core\Page_Assets\Data_Managers\Font_Icon_Svg; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly. |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Font Awesome Icon Svg. |
| 10 |
* |
| 11 |
* @since 3.4.0 |
| 12 |
*/ |
| 13 |
class Font_Awesome extends Base { |
| 14 |
const LIBRARY_CURRENT_VERSION = '5.15.3'; |
| 15 |
|
| 16 |
protected function get_config( $icon ) { |
| 17 |
preg_match( '/fa(.*) fa-/', $icon['value'], $icon_name_matches ); |
| 18 |
|
| 19 |
$icon_name = str_replace( $icon_name_matches[0], '', $icon['value'] ); |
| 20 |
|
| 21 |
$icon_key = str_replace( ' fa-', '-', $icon['value'] ); |
| 22 |
|
| 23 |
$icon_file_name = str_replace( 'fa-', '', $icon['library'] ); |
| 24 |
|
| 25 |
return [ |
| 26 |
'key' => $icon_key, |
| 27 |
'version' => self::LIBRARY_CURRENT_VERSION, |
| 28 |
'file_path' => ELEMENTOR_ASSETS_PATH . 'lib/font-awesome/json/' . $icon_file_name . '.json', |
| 29 |
'data' => [ |
| 30 |
'icon_data' => [ |
| 31 |
'name' => $icon_name, |
| 32 |
'library' => $icon['library'], |
| 33 |
], |
| 34 |
], |
| 35 |
]; |
| 36 |
} |
| 37 |
|
| 38 |
protected function get_asset_content() { |
| 39 |
$icon_data = $this->get_config_data( 'icon_data' ); |
| 40 |
|
| 41 |
$file_data = json_decode( $this->get_file_data( 'content', $icon_data['library'] ), true ); |
| 42 |
|
| 43 |
$icon_name = $icon_data['name']; |
| 44 |
|
| 45 |
$svg_data = $file_data['icons'][ $icon_name ]; |
| 46 |
|
| 47 |
return [ |
| 48 |
'width' => $svg_data[0], |
| 49 |
'height' => $svg_data[1], |
| 50 |
'path' => $svg_data[4], |
| 51 |
'key' => $this->get_key(), |
| 52 |
]; |
| 53 |
} |
| 54 |
} |
| 55 |
|