PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.2.2
Adminify – White Label, Admin Menu Editor, Login Customizer v4.2.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 4.1.17 All 164 releases
adminify / Libs / adminify-framework / fields / typography / typography.php

typography.php in Adminify – White Label, Admin Menu Editor, Login Customizer 4.2.2, at Libs/adminify-framework/fields/typography/typography.php

546 lines 24.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access directly.
2 /**
3 *
4 * Field: typography
5 *
6 * @since 1.0.0
7 * @version 1.0.0
8 *
9 */
10 if ( ! class_exists( 'ADMINIFY_Field_typography' ) ) {
11 class ADMINIFY_Field_typography extends ADMINIFY_Fields {
12
13 public $chosen = false;
14
15 public $value = array();
16
17 public function __construct( $field, $value = '', $unique = '', $where = '', $parent = '' ) {
18 parent::__construct( $field, $value, $unique, $where, $parent );
19 }
20
21 public function render() {
22
23 echo wp_kses_post( $this->field_before() );
24
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 ) );
51
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 }
61
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 );
81
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'];
87
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'] ) .'">';
89
90 echo '<div class="adminify--blocks adminify--blocks-selects">';
91
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' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- returns markup escaped within the method.
98 echo '</div>';
99 }
100
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( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- returns markup escaped within the method.
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 }
122
123 //
124 // Font Style and Extra Style Select
125 if ( ! empty( $args['font_weight'] ) || ! empty( $args['font_style'] ) ) {
126
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'] ) .'" />';
139
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 ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- returns markup escaped within the method.
147 echo '</div>';
148 }
149
150 echo '</div>';
151
152 }
153
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'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- returns markup escaped within the method.
161 echo '</div>';
162 }
163
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( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- returns markup escaped within the method.
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 }
179
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( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- returns markup escaped within the method.
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 }
192
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( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- returns markup escaped within the method.
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 }
206
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( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- returns markup escaped within the method.
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 }
224
225 echo '</div>';
226
227 echo '<div class="adminify--blocks adminify--blocks-inputs">';
228
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 }
240
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 }
252
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 }
264
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 }
276
277 echo '</div>';
278
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 .' />'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- attribute value pre-escaped with esc_attr() where built.
287 echo '</div>';
288 echo '</div>';
289 }
290
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 }
299
300 //
301 // Preview
302 $always_preview = ( $args['preview'] !== 'always' ) ? ' hidden' : '';
303
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 }
310
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'] ) .'" />';
313
314 echo '</div>';
315
316 echo wp_kses_post( $this->field_after() );
317
318 }
319
320 public function create_select( $options, $name, $placeholder = '', $is_multiple = false ) {
321
322 $multiple_name = ( $is_multiple ) ? '[]' : '';
323 $multiple_attr = ( $is_multiple ) ? ' multiple data-multiple="true"' : '';
324 $chosen_rtl = ( $this->chosen && is_rtl() ) ? ' chosen-rtl' : '';
325
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>' : '';
328
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 }
341
342 $output .= '</select>';
343
344 return $output;
345
346 }
347
348 public function enqueue() {
349
350 if ( ! wp_script_is( 'adminify-webfontloader' ) ) {
351
352 ADMINIFY::include_plugin_file( 'fields/typography/google-fonts.php' );
353
354 $webfontloader_url = defined( 'PXLBSADMINIFY_ASSETS' ) ? PXLBSADMINIFY_ASSETS . 'vendors/webfontloader/webfontloader.min.js' : '';
355 wp_enqueue_script( 'adminify-webfontloader', $webfontloader_url, array( 'adminify' ), '1.6.28', true );
356
357 $webfonts = array();
358
359 $customwebfonts = apply_filters( 'adminify_field_typography_customwebfonts', array() );
360
361 if ( ! empty( $customwebfonts ) ) {
362 $webfonts['custom'] = array(
363 'label' => esc_html__( 'Custom Web Fonts', 'adminify' ),
364 'fonts' => $customwebfonts
365 );
366 }
367
368 $webfonts['safe'] = array(
369 'label' => esc_html__( 'Safe Web Fonts', 'adminify' ),
370 'fonts' => apply_filters( 'adminify_field_typography_safewebfonts', array(
371 'Arial',
372 'Arial Black',
373 'Helvetica',
374 'Times New Roman',
375 'Courier New',
376 'Tahoma',
377 'Verdana',
378 'Impact',
379 'Trebuchet MS',
380 'Comic Sans MS',
381 'Lucida Console',
382 'Lucida Sans Unicode',
383 'Georgia, serif',
384 'Palatino Linotype'
385 )
386 ) );
387
388 $webfonts['google'] = array(
389 'label' => esc_html__( 'Google Web Fonts', 'adminify' ),
390 'fonts' => apply_filters( 'adminify_field_typography_googlewebfonts', adminify_get_google_fonts()
391 ) );
392
393 $defaultstyles = apply_filters( 'adminify_field_typography_defaultstyles', array( 'normal', 'italic', '700', '700italic' ) );
394
395 $googlestyles = apply_filters( 'adminify_field_typography_googlestyles', array(
396 '100' => 'Thin 100',
397 '100italic' => 'Thin 100 Italic',
398 '200' => 'Extra-Light 200',
399 '200italic' => 'Extra-Light 200 Italic',
400 '300' => 'Light 300',
401 '300italic' => 'Light 300 Italic',
402 'normal' => 'Normal 400',
403 'italic' => 'Normal 400 Italic',
404 '500' => 'Medium 500',
405 '500italic' => 'Medium 500 Italic',
406 '600' => 'Semi-Bold 600',
407 '600italic' => 'Semi-Bold 600 Italic',
408 '700' => 'Bold 700',
409 '700italic' => 'Bold 700 Italic',
410 '800' => 'Extra-Bold 800',
411 '800italic' => 'Extra-Bold 800 Italic',
412 '900' => 'Black 900',
413 '900italic' => 'Black 900 Italic'
414 ) );
415
416 $webfonts = apply_filters( 'adminify_field_typography_webfonts', $webfonts );
417
418 wp_localize_script( 'adminify', 'adminify_typography_json', array(
419 'webfonts' => $webfonts,
420 'defaultstyles' => $defaultstyles,
421 'googlestyles' => $googlestyles
422 ) );
423
424 }
425
426 }
427
428 public function enqueue_google_fonts( $method = 'enqueue' ) {
429
430 $is_google = false;
431
432 if ( ! empty( $this->value['type'] ) ) {
433 $is_google = ( $this->value['type'] === 'google' ) ? true : false;
434 } else {
435 ADMINIFY::include_plugin_file( 'fields/typography/google-fonts.php' );
436 $is_google = ( array_key_exists( $this->value['font-family'], adminify_get_google_fonts() ) ) ? true : false;
437 }
438
439 if ( $is_google ) {
440
441 // set style
442 $font_family = ( ! empty( $this->value['font-family'] ) ) ? $this->value['font-family'] : '';
443 $font_weight = ( ! empty( $this->value['font-weight'] ) ) ? $this->value['font-weight'] : '';
444 $font_style = ( ! empty( $this->value['font-style'] ) ) ? $this->value['font-style'] : '';
445
446 if ( $font_weight || $font_style ) {
447 $style = $font_weight . $font_style;
448 if ( ! empty( $style ) ) {
449 $style = ( $style === 'normal' ) ? '400' : $style;
450 ADMINIFY::$webfonts[$method][$font_family][$style] = $style;
451 }
452 } else {
453 ADMINIFY::$webfonts[$method][$font_family] = array();
454 }
455
456 // set extra styles
457 if ( ! empty( $this->value['extra-styles'] ) ) {
458 foreach ( $this->value['extra-styles'] as $extra_style ) {
459 if ( ! empty( $extra_style ) ) {
460 $extra_style = ( $extra_style === 'normal' ) ? '400' : $extra_style;
461 ADMINIFY::$webfonts[$method][$font_family][$extra_style] = $extra_style;
462 }
463 }
464 }
465
466 // set subsets
467 if ( ! empty( $this->value['subset'] ) ) {
468 $this->value['subset'] = ( is_array( $this->value['subset'] ) ) ? $this->value['subset'] : array_filter( (array) $this->value['subset'] );
469 foreach ( $this->value['subset'] as $subset ) {
470 if( ! empty( $subset ) ) {
471 ADMINIFY::$subsets[$subset] = $subset;
472 }
473 }
474 }
475
476 return true;
477
478 }
479
480 return false;
481
482 }
483
484 public function output() {
485
486 $output = '';
487 $bg_image = array();
488 $important = ( ! empty( $this->field['output_important'] ) ) ? '!important' : '';
489 $element = ( is_array( $this->field['output'] ) ) ? join( ',', $this->field['output'] ) : $this->field['output'];
490
491 $font_family = ( ! empty( $this->value['font-family'] ) ) ? $this->value['font-family'] : '';
492 $backup_family = ( ! empty( $this->value['backup-font-family'] ) ) ? ', '. $this->value['backup-font-family'] : '';
493
494 if ( $font_family ) {
495 $output .= 'font-family:"'. $font_family .'"'. $backup_family . $important .';';
496 }
497
498 // Common font properties
499 $properties = array(
500 'color',
501 'font-weight',
502 'font-style',
503 'font-variant',
504 'text-align',
505 'text-transform',
506 'text-decoration',
507 );
508
509 foreach ( $properties as $property ) {
510 if ( isset( $this->value[$property] ) && $this->value[$property] !== '' ) {
511 $output .= $property .':'. $this->value[$property] . $important .';';
512 }
513 }
514
515 $properties = array(
516 'font-size',
517 'line-height',
518 'letter-spacing',
519 'word-spacing',
520 );
521
522 $unit = ( ! empty( $this->value['unit'] ) ) ? $this->value['unit'] : 'px';
523 $line_height_unit = ( ! empty( $this->value['line_height_unit'] ) ) ? $this->value['line_height_unit'] : $unit;
524
525 foreach ( $properties as $property ) {
526 if ( isset( $this->value[$property] ) && $this->value[$property] !== '' ) {
527 $unit = ( $property === 'line-height' ) ? $line_height_unit : $unit;
528 $output .= $property .':'. $this->value[$property] . $unit . $important .';';
529 }
530 }
531
532 $custom_style = ( ! empty( $this->value['custom-style'] ) ) ? $this->value['custom-style'] : '';
533
534 if ( $output ) {
535 $output = $element .'{'. $output . $custom_style .'}';
536 }
537
538 $this->parent->output_css .= $output;
539
540 return $output;
541
542 }
543
544 }
545 }
546