| 1 |
<?php |
| 2 |
namespace Elementor\Core\Page_Assets\Data_Managers\Font_Icon_Svg; |
| 3 |
|
| 4 |
use Elementor\Core\Base\Base_Object; |
| 5 |
|
| 6 |
if ( ! defined( 'ABSPATH' ) ) { |
| 7 |
exit; // Exit if accessed directly. |
| 8 |
} |
| 9 |
|
| 10 |
/** |
| 11 |
* Elementor Font Icon Svg Manager. |
| 12 |
* |
| 13 |
* @since 3.4.0 |
| 14 |
*/ |
| 15 |
class Manager extends Base_Object { |
| 16 |
private static $data = []; |
| 17 |
|
| 18 |
private static function get_data() { |
| 19 |
if ( ! self::$data ) { |
| 20 |
self::$data = [ |
| 21 |
'font-awesome' => [ |
| 22 |
'regex' => '/^fa-/', |
| 23 |
'manager' => new Font_Awesome(), |
| 24 |
], |
| 25 |
'eicons' => [ |
| 26 |
'regex' => '/^eicons$/', |
| 27 |
'manager' => new E_Icons(), |
| 28 |
], |
| 29 |
]; |
| 30 |
} |
| 31 |
|
| 32 |
return self::$data; |
| 33 |
} |
| 34 |
|
| 35 |
public static function get_font_icon_svg_data( $icon ) { |
| 36 |
$data = self::get_data(); |
| 37 |
|
| 38 |
$font_family = $icon['font_family']; |
| 39 |
|
| 40 |
$font_family_manager = $data[ $font_family ]['manager']; |
| 41 |
|
| 42 |
return $font_family_manager->get_asset_data( $icon ); |
| 43 |
} |
| 44 |
|
| 45 |
public static function get_font_family( $icon_library ) { |
| 46 |
foreach ( self::get_data() as $family => $data ) { |
| 47 |
if ( preg_match( $data['regex'], $icon_library ) ) { |
| 48 |
return $family; |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
return ''; |
| 53 |
} |
| 54 |
} |
| 55 |
|