1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Handles CSS output for font-family. |
4
|
|
|
* |
5
|
|
|
* @package Kirki |
6
|
|
|
* @subpackage Controls |
7
|
|
|
* @copyright Copyright (c) 2017, Aristeides Stathopoulos |
8
|
|
|
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT |
9
|
|
|
* @since 2.2.0 |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Output overrides. |
14
|
|
|
*/ |
15
|
|
|
class Kirki_Output_Property_Font_Family extends Kirki_Output_Property { |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Modifies the value. |
19
|
|
|
* |
20
|
|
|
* @access protected |
21
|
|
|
*/ |
22
|
|
|
protected function process_value() { |
23
|
|
|
|
24
|
|
|
$google_fonts_array = Kirki_Fonts::get_google_fonts(); |
25
|
|
|
$backup_fonts = Kirki_Fonts::get_backup_fonts(); |
26
|
|
|
|
27
|
|
|
$family = $this->value; |
28
|
|
|
$backup = ''; |
29
|
|
|
if ( is_array( $this->value ) && isset( $this->value[0] ) && isset( $this->value[1] ) ) { |
30
|
|
|
$family = $this->value[0]; |
31
|
|
|
$backup = $this->value[1]; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
// Make sure the value is a string. |
35
|
|
|
// If not, then early exit. |
36
|
|
|
if ( ! is_string( $family ) ) { |
37
|
|
|
return; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
// Hack for standard fonts. |
41
|
|
|
$family = str_replace( '"', '"', $family ); |
42
|
|
|
|
43
|
|
|
// Add backup font. |
44
|
|
|
if ( Kirki_Fonts::is_google_font( $family ) ) { |
45
|
|
|
|
46
|
|
|
if ( '' === $backup && isset( $google_fonts_array[ $family ] ) && isset( $backup_fonts[ $google_fonts_array[ $family ]['category'] ] ) ) { |
47
|
|
|
$backup = $backup_fonts[ $google_fonts_array[ $family ]['category'] ]; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
// Add double quotes if needed. |
51
|
|
|
if ( false !== strpos( $family, ' ' ) && false === strpos( $family, '"' ) ) { |
52
|
|
|
$this->value = '"' . $family . '", ' . $backup; |
53
|
|
|
return; |
54
|
|
|
} |
55
|
|
|
$this->value = $family . ', ' . $backup; |
56
|
|
|
return; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
// Add double quotes if needed. |
60
|
|
|
if ( false !== strpos( $family, ' ' ) && false === strpos( $family, '"' ) ) { |
61
|
|
|
$this->value = '"' . $family . '"'; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|