PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.2.4.1
Adminify – White Label, Admin Menu Editor, Login Customizer v3.2.4.1
4.3.2 4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 All 165 releases
← All changes | Libs/adminify-framework/fields/typography/typography.php +504 -460 4.1.17 → 3.2.4.1 View file →
@@ -1,5 +1,8 @@
1 -<?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
1 +<?php if ( ! defined( 'ABSPATH' ) ) {
2 + die; } // Cannot access directly.
3 +
4 +use WPAdminify\Inc\Utils;
2 5 /**
3 6 *
4 7 * Field: typography
5 8 *
@@ -4,541 +7,582 @@
4 7 * Field: typography
5 8 *
6 9 * @since 1.0.0
7 10 * @version 1.0.0
8 - *
9 11 */
10 12 if ( ! class_exists( 'ADMINIFY_Field_typography' ) ) {
11 - class ADMINIFY_Field_typography extends ADMINIFY_Fields {
13 + class ADMINIFY_Field_typography extends ADMINIFY_Fields {
12 14
13 - public $chosen = false;
15 + public $chosen = false;
14 16
15 - public $value = array();
17 + public $value = [];
16 18
17 - public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
18 - parent::__construct( $field, $value, $unique, $where, $parent );
19 - }
19 + public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
20 + parent::__construct( $field, $value, $unique, $where, $parent );
21 + }
20 22
21 - public function render() {
23 + public function render() {
24 + echo wp_kses_post( $this->field_before() );
22 25
23 - echo $this->field_before();
26 + $args = wp_parse_args(
27 + $this->field,
28 + [
29 + 'font_family' => true,
30 + 'font_weight' => true,
31 + 'font_style' => true,
32 + 'font_size' => true,
33 + 'line_height' => true,
34 + 'letter_spacing' => true,
35 + 'text_align' => true,
36 + 'text_transform' => true,
37 + 'color' => true,
38 + 'chosen' => true,
39 + 'preview' => true,
40 + 'subset' => true,
41 + 'multi_subset' => false,
42 + 'extra_styles' => false,
43 + 'backup_font_family' => false,
44 + 'font_variant' => false,
45 + 'word_spacing' => false,
46 + 'text_decoration' => false,
47 + 'custom_style' => false,
48 + 'compact' => false,
49 + 'exclude' => '',
50 + 'unit' => 'px',
51 + 'line_height_unit' => '',
52 + 'preview_text' => 'The quick brown fox jumps over the lazy dog',
53 + ]
54 + );
24 55
25 - $args = wp_parse_args( $this->field, array(
26 - 'font_family' => true,
27 - 'font_weight' => true,
28 - 'font_style' => true,
29 - 'font_size' => true,
30 - 'line_height' => true,
31 - 'letter_spacing' => true,
32 - 'text_align' => true,
33 - 'text_transform' => true,
34 - 'color' => true,
35 - 'chosen' => true,
36 - 'preview' => true,
37 - 'subset' => true,
38 - 'multi_subset' => false,
39 - 'extra_styles' => false,
40 - 'backup_font_family' => false,
41 - 'font_variant' => false,
42 - 'word_spacing' => false,
43 - 'text_decoration' => false,
44 - 'custom_style' => false,
45 - 'compact' => false,
46 - 'exclude' => '',
47 - 'unit' => 'px',
48 - 'line_height_unit' => '',
49 - 'preview_text' => 'The quick brown fox jumps over the lazy dog',
50 - ) );
56 + if ( $args['compact'] ) {
57 + $args['text_transform'] = false;
58 + $args['text_align'] = false;
59 + $args['font_size'] = false;
60 + $args['line_height'] = false;
61 + $args['letter_spacing'] = false;
62 + $args['preview'] = false;
63 + $args['color'] = false;
64 + }
51 65
52 - if ( $args['compact'] ) {
53 - $args['text_transform'] = false;
54 - $args['text_align'] = false;
55 - $args['font_size'] = false;
56 - $args['line_height'] = false;
57 - $args['letter_spacing'] = false;
58 - $args['preview'] = false;
59 - $args['color'] = false;
60 - }
66 + $default_value = [
67 + 'font-family' => '',
68 + 'font-weight' => '',
69 + 'font-style' => '',
70 + 'font-variant' => '',
71 + 'font-size' => '',
72 + 'line-height' => '',
73 + 'letter-spacing' => '',
74 + 'word-spacing' => '',
75 + 'text-align' => '',
76 + 'text-transform' => '',
77 + 'text-decoration' => '',
78 + 'backup-font-family' => '',
79 + 'color' => '',
80 + 'custom-style' => '',
81 + 'type' => '',
82 + 'subset' => '',
83 + 'extra-styles' => [],
84 + ];
61 85
62 - $default_value = array(
63 - 'font-family' => '',
64 - 'font-weight' => '',
65 - 'font-style' => '',
66 - 'font-variant' => '',
67 - 'font-size' => '',
68 - 'line-height' => '',
69 - 'letter-spacing' => '',
70 - 'word-spacing' => '',
71 - 'text-align' => '',
72 - 'text-transform' => '',
73 - 'text-decoration' => '',
74 - 'backup-font-family' => '',
75 - 'color' => '',
76 - 'custom-style' => '',
77 - 'type' => '',
78 - 'subset' => '',
79 - 'extra-styles' => array(),
80 - );
86 + $default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value;
87 + $this->value = wp_parse_args( $this->value, $default_value );
88 + $this->chosen = $args['chosen'];
89 + $chosen_class = ( $this->chosen ) ? ' adminify--chosen' : '';
90 + $line_height_unit = ( ! empty( $args['line_height_unit'] ) ) ? $args['line_height_unit'] : $args['unit'];
81 91
82 - $default_value = ( ! empty( $this->field['default'] ) ) ? wp_parse_args( $this->field['default'], $default_value ) : $default_value;
83 - $this->value = wp_parse_args( $this->value, $default_value );
84 - $this->chosen = $args['chosen'];
85 - $chosen_class = ( $this->chosen ) ? ' adminify--chosen' : '';
86 - $line_height_unit = ( ! empty( $args['line_height_unit'] ) ) ? $args['line_height_unit'] : $args['unit'];
92 + echo '<div class="adminify--typography' . esc_attr( $chosen_class ) . '" data-depend-id="' . esc_attr( $this->field['id'] ) . '" data-unit="' . esc_attr( $args['unit'] ) . '" data-line-height-unit="' . esc_attr( $line_height_unit ) . '" data-exclude="' . esc_attr( $args['exclude'] ) . '">';
87 93
88 - echo '<div class="adminify--typography'. esc_attr( $chosen_class ) .'" data-depend-id="'. esc_attr( $this->field['id'] ) .'" data-unit="'. esc_attr( $args['unit'] ) .'" data-line-height-unit="'. esc_attr( $line_height_unit ) .'" data-exclude="'. esc_attr( $args['exclude'] ) .'">';
94 + echo '<div class="adminify--blocks adminify--blocks-selects">';
89 95
90 - echo '<div class="adminify--blocks adminify--blocks-selects">';
96 + //
97 + // Font Family
98 + if ( ! empty( $args['font_family'] ) ) {
99 + echo '<div class="adminify--block">';
100 + echo '<div class="adminify--title">' . esc_html__( 'Font Family', 'adminify' ) . '</div>';
101 + echo Utils::wp_kses_custom( $this->create_select( [ $this->value['font-family'] => $this->value['font-family'] ], 'font-family', esc_html__( 'Select a font', 'adminify' ) ) );
102 + echo '</div>';
103 + }
91 104
92 - //
93 - // Font Family
94 - if ( ! empty( $args['font_family'] ) ) {
95 - echo '<div class="adminify--block">';
96 - echo '<div class="adminify--title">'. esc_html__( 'Font Family', 'adminify' ) .'</div>';
97 - echo $this->create_select( array( $this->value['font-family'] => $this->value['font-family'] ), 'font-family', esc_html__( 'Select a font', 'adminify' ) );
98 - echo '</div>';
99 - }
105 + //
106 + // Backup Font Family
107 + if ( ! empty( $args['backup_font_family'] ) ) {
108 + echo '<div class="adminify--block adminify--block-backup-font-family hidden">';
109 + echo '<div class="adminify--title">' . esc_html__( 'Backup Font Family', 'adminify' ) . '</div>';
110 + echo wp_kses_post(
111 + $this->create_select(
112 + apply_filters(
113 + 'adminify_field_typography_backup_font_family',
114 + [
115 + 'Arial, Helvetica, sans-serif',
116 + "'Arial Black', Gadget, sans-serif",
117 + "'Comic Sans MS', cursive, sans-serif",
118 + 'Impact, Charcoal, sans-serif',
119 + "'Lucida Sans Unicode', 'Lucida Grande', sans-serif",
120 + 'Tahoma, Geneva, sans-serif',
121 + "'Trebuchet MS', Helvetica, sans-serif'",
122 + 'Verdana, Geneva, sans-serif',
123 + "'Courier New', Courier, monospace",
124 + "'Lucida Console', Monaco, monospace",
125 + 'Georgia, serif',
126 + 'Palatino Linotype',
127 + ]
128 + ),
129 + 'backup-font-family',
130 + esc_html__( 'Default', 'adminify' )
131 + )
132 + );
133 + echo '</div>';
134 + }
100 135
101 - //
102 - // Backup Font Family
103 - if ( ! empty( $args['backup_font_family'] ) ) {
104 - echo '<div class="adminify--block adminify--block-backup-font-family hidden">';
105 - echo '<div class="adminify--title">'. esc_html__( 'Backup Font Family', 'adminify' ) .'</div>';
106 - echo $this->create_select( apply_filters( 'adminify_field_typography_backup_font_family', array(
107 - 'Arial, Helvetica, sans-serif',
108 - "'Arial Black', Gadget, sans-serif",
109 - "'Comic Sans MS', cursive, sans-serif",
110 - 'Impact, Charcoal, sans-serif',
111 - "'Lucida Sans Unicode', 'Lucida Grande', sans-serif",
112 - 'Tahoma, Geneva, sans-serif',
113 - "'Trebuchet MS', Helvetica, sans-serif",
114 - 'Verdana, Geneva, sans-serif',
115 - "'Courier New', Courier, monospace",
116 - "'Lucida Console', Monaco, monospace",
117 - 'Georgia, serif',
118 - 'Palatino Linotype'
119 - ) ), 'backup-font-family', esc_html__( 'Default', 'adminify' ) );
120 - echo '</div>';
121 - }
136 + //
137 + // Font Style and Extra Style Select
138 + if ( ! empty( $args['font_weight'] ) || ! empty( $args['font_style'] ) ) {
122 139
123 - //
124 - // Font Style and Extra Style Select
125 - if ( ! empty( $args['font_weight'] ) || ! empty( $args['font_style'] ) ) {
140 + //
141 + // Font Style Select
142 + echo '<div class="adminify--block adminify--block-font-style hidden">';
143 + echo '<div class="adminify--title">' . esc_html__( 'Font Style', 'adminify' ) . '</div>';
144 + echo '<select class="adminify--font-style-select" data-placeholder="Default">';
126 145
127 - //
128 - // Font Style Select
129 - echo '<div class="adminify--block adminify--block-font-style hidden">';
130 - echo '<div class="adminify--title">'. esc_html__( 'Font Style', 'adminify') .'</div>';
131 - echo '<select class="adminify--font-style-select" data-placeholder="Default">';
132 - echo '<option value="">'. ( ! $this->chosen ? esc_html__( 'Default', 'adminify' ) : '' ) .'</option>';
133 - if ( ! empty( $this->value['font-weight'] ) || ! empty( $this->value['font-style'] ) ) {
134 - echo '<option value="'. esc_attr( strtolower( $this->value['font-weight'] . $this->value['font-style'] ) ) .'" selected></option>';
135 - }
136 - echo '</select>';
137 - echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[font-weight]' ) ) .'" class="adminify--font-weight" value="'. esc_attr( $this->value['font-weight'] ) .'" />';
138 - echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[font-style]' ) ) .'" class="adminify--font-style" value="'. esc_attr( $this->value['font-style'] ) .'" />';
146 + if ( ( ! $this->chosen ) ){
147 + $typo_options = esc_html__( 'Default', 'adminify' );
148 + } else {
149 + $typo_options = '';
150 + }
151 + echo '<option value="">' . esc_html( $typo_options ). '</option>';
139 152
140 - //
141 - // Extra Font Style Select
142 - if ( ! empty( $args['extra_styles'] ) ) {
143 - echo '<div class="adminify--block-extra-styles hidden">';
144 - echo ( ! $this->chosen ) ? '<div class="adminify--title">'. esc_html__( 'Load Extra Styles', 'adminify' ) .'</div>' : '';
145 - $placeholder = ( $this->chosen ) ? esc_html__( 'Load Extra Styles', 'adminify' ) : esc_html__( 'Default', 'adminify' );
146 - echo $this->create_select( $this->value['extra-styles'], 'extra-styles', $placeholder, true );
147 - echo '</div>';
148 - }
153 + if ( ! empty( $this->value['font-weight'] ) || ! empty( $this->value['font-style'] ) ) {
154 + echo '<option value="' . esc_attr( strtolower( $this->value['font-weight'] . $this->value['font-style'] ) ) . '" selected></option>';
155 + }
156 + echo '</select>';
157 + echo '<input type="hidden" name="' . esc_attr( $this->field_name( '[font-weight]' ) ) . '" class="adminify--font-weight" value="' . esc_attr( $this->value['font-weight'] ) . '" />';
158 + echo '<input type="hidden" name="' . esc_attr( $this->field_name( '[font-style]' ) ) . '" class="adminify--font-style" value="' . esc_attr( $this->value['font-style'] ) . '" />';
149 159
150 - echo '</div>';
160 + //
161 + // Extra Font Style Select
162 + if ( ! empty( $args['extra_styles'] ) ) {
163 + echo '<div class="adminify--block-extra-styles hidden">';
164 + echo ( ! $this->chosen ) ? '<div class="adminify--title">' . esc_html__( 'Load Extra Styles', 'adminify' ) . '</div>' : '';
165 + $placeholder = ( $this->chosen ) ? esc_html__( 'Load Extra Styles', 'adminify' ) : esc_html__( 'Default', 'adminify' );
166 + echo wp_kses_post( $this->create_select( $this->value['extra-styles'], 'extra-styles', $placeholder, true ) );
167 + echo '</div>';
168 + }
151 169
152 - }
170 + echo '</div>';
171 + }
153 172
154 - //
155 - // Subset
156 - if ( ! empty( $args['subset'] ) ) {
157 - echo '<div class="adminify--block adminify--block-subset hidden">';
158 - echo '<div class="adminify--title">'. esc_html__( 'Subset', 'adminify' ) .'</div>';
159 - $subset = ( is_array( $this->value['subset'] ) ) ? $this->value['subset'] : array_filter( (array) $this->value['subset'] );
160 - echo $this->create_select( $subset, 'subset', esc_html__( 'Default', 'adminify' ), $args['multi_subset'] );
161 - echo '</div>';
162 - }
173 + //
174 + // Subset
175 + if ( ! empty( $args['subset'] ) ) {
176 + echo '<div class="adminify--block adminify--block-subset hidden">';
177 + echo '<div class="adminify--title">' . esc_html__( 'Subset', 'adminify' ) . '</div>';
178 + $subset = ( is_array( $this->value['subset'] ) ) ? $this->value['subset'] : array_filter( (array) $this->value['subset'] );
179 + echo wp_kses_post( $this->create_select( $subset, 'subset', esc_html__( 'Default', 'adminify' ), $args['multi_subset'] ) );
180 + echo '</div>';
181 + }
163 182
164 - //
165 - // Text Align
166 - if ( ! empty( $args['text_align'] ) ) {
167 - echo '<div class="adminify--block">';
168 - echo '<div class="adminify--title">'. esc_html__( 'Text Align', 'adminify' ) .'</div>';
169 - echo $this->create_select( array(
170 - 'inherit' => esc_html__( 'Inherit', 'adminify' ),
171 - 'left' => esc_html__( 'Left', 'adminify' ),
172 - 'center' => esc_html__( 'Center', 'adminify' ),
173 - 'right' => esc_html__( 'Right', 'adminify' ),
174 - 'justify' => esc_html__( 'Justify', 'adminify' ),
175 - 'initial' => esc_html__( 'Initial', 'adminify' )
176 - ), 'text-align', esc_html__( 'Default', 'adminify' ) );
177 - echo '</div>';
178 - }
183 + //
184 + // Text Align
185 + if ( ! empty( $args['text_align'] ) ) {
186 + echo '<div class="adminify--block">';
187 + echo '<div class="adminify--title">' . esc_html__( 'Text Align', 'adminify' ) . '</div>';
188 + echo wp_kses_post(
189 + $this->create_select(
190 + [
191 + 'inherit' => esc_html__( 'Inherit', 'adminify' ),
192 + 'left' => esc_html__( 'Left', 'adminify' ),
193 + 'center' => esc_html__( 'Center', 'adminify' ),
194 + 'right' => esc_html__( 'Right', 'adminify' ),
195 + 'justify' => esc_html__( 'Justify', 'adminify' ),
196 + 'initial' => esc_html__( 'Initial', 'adminify' ),
197 + ],
198 + 'text-align',
199 + esc_html__( 'Default', 'adminify' )
200 + )
201 + );
202 + echo '</div>';
203 + }
179 204
180 - //
181 - // Font Variant
182 - if ( ! empty( $args['font_variant'] ) ) {
183 - echo '<div class="adminify--block">';
184 - echo '<div class="adminify--title">'. esc_html__( 'Font Variant', 'adminify' ) .'</div>';
185 - echo $this->create_select( array(
186 - 'normal' => esc_html__( 'Normal', 'adminify' ),
187 - 'small-caps' => esc_html__( 'Small Caps', 'adminify' ),
188 - 'all-small-caps' => esc_html__( 'All Small Caps', 'adminify' )
189 - ), 'font-variant', esc_html__( 'Default', 'adminify' ) );
190 - echo '</div>';
191 - }
205 + //
206 + // Font Variant
207 + if ( ! empty( $args['font_variant'] ) ) {
208 + echo '<div class="adminify--block">';
209 + echo '<div class="adminify--title">' . esc_html__( 'Font Variant', 'adminify' ) . '</div>';
210 + echo wp_kses_post(
211 + $this->create_select(
212 + [
213 + 'normal' => esc_html__( 'Normal', 'adminify' ),
214 + 'small-caps' => esc_html__( 'Small Caps', 'adminify' ),
215 + 'all-small-caps' => esc_html__( 'All Small Caps', 'adminify' ),
216 + ],
217 + 'font-variant',
218 + esc_html__( 'Default', 'adminify' )
219 + )
220 + );
221 + echo '</div>';
222 + }
192 223
193 - //
194 - // Text Transform
195 - if ( ! empty( $args['text_transform'] ) ) {
196 - echo '<div class="adminify--block">';
197 - echo '<div class="adminify--title">'. esc_html__( 'Text Transform', 'adminify' ) .'</div>';
198 - echo $this->create_select( array(
199 - 'none' => esc_html__( 'None', 'adminify' ),
200 - 'capitalize' => esc_html__( 'Capitalize', 'adminify' ),
201 - 'uppercase' => esc_html__( 'Uppercase', 'adminify' ),
202 - 'lowercase' => esc_html__( 'Lowercase', 'adminify' )
203 - ), 'text-transform', esc_html__( 'Default', 'adminify' ) );
204 - echo '</div>';
205 - }
224 + //
225 + // Text Transform
226 + if ( ! empty( $args['text_transform'] ) ) {
227 + echo '<div class="adminify--block">';
228 + echo '<div class="adminify--title">' . esc_html__( 'Text Transform', 'adminify' ) . '</div>';
229 + echo wp_kses_post(
230 + $this->create_select(
231 + [
232 + 'none' => esc_html__( 'None', 'adminify' ),
233 + 'capitalize' => esc_html__( 'Capitalize', 'adminify' ),
234 + 'uppercase' => esc_html__( 'Uppercase', 'adminify' ),
235 + 'lowercase' => esc_html__( 'Lowercase', 'adminify' ),
236 + ],
237 + 'text-transform',
238 + esc_html__( 'Default', 'adminify' )
239 + )
240 + );
241 + echo '</div>';
242 + }
206 243
207 - //
208 - // Text Decoration
209 - if ( ! empty( $args['text_decoration'] ) ) {
210 - echo '<div class="adminify--block">';
211 - echo '<div class="adminify--title">'. esc_html__( 'Text Decoration', 'adminify' ) .'</div>';
212 - echo $this->create_select( array(
213 - 'none' => esc_html__( 'None', 'adminify' ),
214 - 'underline' => esc_html__( 'Solid', 'adminify' ),
215 - 'underline double' => esc_html__( 'Double', 'adminify' ),
216 - 'underline dotted' => esc_html__( 'Dotted', 'adminify' ),
217 - 'underline dashed' => esc_html__( 'Dashed', 'adminify' ),
218 - 'underline wavy' => esc_html__( 'Wavy', 'adminify' ),
219 - 'underline overline' => esc_html__( 'Overline', 'adminify' ),
220 - 'line-through' => esc_html__( 'Line-through', 'adminify' )
221 - ), 'text-decoration', esc_html__( 'Default', 'adminify' ) );
222 - echo '</div>';
223 - }
244 + //
245 + // Text Decoration
246 + if ( ! empty( $args['text_decoration'] ) ) {
247 + echo '<div class="adminify--block">';
248 + echo '<div class="adminify--title">' . esc_html__( 'Text Decoration', 'adminify' ) . '</div>';
249 + echo wp_kses_post(
250 + $this->create_select(
251 + [
252 + 'none' => esc_html__( 'None', 'adminify' ),
253 + 'underline' => esc_html__( 'Solid', 'adminify' ),
254 + 'underline double' => esc_html__( 'Double', 'adminify' ),
255 + 'underline dotted' => esc_html__( 'Dotted', 'adminify' ),
256 + 'underline dashed' => esc_html__( 'Dashed', 'adminify' ),
257 + 'underline wavy' => esc_html__( 'Wavy', 'adminify' ),
258 + 'underline overline' => esc_html__( 'Overline', 'adminify' ),
259 + 'line-through' => esc_html__( 'Line-through', 'adminify' ),
260 + ],
261 + 'text-decoration',
262 + esc_html__( 'Default', 'adminify' )
263 + )
264 + );
265 + echo '</div>';
266 + }
224 267
225 - echo '</div>';
268 + echo '</div>';
226 269
227 - echo '<div class="adminify--blocks adminify--blocks-inputs">';
270 + echo '<div class="adminify--blocks adminify--blocks-inputs">';
228 271
229 - //
230 - // Font Size
231 - if ( ! empty( $args['font_size'] ) ) {
232 - echo '<div class="adminify--block">';
233 - echo '<div class="adminify--title">'. esc_html__( 'Font Size', 'adminify' ) .'</div>';
234 - echo '<div class="adminify--input-wrap">';
235 - echo '<input type="number" name="'. esc_attr( $this->field_name( '[font-size]' ) ) .'" class="adminify--font-size adminify--input adminify-input-number" value="'. esc_attr( $this->value['font-size'] ) .'" step="any" />';
236 - echo '<span class="adminify--unit">'. esc_attr( $args['unit'] ) .'</span>';
237 - echo '</div>';
238 - echo '</div>';
239 - }
272 + //
273 + // Font Size
274 + if ( ! empty( $args['font_size'] ) ) {
275 + echo '<div class="adminify--block">';
276 + echo '<div class="adminify--title">' . esc_html__( 'Font Size', 'adminify' ) . '</div>';
277 + echo '<div class="adminify--input-wrap">';
278 + echo '<input type="number" name="' . esc_attr( $this->field_name( '[font-size]' ) ) . '" class="adminify--font-size adminify--input adminify-input-number" value="' . esc_attr( $this->value['font-size'] ) . '" step="any" />';
279 + echo '<span class="adminify--unit">' . esc_attr( $args['unit'] ) . '</span>';
280 + echo '</div>';
281 + echo '</div>';
282 + }
240 283
241 - //
242 - // Line Height
243 - if ( ! empty( $args['line_height'] ) ) {
244 - echo '<div class="adminify--block">';
245 - echo '<div class="adminify--title">'. esc_html__( 'Line Height', 'adminify' ) .'</div>';
246 - echo '<div class="adminify--input-wrap">';
247 - echo '<input type="number" name="'. esc_attr( $this->field_name( '[line-height]' ) ) .'" class="adminify--line-height adminify--input adminify-input-number" value="'. esc_attr( $this->value['line-height'] ) .'" step="any" />';
248 - echo '<span class="adminify--unit">'. esc_attr( $line_height_unit ) .'</span>';
249 - echo '</div>';
250 - echo '</div>';
251 - }
284 + //
285 + // Line Height
286 + if ( ! empty( $args['line_height'] ) ) {
287 + echo '<div class="adminify--block">';
288 + echo '<div class="adminify--title">' . esc_html__( 'Line Height', 'adminify' ) . '</div>';
289 + echo '<div class="adminify--input-wrap">';
290 + echo '<input type="number" name="' . esc_attr( $this->field_name( '[line-height]' ) ) . '" class="adminify--line-height adminify--input adminify-input-number" value="' . esc_attr( $this->value['line-height'] ) . '" step="any" />';
291 + echo '<span class="adminify--unit">' . esc_attr( $line_height_unit ) . '</span>';
292 + echo '</div>';
293 + echo '</div>';
294 + }
252 295
253 - //
254 - // Letter Spacing
255 - if ( ! empty( $args['letter_spacing'] ) ) {
256 - echo '<div class="adminify--block">';
257 - echo '<div class="adminify--title">'. esc_html__( 'Letter Spacing', 'adminify' ) .'</div>';
258 - echo '<div class="adminify--input-wrap">';
259 - echo '<input type="number" name="'. esc_attr( $this->field_name( '[letter-spacing]' ) ) .'" class="adminify--letter-spacing adminify--input adminify-input-number" value="'. esc_attr( $this->value['letter-spacing'] ) .'" step="any" />';
260 - echo '<span class="adminify--unit">'. esc_attr( $args['unit'] ) .'</span>';
261 - echo '</div>';
262 - echo '</div>';
263 - }
296 + //
297 + // Letter Spacing
298 + if ( ! empty( $args['letter_spacing'] ) ) {
299 + echo '<div class="adminify--block">';
300 + echo '<div class="adminify--title">' . esc_html__( 'Letter Spacing', 'adminify' ) . '</div>';
301 + echo '<div class="adminify--input-wrap">';
302 + echo '<input type="number" name="' . esc_attr( $this->field_name( '[letter-spacing]' ) ) . '" class="adminify--letter-spacing adminify--input adminify-input-number" value="' . esc_attr( $this->value['letter-spacing'] ) . '" step="any" />';
303 + echo '<span class="adminify--unit">' . esc_attr( $args['unit'] ) . '</span>';
304 + echo '</div>';
305 + echo '</div>';
306 + }
264 307
265 - //
266 - // Word Spacing
267 - if ( ! empty( $args['word_spacing'] ) ) {
268 - echo '<div class="adminify--block">';
269 - echo '<div class="adminify--title">'. esc_html__( 'Word Spacing', 'adminify' ) .'</div>';
270 - echo '<div class="adminify--input-wrap">';
271 - echo '<input type="number" name="'. esc_attr( $this->field_name( '[word-spacing]' ) ) .'" class="adminify--word-spacing adminify--input adminify-input-number" value="'. esc_attr( $this->value['word-spacing'] ) .'" step="any" />';
272 - echo '<span class="adminify--unit">'. esc_attr( $args['unit'] ) .'</span>';
273 - echo '</div>';
274 - echo '</div>';
275 - }
308 + //
309 + // Word Spacing
310 + if ( ! empty( $args['word_spacing'] ) ) {
311 + echo '<div class="adminify--block">';
312 + echo '<div class="adminify--title">' . esc_html__( 'Word Spacing', 'adminify' ) . '</div>';
313 + echo '<div class="adminify--input-wrap">';
314 + echo '<input type="number" name="' . esc_attr( $this->field_name( '[word-spacing]' ) ) . '" class="adminify--word-spacing adminify--input adminify-input-number" value="' . esc_attr( $this->value['word-spacing'] ) . '" step="any" />';
315 + echo '<span class="adminify--unit">' . esc_attr( $args['unit'] ) . '</span>';
316 + echo '</div>';
317 + echo '</div>';
318 + }
276 319
277 - echo '</div>';
320 + echo '</div>';
278 321
279 - //
280 - // Font Color
281 - if ( ! empty( $args['color'] ) ) {
282 - $default_color_attr = ( ! empty( $default_value['color'] ) ) ? ' data-default-color="'. esc_attr( $default_value['color'] ) .'"' : '';
283 - echo '<div class="adminify--block adminify--block-font-color">';
284 - echo '<div class="adminify--title">'. esc_html__( 'Font Color', 'adminify' ) .'</div>';
285 - echo '<div class="adminify-field-color">';
286 - echo '<input type="text" name="'. esc_attr( $this->field_name( '[color]' ) ) .'" class="adminify-color adminify--color" value="'. esc_attr( $this->value['color'] ) .'"'. $default_color_attr .' />';
287 - echo '</div>';
288 - echo '</div>';
289 - }
322 + //
323 + // Font Color
324 + if ( ! empty( $args['color'] ) ) {
325 + $default_color_attr = ( ! empty( $default_value['color'] ) ) ? ' data-default-color="' . esc_attr( $default_value['color'] ) . '"' : '';
326 + echo '<div class="adminify--block adminify--block-font-color">';
327 + echo '<div class="adminify--title">' . esc_html__( 'Font Color', 'adminify' ) . '</div>';
328 + echo '<div class="adminify-field-color">';
329 + echo '<input type="text" name="' . esc_attr( $this->field_name( '[color]' ) ) . '" class="adminify-color adminify--color" value="' . esc_attr( $this->value['color'] ) . '"' . esc_attr( $default_color_attr ) . ' />';
330 + echo '</div>';
331 + echo '</div>';
332 + }
290 333
291 - //
292 - // Custom style
293 - if ( ! empty( $args['custom_style'] ) ) {
294 - echo '<div class="adminify--block adminify--block-custom-style">';
295 - echo '<div class="adminify--title">'. esc_html__( 'Custom Style', 'adminify' ) .'</div>';
296 - echo '<textarea name="'. esc_attr( $this->field_name( '[custom-style]' ) ) .'" class="adminify--custom-style">'. esc_attr( $this->value['custom-style'] ) .'</textarea>';
297 - echo '</div>';
298 - }
334 + //
335 + // Custom style
336 + if ( ! empty( $args['custom_style'] ) ) {
337 + echo '<div class="adminify--block adminify--block-custom-style">';
338 + echo '<div class="adminify--title">' . esc_html__( 'Custom Style', 'adminify' ) . '</div>';
339 + echo '<textarea name="' . esc_attr( $this->field_name( '[custom-style]' ) ) . '" class="adminify--custom-style">' . esc_attr( $this->value['custom-style'] ) . '</textarea>';
340 + echo '</div>';
341 + }
299 342
300 - //
301 - // Preview
302 - $always_preview = ( $args['preview'] !== 'always' ) ? ' hidden' : '';
343 + //
344 + // Preview
345 + $always_preview = ( $args['preview'] !== 'always' ) ? ' hidden' : '';
303 346
304 - if ( ! empty( $args['preview'] ) ) {
305 - echo '<div class="adminify--block adminify--block-preview'. esc_attr( $always_preview ) .'">';
306 - echo '<div class="adminify--toggle fas fa-toggle-off"></div>';
307 - echo '<div class="adminify--preview">'. esc_attr( $args['preview_text'] ) .'</div>';
308 - echo '</div>';
309 - }
347 + if ( ! empty( $args['preview'] ) ) {
348 + echo '<div class="adminify--block adminify--block-preview' . esc_attr( $always_preview ) . '">';
349 + echo '<div class="adminify--toggle fas fa-toggle-off"></div>';
350 + echo '<div class="adminify--preview">' . esc_attr( $args['preview_text'] ) . '</div>';
351 + echo '</div>';
352 + }
310 353
311 - echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[type]' ) ) .'" class="adminify--type" value="'. esc_attr( $this->value['type'] ) .'" />';
312 - echo '<input type="hidden" name="'. esc_attr( $this->field_name( '[unit]' ) ) .'" class="adminify--unit-save" value="'. esc_attr( $args['unit'] ) .'" />';
354 + echo '<input type="hidden" name="' . esc_attr( $this->field_name( '[type]' ) ) . '" class="adminify--type" value="' . esc_attr( $this->value['type'] ) . '" />';
355 + echo '<input type="hidden" name="' . esc_attr( $this->field_name( '[unit]' ) ) . '" class="adminify--unit-save" value="' . esc_attr( $args['unit'] ) . '" />';
313 356
314 - echo '</div>';
357 + echo '</div>';
315 358
316 - echo $this->field_after();
359 + echo wp_kses_post( $this->field_after() );
360 + }
317 361
318 - }
362 + public function create_select( $options, $name, $placeholder = '', $is_multiple = false ) {
363 + $multiple_name = ( $is_multiple ) ? '[]' : '';
364 + $multiple_attr = ( $is_multiple ) ? ' multiple data-multiple="true"' : '';
365 + $chosen_rtl = ( $this->chosen && is_rtl() ) ? ' chosen-rtl' : '';
319 366
320 - public function create_select( $options, $name, $placeholder = '', $is_multiple = false ) {
367 + $output = '<select name="' . esc_attr( $this->field_name( '[' . $name . ']' . $multiple_name ) ) . '" class="adminify--' . esc_attr( $name ) . esc_attr( $chosen_rtl ) . '" data-placeholder="' . esc_attr( $placeholder ) . '"' . $multiple_attr . '>';
368 + $output .= ( ! empty( $placeholder ) ) ? '<option value="">' . esc_attr( ( ! $this->chosen ) ? $placeholder : '' ) . '</option>' : '';
321 369
322 - $multiple_name = ( $is_multiple ) ? '[]' : '';
323 - $multiple_attr = ( $is_multiple ) ? ' multiple data-multiple="true"' : '';
324 - $chosen_rtl = ( $this->chosen && is_rtl() ) ? ' chosen-rtl' : '';
370 + if ( ! empty( $options ) ) {
371 + foreach ( $options as $option_key => $option_value ) {
372 + if ( $is_multiple ) {
373 + $selected = ( in_array( $option_value, $this->value[ $name ] ) ) ? ' selected' : '';
374 + $output .= '<option value="' . esc_attr( $option_value ) . '"' . esc_attr( $selected ) . '>' . esc_attr( $option_value ) . '</option>';
375 + } else {
376 + $option_key = ( is_numeric( $option_key ) ) ? $option_value : $option_key;
377 + $selected = ( $option_key === $this->value[ $name ] ) ? ' selected' : '';
378 + $output .= '<option value="' . esc_attr( $option_key ) . '"' . esc_attr( $selected ) . '>' . esc_attr( $option_value ) . '</option>';
379 + }
380 + }
381 + }
325 382
326 - $output = '<select name="'. esc_attr( $this->field_name( '['. $name .']'. $multiple_name ) ) .'" class="adminify--'. esc_attr( $name ) . esc_attr( $chosen_rtl ) .'" data-placeholder="'. esc_attr( $placeholder ) .'"'. $multiple_attr .'>';
327 - $output .= ( ! empty( $placeholder ) ) ? '<option value="">'. esc_attr( ( ! $this->chosen ) ? $placeholder : '' ) .'</option>' : '';
383 + $output .= '</select>';
328 384
329 - if ( ! empty( $options ) ) {
330 - foreach ( $options as $option_key => $option_value ) {
331 - if ( $is_multiple ) {
332 - $selected = ( in_array( $option_value, $this->value[$name] ) ) ? ' selected' : '';
333 - $output .= '<option value="'. esc_attr( $option_value ) .'"'. esc_attr( $selected ).'>'. esc_attr( $option_value ) .'</option>';
334 - } else {
335 - $option_key = ( is_numeric( $option_key ) ) ? $option_value : $option_key;
336 - $selected = ( $option_key === $this->value[$name] ) ? ' selected' : '';
337 - $output .= '<option value="'. esc_attr( $option_key ) .'"'. esc_attr( $selected ).'>'. esc_attr( $option_value ) .'</option>';
338 - }
339 - }
340 - }
385 + return $output;
386 + }
341 387
342 - $output .= '</select>';
388 + public function enqueue() {
389 + if ( ! wp_script_is( 'adminify-webfontloader' ) ) {
390 + ADMINIFY::include_plugin_file( 'fields/typography/google-fonts.php' );
343 391
344 - return $output;
392 + wp_enqueue_script( 'adminify-webfontloader', 'https://cdn.jsdelivr.net/npm/[email protected]/webfontloader.min.js', [ 'adminify' ], '1.6.28', true );
345 393
346 - }
394 + $webfonts = [];
347 395
348 - public function enqueue() {
396 + $customwebfonts = apply_filters( 'adminify_field_typography_customwebfonts', [] );
349 397
350 - if ( ! wp_script_is( 'adminify-webfontloader' ) ) {
398 + if ( ! empty( $customwebfonts ) ) {
399 + $webfonts['custom'] = [
400 + 'label' => esc_html__( 'Custom Web Fonts', 'adminify' ),
401 + 'fonts' => $customwebfonts,
402 + ];
403 + }
351 404
352 - ADMINIFY::include_plugin_file( 'fields/typography/google-fonts.php' );
405 + $webfonts['safe'] = [
406 + 'label' => esc_html__( 'Safe Web Fonts', 'adminify' ),
407 + 'fonts' => apply_filters(
408 + 'adminify_field_typography_safewebfonts',
409 + [
410 + 'Arial',
411 + 'Arial Black',
412 + 'Helvetica',
413 + 'Times New Roman',
414 + 'Courier New',
415 + 'Tahoma',
416 + 'Verdana',
417 + 'Impact',
418 + 'Trebuchet MS',
419 + 'Comic Sans MS',
420 + 'Lucida Console',
421 + 'Lucida Sans Unicode',
422 + 'Georgia, serif',
423 + 'Palatino Linotype',
424 + ]
425 + ),
426 + ];
353 427
354 - wp_enqueue_script( 'adminify-webfontloader', 'https://cdn.jsdelivr.net/npm/[email protected]/webfontloader.min.js', array( 'adminify' ), '1.6.28', true );
428 + $webfonts['google'] = [
429 + 'label' => esc_html__( 'Google Web Fonts', 'adminify' ),
430 + 'fonts' => apply_filters(
431 + 'adminify_field_typography_googlewebfonts',
432 + adminify_get_google_fonts()
433 + ),
434 + ];
355 435
356 - $webfonts = array();
436 + $defaultstyles = apply_filters( 'adminify_field_typography_defaultstyles', [ 'normal', 'italic', '700', '700italic' ] );
357 437
358 - $customwebfonts = apply_filters( 'adminify_field_typography_customwebfonts', array() );
438 + $googlestyles = apply_filters(
439 + 'adminify_field_typography_googlestyles',
440 + [
441 + '100' => 'Thin 100',
442 + '100italic' => 'Thin 100 Italic',
443 + '200' => 'Extra-Light 200',
444 + '200italic' => 'Extra-Light 200 Italic',
445 + '300' => 'Light 300',
446 + '300italic' => 'Light 300 Italic',
447 + 'normal' => 'Normal 400',
448 + 'italic' => 'Normal 400 Italic',
449 + '500' => 'Medium 500',
450 + '500italic' => 'Medium 500 Italic',
451 + '600' => 'Semi-Bold 600',
452 + '600italic' => 'Semi-Bold 600 Italic',
453 + '700' => 'Bold 700',
454 + '700italic' => 'Bold 700 Italic',
455 + '800' => 'Extra-Bold 800',
456 + '800italic' => 'Extra-Bold 800 Italic',
457 + '900' => 'Black 900',
458 + '900italic' => 'Black 900 Italic',
459 + ]
460 + );
359 461
360 - if ( ! empty( $customwebfonts ) ) {
361 - $webfonts['custom'] = array(
362 - 'label' => esc_html__( 'Custom Web Fonts', 'adminify' ),
363 - 'fonts' => $customwebfonts
364 - );
365 - }
462 + $webfonts = apply_filters( 'adminify_field_typography_webfonts', $webfonts );
366 463
367 - $webfonts['safe'] = array(
368 - 'label' => esc_html__( 'Safe Web Fonts', 'adminify' ),
369 - 'fonts' => apply_filters( 'adminify_field_typography_safewebfonts', array(
370 - 'Arial',
371 - 'Arial Black',
372 - 'Helvetica',
373 - 'Times New Roman',
374 - 'Courier New',
375 - 'Tahoma',
376 - 'Verdana',
377 - 'Impact',
378 - 'Trebuchet MS',
379 - 'Comic Sans MS',
380 - 'Lucida Console',
381 - 'Lucida Sans Unicode',
382 - 'Georgia, serif',
383 - 'Palatino Linotype'
384 - )
385 - ) );
464 + wp_localize_script(
465 + 'adminify',
466 + 'adminify_typography_json',
467 + [
468 + 'webfonts' => $webfonts,
469 + 'defaultstyles' => $defaultstyles,
470 + 'googlestyles' => $googlestyles,
471 + ]
472 + );
473 + }
474 + }
386 475
387 - $webfonts['google'] = array(
388 - 'label' => esc_html__( 'Google Web Fonts', 'adminify' ),
389 - 'fonts' => apply_filters( 'adminify_field_typography_googlewebfonts', adminify_get_google_fonts()
390 - ) );
476 + public function enqueue_google_fonts( $method = 'enqueue' ) {
477 + $is_google = false;
391 478
392 - $defaultstyles = apply_filters( 'adminify_field_typography_defaultstyles', array( 'normal', 'italic', '700', '700italic' ) );
479 + if ( ! empty( $this->value['type'] ) ) {
480 + $is_google = ( $this->value['type'] === 'google' ) ? true : false;
481 + } else {
482 + ADMINIFY::include_plugin_file( 'fields/typography/google-fonts.php' );
483 + $is_google = ( array_key_exists( $this->value['font-family'], adminify_get_google_fonts() ) ) ? true : false;
484 + }
393 485
394 - $googlestyles = apply_filters( 'adminify_field_typography_googlestyles', array(
395 - '100' => 'Thin 100',
396 - '100italic' => 'Thin 100 Italic',
397 - '200' => 'Extra-Light 200',
398 - '200italic' => 'Extra-Light 200 Italic',
399 - '300' => 'Light 300',
400 - '300italic' => 'Light 300 Italic',
401 - 'normal' => 'Normal 400',
402 - 'italic' => 'Normal 400 Italic',
403 - '500' => 'Medium 500',
404 - '500italic' => 'Medium 500 Italic',
405 - '600' => 'Semi-Bold 600',
406 - '600italic' => 'Semi-Bold 600 Italic',
407 - '700' => 'Bold 700',
408 - '700italic' => 'Bold 700 Italic',
409 - '800' => 'Extra-Bold 800',
410 - '800italic' => 'Extra-Bold 800 Italic',
411 - '900' => 'Black 900',
412 - '900italic' => 'Black 900 Italic'
413 - ) );
486 + if ( $is_google ) {
414 487
415 - $webfonts = apply_filters( 'adminify_field_typography_webfonts', $webfonts );
488 + // set style
489 + $font_family = ( ! empty( $this->value['font-family'] ) ) ? $this->value['font-family'] : '';
490 + $font_weight = ( ! empty( $this->value['font-weight'] ) ) ? $this->value['font-weight'] : '';
491 + $font_style = ( ! empty( $this->value['font-style'] ) ) ? $this->value['font-style'] : '';
416 492
417 - wp_localize_script( 'adminify', 'adminify_typography_json', array(
418 - 'webfonts' => $webfonts,
419 - 'defaultstyles' => $defaultstyles,
420 - 'googlestyles' => $googlestyles
421 - ) );
493 + if ( $font_weight || $font_style ) {
494 + $style = $font_weight . $font_style;
495 + if ( ! empty( $style ) ) {
496 + $style = ( $style === 'normal' ) ? '400' : $style;
497 + ADMINIFY::$webfonts[ $method ][ $font_family ][ $style ] = $style;
498 + }
499 + } else {
500 + ADMINIFY::$webfonts[ $method ][ $font_family ] = [];
501 + }
422 502
423 - }
503 + // set extra styles
504 + if ( ! empty( $this->value['extra-styles'] ) ) {
505 + foreach ( $this->value['extra-styles'] as $extra_style ) {
506 + if ( ! empty( $extra_style ) ) {
507 + $extra_style = ( $extra_style === 'normal' ) ? '400' : $extra_style;
508 + ADMINIFY::$webfonts[ $method ][ $font_family ][ $extra_style ] = $extra_style;
509 + }
510 + }
511 + }
424 512
425 - }
513 + // set subsets
514 + if ( ! empty( $this->value['subset'] ) ) {
515 + $this->value['subset'] = ( is_array( $this->value['subset'] ) ) ? $this->value['subset'] : array_filter( (array) $this->value['subset'] );
516 + foreach ( $this->value['subset'] as $subset ) {
517 + if ( ! empty( $subset ) ) {
518 + ADMINIFY::$subsets[ $subset ] = $subset;
519 + }
520 + }
521 + }
426 522
427 - public function enqueue_google_fonts( $method = 'enqueue' ) {
523 + return true;
524 + }
428 525
429 - $is_google = false;
526 + return false;
527 + }
430 528
431 - if ( ! empty( $this->value['type'] ) ) {
432 - $is_google = ( $this->value['type'] === 'google' ) ? true : false;
433 - } else {
434 - ADMINIFY::include_plugin_file( 'fields/typography/google-fonts.php' );
435 - $is_google = ( array_key_exists( $this->value['font-family'], adminify_get_google_fonts() ) ) ? true : false;
436 - }
529 + public function output() {
530 + $output = '';
531 + $bg_image = [];
532 + $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
533 + $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
437 534
438 - if ( $is_google ) {
535 + $font_family = ( ! empty( $this->value['font-family'] ) ) ? $this->value['font-family'] : '';
536 + $backup_family = ( ! empty( $this->value['backup-font-family'] ) ) ? ', ' . $this->value['backup-font-family'] : '';
439 537
440 - // set style
441 - $font_family = ( ! empty( $this->value['font-family'] ) ) ? $this->value['font-family'] : '';
442 - $font_weight = ( ! empty( $this->value['font-weight'] ) ) ? $this->value['font-weight'] : '';
443 - $font_style = ( ! empty( $this->value['font-style'] ) ) ? $this->value['font-style'] : '';
538 + if ( $font_family ) {
539 + $output .= 'font-family:"' . $font_family . '"' . $backup_family . $important . ';';
540 + }
444 541
445 - if ( $font_weight || $font_style ) {
446 - $style = $font_weight . $font_style;
447 - if ( ! empty( $style ) ) {
448 - $style = ( $style === 'normal' ) ? '400' : $style;
449 - ADMINIFY::$webfonts[$method][$font_family][$style] = $style;
450 - }
451 - } else {
452 - ADMINIFY::$webfonts[$method][$font_family] = array();
453 - }
542 + // Common font properties
543 + $properties = [
544 + 'color',
545 + 'font-weight',
546 + 'font-style',
547 + 'font-variant',
548 + 'text-align',
549 + 'text-transform',
550 + 'text-decoration',
551 + ];
454 552
455 - // set extra styles
456 - if ( ! empty( $this->value['extra-styles'] ) ) {
457 - foreach ( $this->value['extra-styles'] as $extra_style ) {
458 - if ( ! empty( $extra_style ) ) {
459 - $extra_style = ( $extra_style === 'normal' ) ? '400' : $extra_style;
460 - ADMINIFY::$webfonts[$method][$font_family][$extra_style] = $extra_style;
461 - }
462 - }
463 - }
553 + foreach ( $properties as $property ) {
554 + if ( isset( $this->value[ $property ] ) && $this->value[ $property ] !== '' ) {
555 + $output .= $property . ':' . $this->value[ $property ] . $important . ';';
556 + }
557 + }
464 558
465 - // set subsets
466 - if ( ! empty( $this->value['subset'] ) ) {
467 - $this->value['subset'] = ( is_array( $this->value['subset'] ) ) ? $this->value['subset'] : array_filter( (array) $this->value['subset'] );
468 - foreach ( $this->value['subset'] as $subset ) {
469 - if( ! empty( $subset ) ) {
470 - ADMINIFY::$subsets[$subset] = $subset;
471 - }
472 - }
473 - }
559 + $properties = [
560 + 'font-size',
561 + 'line-height',
562 + 'letter-spacing',
563 + 'word-spacing',
564 + ];
474 565
475 - return true;
566 + $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
567 + $line_height_unit = ( ! empty( $this->value['line_height_unit'] ) ) ? $this->value['line_height_unit'] : $unit;
476 568
477 - }
569 + foreach ( $properties as $property ) {
570 + if ( isset( $this->value[ $property ] ) && $this->value[ $property ] !== '' ) {
571 + $unit = ( $property === 'line-height' ) ? $line_height_unit : $unit;
572 + $output .= $property . ':' . $this->value[ $property ] . $unit . $important . ';';
573 + }
574 + }
478 575
479 - return false;
576 + $custom_style = ( ! empty( $this->value['custom-style'] ) ) ? $this->value['custom-style'] : '';
480 577
481 - }
578 + if ( $output ) {
579 + $output = $element . '{' . $output . $custom_style . '}';
580 + }
482 581
483 - public function output() {
582 + $this->parent->output_css .= $output;
484 583
485 - $output = '';
486 - $bg_image = array();
487 - $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
488 - $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
584 + return $output;
585 + }
489 586
490 - $font_family = ( ! empty( $this->value['font-family'] ) ) ? $this->value['font-family'] : '';
491 - $backup_family = ( ! empty( $this->value['backup-font-family'] ) ) ? ', '. $this->value['backup-font-family'] : '';
492 -
493 - if ( $font_family ) {
494 - $output .= 'font-family:"'. $font_family .'"'. $backup_family . $important .';';
495 - }
496 -
497 - // Common font properties
498 - $properties = array(
499 - 'color',
500 - 'font-weight',
501 - 'font-style',
502 - 'font-variant',
503 - 'text-align',
504 - 'text-transform',
505 - 'text-decoration',
506 - );
507 -
508 - foreach ( $properties as $property ) {
509 - if ( isset( $this->value[$property] ) && $this->value[$property] !== '' ) {
510 - $output .= $property .':'. $this->value[$property] . $important .';';
511 - }
512 - }
513 -
514 - $properties = array(
515 - 'font-size',
516 - 'line-height',
517 - 'letter-spacing',
518 - 'word-spacing',
519 - );
520 -
521 - $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
522 - $line_height_unit = ( ! empty( $this->value['line_height_unit'] ) ) ? $this->value['line_height_unit'] : $unit;
523 -
524 - foreach ( $properties as $property ) {
525 - if ( isset( $this->value[$property] ) && $this->value[$property] !== '' ) {
526 - $unit = ( $property === 'line-height' ) ? $line_height_unit : $unit;
527 - $output .= $property .':'. $this->value[$property] . $unit . $important .';';
528 - }
529 - }
530 -
531 - $custom_style = ( ! empty( $this->value['custom-style'] ) ) ? $this->value['custom-style'] : '';
532 -
533 - if ( $output ) {
534 - $output = $element .'{'. $output . $custom_style .'}';
535 - }
536 -
537 - $this->parent->output_css .= $output;
538 -
539 - return $output;
540 -
541 - }
542 -
543 - }
587 + }
544 588 }