| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\Variables\Classes; |
| 4 |
|
| 5 |
use Elementor\Modules\Variables\Services\Variables_Service; |
| 6 |
use Elementor\Plugin; |
| 7 |
use Elementor\Core\Files\CSS\Post as Post_CSS; |
| 8 |
use Elementor\Modules\Variables\PropTypes\Font_Variable_Prop_Type; |
| 9 |
|
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
exit; // Exit if accessed directly. |
| 12 |
} |
| 13 |
|
| 14 |
class Fonts { |
| 15 |
private Variables_Service $service; |
| 16 |
|
| 17 |
public function __construct( Variables_Service $service ) { |
| 18 |
$this->service = $service; |
| 19 |
} |
| 20 |
|
| 21 |
public function append_to( Post_CSS $post_css ) { |
| 22 |
if ( ! Plugin::$instance->kits_manager->is_kit( $post_css->get_post_id() ) ) { |
| 23 |
return; |
| 24 |
} |
| 25 |
|
| 26 |
$list_of_variables = $this->service->get_variables_list(); |
| 27 |
|
| 28 |
foreach ( $list_of_variables as $variable ) { |
| 29 |
if ( Font_Variable_Prop_Type::get_key() !== $variable['type'] ) { |
| 30 |
continue; |
| 31 |
} |
| 32 |
|
| 33 |
$font_family = sanitize_text_field( $variable['value'] ?? '' ); |
| 34 |
|
| 35 |
if ( empty( $font_family ) ) { |
| 36 |
continue; |
| 37 |
} |
| 38 |
|
| 39 |
$post_css->add_font( $font_family ); |
| 40 |
} |
| 41 |
|
| 42 |
return $this; |
| 43 |
} |
| 44 |
} |
| 45 |
|