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

61 lines 1.2 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 if ( ! defined( 'ABSPATH' ) ) {
6 exit; // Exit if accessed directly.
7 }
8
9 const FONTS_KEY_PREFIX = 'elementor_atomic_styles_fonts-';
10
11 class Style_Fonts {
12 private string $style_key;
13
14 public function __construct( string $style_key ) {
15 $this->style_key = $style_key;
16 }
17
18 public static function make( string $style_key ) {
19 return new static( $style_key );
20 }
21
22 public function add( string $font ) {
23 $style_fonts = $this->get_fonts();
24
25 if ( ! in_array( $font, $style_fonts, true ) ) {
26 $style_fonts[] = $font;
27
28 $this->update_fonts( $style_fonts );
29 }
30 }
31
32 public function get(): array {
33 return $this->get_fonts();
34 }
35
36 public function clear() {
37 $this->update_fonts( [] );
38 }
39
40 private function get_fonts(): array {
41 $style_fonts_key = $this->get_key();
42 return get_option( $style_fonts_key, [] );
43 }
44
45 private function update_fonts( array $fonts ) {
46 $style_fonts_key = $this->get_key();
47
48 if ( empty( $fonts ) ) {
49 delete_option( $style_fonts_key );
50
51 return;
52 }
53
54 update_option( $style_fonts_key, $fonts, false );
55 }
56
57 private function get_key(): string {
58 return FONTS_KEY_PREFIX . $this->style_key;
59 }
60 }
61