PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.0
Elementor Website Builder – more than just a page builder v3.32.0
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
elementor / modules / atomic-widgets / styles / style-fonts.php

style-fonts.php in Elementor Website Builder – more than just a page builder 3.32.0, at modules/atomic-widgets/styles/style-fonts.php

61 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\AtomicWidgets\Styles;
4
5 use Elementor\Core\Base\Document;
6 use Elementor\Core\Breakpoints\Breakpoint;
7 use Elementor\Core\Utils\Collection;
8 use Elementor\Modules\AtomicWidgets\Memo;
9 use Elementor\Modules\AtomicWidgets\Cache_Validity;
10 use Elementor\Plugin;
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit; // Exit if accessed directly.
14 }
15
16 const FONTS_KEY_PREFIX = 'elementor_atomic_styles_fonts-';
17
18 class Style_Fonts {
19 private string $style_key;
20
21 public function __construct( string $style_key ) {
22 $this->style_key = $style_key;
23 }
24
25 public static function make( string $style_key ) {
26 return new static( $style_key );
27 }
28
29 public function add( string $font ) {
30 $style_fonts = $this->get_fonts();
31
32 if ( ! in_array( $font, $style_fonts, true ) ) {
33 $style_fonts[] = $font;
34
35 $this->update_fonts( $style_fonts );
36 }
37 }
38
39 public function get(): array {
40 return $this->get_fonts();
41 }
42
43 public function clear() {
44 $this->update_fonts( [] );
45 }
46
47 private function get_fonts(): array {
48 $style_fonts_key = $this->get_key();
49 return get_option( $style_fonts_key, [] );
50 }
51
52 private function update_fonts( array $fonts ) {
53 $style_fonts_key = $this->get_key();
54 update_option( $style_fonts_key, $fonts );
55 }
56
57 private function get_key(): string {
58 return FONTS_KEY_PREFIX . $this->style_key;
59 }
60 }
61