Kirki - Version 3.0.22

Version Description

December 20 2017, dev time: 3.5 hours.

  • Fix: Files cleanup. Removed webfonts.php and now use the json file.
  • Fix: WordPress Coding Standards fixes.
  • New: Converted all filter names to use _ instead of / (WPCS)
  • New: Removed inline methods for webfonts and now use typekit/webfontloader.
  • New: Update GoogleFonts list.
Download this release

Release Info

Developer aristath
Plugin Icon 128x128 Kirki
Version 3.0.22
Comparing to
See all releases

Code changes from version 3.0.21 to 3.0.22

Files changed (58) hide show
  1. class-kirki-autoload.php +4 -4
  2. controls/php/class-kirki-control-color.php +2 -2
  3. controls/php/class-kirki-control-dimensions.php +26 -26
  4. controls/php/class-kirki-control-fontawesome.php +1 -1
  5. controls/php/class-kirki-control-repeater.php +6 -6
  6. controls/php/class-kirki-control-select.php +1 -1
  7. controls/php/class-kirki-control-typography.php +8 -8
  8. controls/views/code.php +1 -0
  9. controls/views/color.php +1 -0
  10. controls/views/generic.php +1 -0
  11. controls/views/radio.php +1 -0
  12. controls/views/select.php +1 -0
  13. controls/views/textarea.php +1 -0
  14. core/class-kirki-config.php +21 -5
  15. core/class-kirki-control.php +2 -2
  16. core/class-kirki-field.php +2 -2
  17. core/class-kirki-helper.php +10 -5
  18. core/class-kirki-init.php +8 -8
  19. core/class-kirki-l10n.php +1 -1
  20. core/class-kirki-modules.php +2 -4
  21. core/class-kirki-panel.php +1 -1
  22. core/class-kirki-sanitize-values.php +0 -15
  23. core/class-kirki-section.php +2 -2
  24. core/class-kirki-settings.php +4 -4
  25. core/class-kirki-util.php +2 -2
  26. core/class-kirki-values.php +8 -8
  27. core/class-kirki.php +3 -3
  28. core/dynamic-css.php +1 -1
  29. deprecated/classes.php +20 -0
  30. deprecated/deprecated.php +19 -0
  31. deprecated/filters.php +108 -0
  32. core/deprecated.php → deprecated/functions.php +0 -30
  33. field/class-kirki-field-repeater.php +1 -1
  34. field/class-kirki-field-select.php +1 -1
  35. field/class-kirki-field-spacing.php +1 -1
  36. field/class-kirki-field-typography.php +2 -2
  37. kirki.php +7 -7
  38. modules/collapsible/class-kirki-modules-collapsible.php +1 -1
  39. modules/css/class-kirki-css-to-file.php +2 -2
  40. modules/css/class-kirki-modules-css-generator.php +9 -9
  41. modules/css/class-kirki-modules-css.php +5 -5
  42. modules/css/class-kirki-output.php +6 -5
  43. modules/css/field/class-kirki-output-field-typography.php +4 -4
  44. modules/custom-sections/class-kirki-modules-custom-sections.php +4 -4
  45. modules/customizer-branding/class-kirki-modules-customizer-branding.php +1 -1
  46. modules/customizer-styling/class-kirki-modules-customizer-styling.php +2 -2
  47. modules/loading/class-kirki-modules-loading.php +2 -2
  48. modules/post-meta/class-kirki-modules-post-meta.php +1 -1
  49. modules/postmessage/class-kirki-modules-postmessage.php +15 -14
  50. modules/webfonts/class-kirki-fonts-google.php +2 -2
  51. modules/webfonts/class-kirki-fonts.php +13 -10
  52. modules/webfonts/class-kirki-modules-webfonts-async.php +1 -1
  53. modules/webfonts/class-kirki-modules-webfonts-embed.php +0 -175
  54. modules/webfonts/class-kirki-modules-webfonts-link.php +0 -150
  55. modules/webfonts/class-kirki-modules-webfonts.php +8 -3
  56. modules/webfonts/webfonts.json +1 -1
  57. modules/webfonts/webfonts.php +0 -5
  58. readme.txt +11 -1
class-kirki-autoload.php CHANGED
@@ -90,8 +90,8 @@ class Kirki_Autoload {
90
91
// Handle modules loading.
92
if ( isset( $name_parts[0] ) && 'Modules' === $name_parts[0] ) {
93
- $path = dirname( __FILE__ ) . '/modules/';
94
- $path .= strtolower( str_replace( '_', '-', str_replace( 'Kirki_Modules_', '', $class_name ) ) ) . '/';
95
$paths[] = $path . $filename;
96
}
97
@@ -99,7 +99,7 @@ class Kirki_Autoload {
99
100
// Handle controls loading.
101
if ( 'Control' === $name_parts[0] || 'Settings' === $name_parts[0] ) {
102
- $path = dirname( __FILE__ ) . '/controls/php/';
103
$paths[] = $path . $filename;
104
}
105
}
@@ -113,7 +113,7 @@ class Kirki_Autoload {
113
114
$previous_path = '';
115
for ( $i = 0; $i < $levels; $i++ ) {
116
- $paths[] = dirname( __FILE__ ) . '/' . $previous_path . strtolower( $exploded[ $i ] ) . '/' . $filename;
117
$previous_path .= strtolower( $exploded[ $i ] ) . '/';
118
}
119
return $paths;
90
91
// Handle modules loading.
92
if ( isset( $name_parts[0] ) && 'Modules' === $name_parts[0] ) {
93
+ $path = dirname( __FILE__ ) . '/modules/';
94
+ $path .= strtolower( str_replace( '_', '-', str_replace( 'Kirki_Modules_', '', $class_name ) ) ) . '/';
95
$paths[] = $path . $filename;
96
}
97
99
100
// Handle controls loading.
101
if ( 'Control' === $name_parts[0] || 'Settings' === $name_parts[0] ) {
102
+ $path = dirname( __FILE__ ) . '/controls/php/';
103
$paths[] = $path . $filename;
104
}
105
}
113
114
$previous_path = '';
115
for ( $i = 0; $i < $levels; $i++ ) {
116
+ $paths[] = dirname( __FILE__ ) . '/' . $previous_path . strtolower( $exploded[ $i ] ) . '/' . $filename;
117
$previous_path .= strtolower( $exploded[ $i ] ) . '/';
118
}
119
return $paths;
controls/php/class-kirki-control-color.php CHANGED
@@ -53,8 +53,8 @@ class Kirki_Control_Color extends Kirki_Control_Base {
53
public function to_json() {
54
parent::to_json();
55
56
- $this->json['palette'] = $this->palette;
57
$this->json['choices']['alpha'] = ( isset( $this->choices['alpha'] ) && $this->choices['alpha'] ) ? 'true' : 'false';
58
- $this->json['mode'] = $this->mode;
59
}
60
}
53
public function to_json() {
54
parent::to_json();
55
56
+ $this->json['palette'] = $this->palette;
57
$this->json['choices']['alpha'] = ( isset( $this->choices['alpha'] ) && $this->choices['alpha'] ) ? 'true' : 'false';
58
+ $this->json['mode'] = $this->mode;
59
}
60
}
controls/php/class-kirki-control-dimensions.php CHANGED
@@ -112,32 +112,32 @@ class Kirki_Control_Dimensions extends Kirki_Control_Base {
112
*/
113
protected function l10n() {
114
return array(
115
- 'left-top' => esc_attr__( 'Left Top', 'kirki' ),
116
- 'left-center' => esc_attr__( 'Left Center', 'kirki' ),
117
- 'left-bottom' => esc_attr__( 'Left Bottom', 'kirki' ),
118
- 'right-top' => esc_attr__( 'Right Top', 'kirki' ),
119
- 'right-center' => esc_attr__( 'Right Center', 'kirki' ),
120
- 'right-bottom' => esc_attr__( 'Right Bottom', 'kirki' ),
121
- 'center-top' => esc_attr__( 'Center Top', 'kirki' ),
122
- 'center-center' => esc_attr__( 'Center Center', 'kirki' ),
123
- 'center-bottom' => esc_attr__( 'Center Bottom', 'kirki' ),
124
- 'font-size' => esc_attr__( 'Font Size', 'kirki' ),
125
- 'font-weight' => esc_attr__( 'Font Weight', 'kirki' ),
126
- 'line-height' => esc_attr__( 'Line Height', 'kirki' ),
127
- 'font-style' => esc_attr__( 'Font Style', 'kirki' ),
128
- 'letter-spacing' => esc_attr__( 'Letter Spacing', 'kirki' ),
129
- 'word-spacing' => esc_attr__( 'Word Spacing', 'kirki' ),
130
- 'top' => esc_attr__( 'Top', 'kirki' ),
131
- 'bottom' => esc_attr__( 'Bottom', 'kirki' ),
132
- 'left' => esc_attr__( 'Left', 'kirki' ),
133
- 'right' => esc_attr__( 'Right', 'kirki' ),
134
- 'center' => esc_attr__( 'Center', 'kirki' ),
135
- 'size' => esc_attr__( 'Size', 'kirki' ),
136
- 'height' => esc_attr__( 'Height', 'kirki' ),
137
- 'spacing' => esc_attr__( 'Spacing', 'kirki' ),
138
- 'width' => esc_attr__( 'Width', 'kirki' ),
139
- 'height' => esc_attr__( 'Height', 'kirki' ),
140
- 'invalid-value' => esc_attr__( 'Invalid Value', 'kirki' ),
141
);
142
}
143
}
112
*/
113
protected function l10n() {
114
return array(
115
+ 'left-top' => esc_attr__( 'Left Top', 'kirki' ),
116
+ 'left-center' => esc_attr__( 'Left Center', 'kirki' ),
117
+ 'left-bottom' => esc_attr__( 'Left Bottom', 'kirki' ),
118
+ 'right-top' => esc_attr__( 'Right Top', 'kirki' ),
119
+ 'right-center' => esc_attr__( 'Right Center', 'kirki' ),
120
+ 'right-bottom' => esc_attr__( 'Right Bottom', 'kirki' ),
121
+ 'center-top' => esc_attr__( 'Center Top', 'kirki' ),
122
+ 'center-center' => esc_attr__( 'Center Center', 'kirki' ),
123
+ 'center-bottom' => esc_attr__( 'Center Bottom', 'kirki' ),
124
+ 'font-size' => esc_attr__( 'Font Size', 'kirki' ),
125
+ 'font-weight' => esc_attr__( 'Font Weight', 'kirki' ),
126
+ 'line-height' => esc_attr__( 'Line Height', 'kirki' ),
127
+ 'font-style' => esc_attr__( 'Font Style', 'kirki' ),
128
+ 'letter-spacing' => esc_attr__( 'Letter Spacing', 'kirki' ),
129
+ 'word-spacing' => esc_attr__( 'Word Spacing', 'kirki' ),
130
+ 'top' => esc_attr__( 'Top', 'kirki' ),
131
+ 'bottom' => esc_attr__( 'Bottom', 'kirki' ),
132
+ 'left' => esc_attr__( 'Left', 'kirki' ),
133
+ 'right' => esc_attr__( 'Right', 'kirki' ),
134
+ 'center' => esc_attr__( 'Center', 'kirki' ),
135
+ 'size' => esc_attr__( 'Size', 'kirki' ),
136
+ 'height' => esc_attr__( 'Height', 'kirki' ),
137
+ 'spacing' => esc_attr__( 'Spacing', 'kirki' ),
138
+ 'width' => esc_attr__( 'Width', 'kirki' ),
139
+ 'height' => esc_attr__( 'Height', 'kirki' ),
140
+ 'invalid-value' => esc_attr__( 'Invalid Value', 'kirki' ),
141
);
142
}
143
}
controls/php/class-kirki-control-fontawesome.php CHANGED
@@ -39,7 +39,7 @@ class Kirki_Control_FontAwesome extends Kirki_Control_Base {
39
40
ob_start();
41
$json_path = wp_normalize_path( Kirki::$path . '/assets/vendor/fontawesome/fontawesome.json' );
42
- include( $json_path );
43
$font_awesome_json = ob_get_clean();
44
45
wp_localize_script( 'kirki-script', 'fontAwesomeJSON', $font_awesome_json );
39
40
ob_start();
41
$json_path = wp_normalize_path( Kirki::$path . '/assets/vendor/fontawesome/fontawesome.json' );
42
+ include $json_path;
43
$font_awesome_json = ob_get_clean();
44
45
wp_localize_script( 'kirki-script', 'fontAwesomeJSON', $font_awesome_json );
controls/php/class-kirki-control-repeater.php CHANGED
@@ -66,7 +66,7 @@ class Kirki_Control_Repeater extends Kirki_Control_Base {
66
67
// Set up defaults for row labels.
68
$this->row_label = array(
69
- 'type' => 'text',
70
'value' => esc_attr__( 'row', 'kirki' ),
71
'field' => false,
72
);
@@ -93,7 +93,7 @@ class Kirki_Control_Repeater extends Kirki_Control_Base {
93
if ( ! isset( $value['label'] ) ) {
94
$args['fields'][ $key ]['label'] = '';
95
}
96
- $args['fields'][ $key ]['id'] = $key;
97
98
// We check if the filed is an uploaded media ( image , file, video, etc.. ).
99
if ( isset( $value['type'] ) ) {
@@ -161,8 +161,8 @@ class Kirki_Control_Repeater extends Kirki_Control_Base {
161
162
// 'id' is needed for form hidden value, URL is needed to display the image.
163
$value = array(
164
- 'id' => $attachment_id,
165
- 'url' => $url,
166
'filename' => $filename,
167
);
168
}
@@ -184,14 +184,14 @@ class Kirki_Control_Repeater extends Kirki_Control_Base {
184
185
$fields = $this->fields;
186
187
- $this->json['fields'] = $fields;
188
$this->json['row_label'] = $this->row_label;
189
190
// If filtered_value has been set and is not empty we use it instead of the actual value.
191
if ( is_array( $this->filtered_value ) && ! empty( $this->filtered_value ) ) {
192
$this->json['value'] = $this->filtered_value;
193
}
194
- $this->json['value'] = apply_filters( "kirki/controls/repeater/value/{$this->id}", $this->json['value'] );
195
}
196
197
/**
66
67
// Set up defaults for row labels.
68
$this->row_label = array(
69
+ 'type' => 'text',
70
'value' => esc_attr__( 'row', 'kirki' ),
71
'field' => false,
72
);
93
if ( ! isset( $value['label'] ) ) {
94
$args['fields'][ $key ]['label'] = '';
95
}
96
+ $args['fields'][ $key ]['id'] = $key;
97
98
// We check if the filed is an uploaded media ( image , file, video, etc.. ).
99
if ( isset( $value['type'] ) ) {
161
162
// 'id' is needed for form hidden value, URL is needed to display the image.
163
$value = array(
164
+ 'id' => $attachment_id,
165
+ 'url' => $url,
166
'filename' => $filename,
167
);
168
}
184
185
$fields = $this->fields;
186
187
+ $this->json['fields'] = $fields;
188
$this->json['row_label'] = $this->row_label;
189
190
// If filtered_value has been set and is not empty we use it instead of the actual value.
191
if ( is_array( $this->filtered_value ) && ! empty( $this->filtered_value ) ) {
192
$this->json['value'] = $this->filtered_value;
193
}
194
+ $this->json['value'] = apply_filters( "kirki_controls_repeater_value_{$this->id}", $this->json['value'] );
195
}
196
197
/**
controls/php/class-kirki-control-select.php CHANGED
@@ -53,7 +53,7 @@ class Kirki_Control_Select extends Kirki_Control_Base {
53
public function to_json() {
54
parent::to_json();
55
56
- $this->json['multiple'] = $this->multiple;
57
$this->json['placeholder'] = $this->placeholder;
58
}
59
}
53
public function to_json() {
54
parent::to_json();
55
56
+ $this->json['multiple'] = $this->multiple;
57
$this->json['placeholder'] = $this->placeholder;
58
}
59
}
controls/php/class-kirki-control-typography.php CHANGED
@@ -278,7 +278,7 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
278
*/
279
protected function format_variants_array( $variants ) {
280
281
- $all_variants = Kirki_Fonts::get_all_variants();
282
$final_variants = array();
283
foreach ( $variants as $variant ) {
284
if ( is_string( $variant ) ) {
@@ -310,7 +310,7 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
310
}
311
312
$standard_fonts_final = array();
313
- $default_variants = $this->format_variants_array(
314
array(
315
'regular',
316
'italic',
@@ -366,7 +366,7 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
366
foreach ( $variants as $variant ) {
367
if ( array_key_exists( $variant, $all_variants ) ) {
368
$available_variants[] = array(
369
- 'id' => $variant,
370
'label' => $all_variants[ $variant ],
371
);
372
}
@@ -378,7 +378,7 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
378
foreach ( $subsets as $subset ) {
379
if ( array_key_exists( $subset, $all_subsets ) ) {
380
$available_subsets[] = array(
381
- 'id' => $subset,
382
'label' => $all_subsets[ $subset ],
383
);
384
}
@@ -386,10 +386,10 @@ class Kirki_Control_Typography extends Kirki_Control_Base {
386
}
387
388
$google_fonts_final[] = array(
389
- 'family' => $family,
390
- 'label' => $label,
391
- 'variants' => $available_variants,
392
- 'subsets' => $available_subsets,
393
);
394
} // End foreach().
395
return $google_fonts_final;
278
*/
279
protected function format_variants_array( $variants ) {
280
281
+ $all_variants = Kirki_Fonts::get_all_variants();
282
$final_variants = array();
283
foreach ( $variants as $variant ) {
284
if ( is_string( $variant ) ) {
310
}
311
312
$standard_fonts_final = array();
313
+ $default_variants = $this->format_variants_array(
314
array(
315
'regular',
316
'italic',
366
foreach ( $variants as $variant ) {
367
if ( array_key_exists( $variant, $all_variants ) ) {
368
$available_variants[] = array(
369
+ 'id' => $variant,
370
'label' => $all_variants[ $variant ],
371
);
372
}
378
foreach ( $subsets as $subset ) {
379
if ( array_key_exists( $subset, $all_subsets ) ) {
380
$available_subsets[] = array(
381
+ 'id' => $subset,
382
'label' => $all_subsets[ $subset ],
383
);
384
}
386
}
387
388
$google_fonts_final[] = array(
389
+ 'family' => $family,
390
+ 'label' => $label,
391
+ 'variants' => $available_variants,
392
+ 'subsets' => $available_subsets,
393
);
394
} // End foreach().
395
return $google_fonts_final;
controls/views/code.php CHANGED
@@ -8,6 +8,7 @@
8
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT
9
* @since 3.0.17
10
*/
11
?>
12
<#
13
data = _.defaults( data, {
8
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT
9
* @since 3.0.17
10
*/
11
+
12
?>
13
<#
14
data = _.defaults( data, {
controls/views/color.php CHANGED
@@ -8,6 +8,7 @@
8
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT
9
* @since 3.0.17
10
*/
11
?>
12
<#
13
data = _.defaults( data, {
8
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT
9
* @since 3.0.17
10
*/
11
+
12
?>
13
<#
14
data = _.defaults( data, {
controls/views/generic.php CHANGED
@@ -8,6 +8,7 @@
8
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT
9
* @since 3.0.17
10
*/
11
?>
12
<#
13
element = ( data.choices.element ) ? data.choices.element : 'input';
8
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT
9
* @since 3.0.17
10
*/
11
+
12
?>
13
<#
14
element = ( data.choices.element ) ? data.choices.element : 'input';
controls/views/radio.php CHANGED
@@ -8,6 +8,7 @@
8
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT
9
* @since 3.0.17
10
*/
11
?>
12
<# data = _.defaults( data, {
13
choices: {},
8
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT
9
* @since 3.0.17
10
*/
11
+
12
?>
13
<# data = _.defaults( data, {
14
choices: {},
controls/views/select.php CHANGED
@@ -8,6 +8,7 @@
8
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT
9
* @since 3.0.17
10
*/
11
?>
12
<#
13
data = _.defaults( data, {
8
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT
9
* @since 3.0.17
10
*/
11
+
12
?>
13
<#
14
data = _.defaults( data, {
controls/views/textarea.php CHANGED
@@ -8,6 +8,7 @@
8
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT
9
* @since 3.0.17
10
*/
11
?>
12
<#
13
data = _.defaults( data, {
8
* @license http://opensource.org/licenses/https://opensource.org/licenses/MIT
9
* @since 3.0.17
10
*/
11
+
12
?>
13
<#
14
data = _.defaults( data, {
core/class-kirki-config.php CHANGED
@@ -34,10 +34,10 @@ final class Kirki_Config {
34
/**
35
* The configuration ID.
36
*
37
- * @access protected
38
* @var string
39
*/
40
- protected $id = 'global';
41
42
/**
43
* Capability (fields will inherit this).
@@ -94,8 +94,8 @@ final class Kirki_Config {
94
// Skip what we don't need in this context.
95
unset( $defaults['config_final'] );
96
unset( $defaults['instances'] );
97
- // Apply any kirki/config global filters.
98
- $defaults = apply_filters( 'kirki/config', $defaults );
99
// Merge our args with the defaults.
100
$args = wp_parse_args( $args, $defaults );
101
@@ -106,6 +106,7 @@ final class Kirki_Config {
106
$args[ $key ] = $value;
107
}
108
}
109
110
$this->config_final = wp_parse_args(
111
array(
@@ -138,7 +139,6 @@ final class Kirki_Config {
138
* @return Kirki_Config
139
*/
140
public static function get_instance( $id = 'global', $args = array() ) {
141
-
142
$id = trim( esc_attr( $id ) );
143
$id = ( '' === $id ) ? 'global' : $id;
144
@@ -150,6 +150,22 @@ final class Kirki_Config {
150
151
}
152
153
/**
154
* Returns the $config_final property
155
*
34
/**
35
* The configuration ID.
36
*
37
+ * @access public
38
* @var string
39
*/
40
+ public $id = 'global';
41
42
/**
43
* Capability (fields will inherit this).
94
// Skip what we don't need in this context.
95
unset( $defaults['config_final'] );
96
unset( $defaults['instances'] );
97
+ // Apply any kirki_config global filters.
98
+ $defaults = apply_filters( 'kirki_config', $defaults );
99
// Merge our args with the defaults.
100
$args = wp_parse_args( $args, $defaults );
101
106
$args[ $key ] = $value;
107
}
108
}
109
+ $this->id = $config_id;
110
111
$this->config_final = wp_parse_args(
112
array(
139
* @return Kirki_Config
140
*/
141
public static function get_instance( $id = 'global', $args = array() ) {
142
$id = trim( esc_attr( $id ) );
143
$id = ( '' === $id ) ? 'global' : $id;
144
150
151
}
152
153
+ /**
154
+ * Get the IDs of all current configs.
155
+ *
156
+ * @static
157
+ * @access public
158
+ * @since 3.0.22
159
+ * @return array
160
+ */
161
+ public static function get_config_ids() {
162
+ $configs = array();
163
+ foreach ( self::$instances as $instance ) {
164
+ $configs[] = $instance->id;
165
+ }
166
+ return array_unique( $configs );
167
+ }
168
+
169
/**
170
* Returns the $config_final property
171
*
core/class-kirki-control.php CHANGED
@@ -90,7 +90,7 @@ class Kirki_Control {
90
91
/**
92
* Sets the $control_types property.
93
- * Makes sure the kirki/control_types filter is applied
94
* and that the defined classes actually exist.
95
* If a defined class does not exist, it is removed.
96
*
@@ -103,7 +103,7 @@ class Kirki_Control {
103
return;
104
}
105
106
- self::$control_types = apply_filters( 'kirki/control_types', array() );
107
108
// Make sure the defined classes actually exist.
109
foreach ( self::$control_types as $key => $classname ) {
90
91
/**
92
* Sets the $control_types property.
93
+ * Makes sure the kirki_control_types filter is applied
94
* and that the defined classes actually exist.
95
* If a defined class does not exist, it is removed.
96
*
103
return;
104
}
105
106
+ self::$control_types = apply_filters( 'kirki_control_types', array() );
107
108
// Make sure the defined classes actually exist.
109
foreach ( self::$control_types as $key => $classname ) {
core/class-kirki-field.php CHANGED
@@ -239,7 +239,7 @@ class Kirki_Field {
239
if ( is_array( $config_id ) && empty( $args ) ) {
240
/* translators: %1$s represents the field ID where the error occurs. %2$s is the URL in the documentation site. */
241
_doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args['settings'] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' );
242
- $args = $config_id;
243
$config_id = 'global';
244
}
245
@@ -641,7 +641,7 @@ class Kirki_Field {
641
protected function set_variables() {
642
643
if ( ! is_array( $this->variables ) ) {
644
- $variable = ( is_string( $this->variables ) && ! empty( $this->variables ) ) ? $this->variables : false;
645
$this->variables = array();
646
if ( $variable && empty( $this->variables ) ) {
647
$this->variables[0]['name'] = $variable;
239
if ( is_array( $config_id ) && empty( $args ) ) {
240
/* translators: %1$s represents the field ID where the error occurs. %2$s is the URL in the documentation site. */
241
_doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args['settings'] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' );
242
+ $args = $config_id;
243
$config_id = 'global';
244
}
245
641
protected function set_variables() {
642
643
if ( ! is_array( $this->variables ) ) {
644
+ $variable = ( is_string( $this->variables ) && ! empty( $this->variables ) ) ? $this->variables : false;
645
$this->variables = array();
646
if ( $variable && empty( $this->variables ) ) {
647
$this->variables[0]['name'] = $variable;
core/class-kirki-helper.php CHANGED
@@ -31,7 +31,8 @@ class Kirki_Helper {
31
*/
32
public static function array_replace_recursive( $array, $array1 ) {
33
if ( function_exists( 'array_replace_recursive' ) ) {
34
- return array_replace_recursive( $array, $array1 );
35
}
36
37
// Handle the arguments, merge one by one.
@@ -84,7 +85,7 @@ class Kirki_Helper {
84
public static function init_filesystem() {
85
global $wp_filesystem;
86
if ( empty( $wp_filesystem ) ) {
87
- require_once( ABSPATH . '/wp-admin/includes/file.php' );
88
WP_Filesystem();
89
}
90
return $wp_filesystem;
@@ -107,7 +108,8 @@ class Kirki_Helper {
107
108
$attachment = wp_cache_get( 'kirki_image_id_' . md5( $url ), null );
109
if ( false === $attachment ) {
110
- $attachment = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid = %s;", $url ) );
111
wp_cache_add( 'kirki_image_id_' . md5( $url ), $attachment, null );
112
}
113
@@ -158,6 +160,7 @@ class Kirki_Helper {
158
}
159
160
// Get the posts.
161
$posts = get_posts( $args );
162
163
// Properly format the array.
@@ -384,7 +387,8 @@ class Kirki_Helper {
384
$return = true;
385
} elseif ( '!==' === $operator && $value1 !== $value2 ) {
386
$return = true;
387
- } elseif ( ( '!=' === $operator || 'not equal' === $operator ) && $value1 != $value2 ) {
388
$return = true;
389
} elseif ( ( '>=' === $operator || 'greater or equal' === $operator || 'equal or greater' === $operator ) && $value2 >= $value1 ) {
390
$return = true;
@@ -405,7 +409,8 @@ class Kirki_Helper {
405
$return = false;
406
}
407
} else {
408
- $return = ( $value1 == $value2 ) ? true : false;
409
}
410
return (bool) $return;
411
}
31
*/
32
public static function array_replace_recursive( $array, $array1 ) {
33
if ( function_exists( 'array_replace_recursive' ) ) {
34
+ // @codingStandardsIgnoreLine PHPCompatibility.PHP.NewFunctions.array_replace_recursiveFound
35
+ return array_replace_recursive( $array, $array1 ); // phpcs:ignore PHPCompatibility.PHP.NewFunctions.array_replace_recursiveFound
36
}
37
38
// Handle the arguments, merge one by one.
85
public static function init_filesystem() {
86
global $wp_filesystem;
87
if ( empty( $wp_filesystem ) ) {
88
+ require_once ABSPATH . '/wp-admin/includes/file.php';
89
WP_Filesystem();
90
}
91
return $wp_filesystem;
108
109
$attachment = wp_cache_get( 'kirki_image_id_' . md5( $url ), null );
110
if ( false === $attachment ) {
111
+ // @codingStandardsIgnoreLine WordPress.VIP.DirectDatabaseQuery.DirectQuery
112
+ $attachment = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid = %s;", $url ) ); // phpcs:ignore WordPress.VIP.DirectDatabaseQuery.DirectQuery
113
wp_cache_add( 'kirki_image_id_' . md5( $url ), $attachment, null );
114
}
115
160
}
161
162
// Get the posts.
163
+ // TODO: WordPress.VIP.RestrictedFunctions.get_posts_get_posts
164
$posts = get_posts( $args );
165
166
// Properly format the array.
387
$return = true;
388
} elseif ( '!==' === $operator && $value1 !== $value2 ) {
389
$return = true;
390
+ // @codingStandardsIgnoreLine WordPress.PHP.StrictComparisons.LooseComparison
391
+ } elseif ( ( '!=' === $operator || 'not equal' === $operator ) && $value1 != $value2 ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
392
$return = true;
393
} elseif ( ( '>=' === $operator || 'greater or equal' === $operator || 'equal or greater' === $operator ) && $value2 >= $value1 ) {
394
$return = true;
409
$return = false;
410
}
411
} else {
412
+ // @codingStandardsIgnoreLine WordPress.PHP.StrictComparisons.LooseComparison
413
+ $return = ( $value1 == $value2 ) ? true : false; // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
414
}
415
return (bool) $return;
416
}
core/class-kirki-init.php CHANGED
@@ -32,7 +32,7 @@ class Kirki_Init {
32
self::set_url();
33
add_action( 'after_setup_theme', array( $this, 'set_url' ) );
34
add_action( 'wp_loaded', array( $this, 'add_to_customizer' ), 1 );
35
- add_filter( 'kirki/control_types', array( $this, 'default_control_types' ) );
36
37
add_action( 'customize_register', array( $this, 'remove_panels' ), 99999 );
38
add_action( 'customize_register', array( $this, 'remove_sections' ), 99999 );
@@ -60,8 +60,8 @@ class Kirki_Init {
60
61
Kirki::$url = str_replace( $content_dir, $content_url, wp_normalize_path( Kirki::$path ) );
62
63
- // Apply the kirki/config filter.
64
- $config = apply_filters( 'kirki/config', array() );
65
if ( isset( $config['url_path'] ) ) {
66
Kirki::$url = $config['url_path'];
67
}
@@ -136,7 +136,7 @@ class Kirki_Init {
136
public function register_control_types() {
137
global $wp_customize;
138
139
- $section_types = apply_filters( 'kirki/section_types', array() );
140
foreach ( $section_types as $section_type ) {
141
$wp_customize->register_section_type( $section_type );
142
}
@@ -149,7 +149,7 @@ class Kirki_Init {
149
}
150
151
$skip_control_types = apply_filters(
152
- 'kirki/control_types/exclude', array(
153
'Kirki_Control_Repeater',
154
'WP_Customize_Control',
155
)
@@ -234,7 +234,7 @@ class Kirki_Init {
234
}
235
236
/**
237
- * Process fields added using the 'kirki/fields' and 'kirki/controls' filter.
238
* These filters are no longer used, this is simply for backwards-compatibility.
239
*
240
* @access private
@@ -242,8 +242,8 @@ class Kirki_Init {
242
*/
243
private function fields_from_filters() {
244
245
- $fields = apply_filters( 'kirki/controls', array() );
246
- $fields = apply_filters( 'kirki/fields', $fields );
247
248
if ( ! empty( $fields ) ) {
249
foreach ( $fields as $field ) {
32
self::set_url();
33
add_action( 'after_setup_theme', array( $this, 'set_url' ) );
34
add_action( 'wp_loaded', array( $this, 'add_to_customizer' ), 1 );
35
+ add_filter( 'kirki_control_types', array( $this, 'default_control_types' ) );
36
37
add_action( 'customize_register', array( $this, 'remove_panels' ), 99999 );
38
add_action( 'customize_register', array( $this, 'remove_sections' ), 99999 );
60
61
Kirki::$url = str_replace( $content_dir, $content_url, wp_normalize_path( Kirki::$path ) );
62
63
+ // Apply the kirki_config filter.
64
+ $config = apply_filters( 'kirki_config', array() );
65
if ( isset( $config['url_path'] ) ) {
66
Kirki::$url = $config['url_path'];
67
}
136
public function register_control_types() {
137
global $wp_customize;
138
139
+ $section_types = apply_filters( 'kirki_section_types', array() );
140
foreach ( $section_types as $section_type ) {
141
$wp_customize->register_section_type( $section_type );
142
}
149
}
150
151
$skip_control_types = apply_filters(
152
+ 'kirki_control_types_exclude', array(
153
'Kirki_Control_Repeater',
154
'WP_Customize_Control',
155
)
234
}
235
236
/**
237
+ * Process fields added using the 'kirki_fields' and 'kirki_controls' filter.
238
* These filters are no longer used, this is simply for backwards-compatibility.
239
*
240
* @access private
242
*/
243
private function fields_from_filters() {
244
245
+ $fields = apply_filters( 'kirki_controls', array() );
246
+ $fields = apply_filters( 'kirki_fields', $fields );
247
248
if ( ! empty( $fields ) ) {
249
foreach ( $fields as $field ) {
core/class-kirki-l10n.php CHANGED
@@ -142,7 +142,7 @@ class Kirki_L10n {
142
if ( '' === $this->theme_textdomain ) {
143
144
// Get the textdomain.
145
- $theme = wp_get_theme();
146
$this->theme_textdomain = $theme->get( 'TextDomain' );
147
148
// If no texdomain was found, use the template folder name.
142
if ( '' === $this->theme_textdomain ) {
143
144
// Get the textdomain.
145
+ $theme = wp_get_theme();
146
$this->theme_textdomain = $theme->get( 'TextDomain' );
147
148
// If no texdomain was found, use the template folder name.
core/class-kirki-modules.php CHANGED
@@ -49,7 +49,7 @@ class Kirki_Modules {
49
}
50
51
/**
52
- * Set the default modules and apply the 'kirki/modules' filter.
53
*
54
* @access private
55
* @since 3.0.0
@@ -57,7 +57,7 @@ class Kirki_Modules {
57
private function default_modules() {
58
59
self::$modules = apply_filters(
60
- 'kirki/modules', array(
61
'css' => 'Kirki_Modules_CSS',
62
'customizer-styling' => 'Kirki_Modules_Customizer_Styling',
63
'icons' => 'Kirki_Modules_Icons',
@@ -65,11 +65,9 @@ class Kirki_Modules {
65
'tooltips' => 'Kirki_Modules_Tooltips',
66
'branding' => 'Kirki_Modules_Customizer_Branding',
67
'postMessage' => 'Kirki_Modules_PostMessage',
68
- // 'post_meta' => 'Kirki_Modules_Post_Meta',
69
'selective-refresh' => 'Kirki_Modules_Selective_Refresh',
70
'field-dependencies' => 'Kirki_Modules_Field_Dependencies',
71
'custom-sections' => 'Kirki_Modules_Custom_Sections',
72
- // 'collapsible' => 'Kirki_Modules_Collapsible',
73
'webfonts' => 'Kirki_Modules_Webfonts',
74
)
75
);
49
}
50
51
/**
52
+ * Set the default modules and apply the 'kirki_modules' filter.
53
*
54
* @access private
55
* @since 3.0.0
57
private function default_modules() {
58
59
self::$modules = apply_filters(
60
+ 'kirki_modules', array(
61
'css' => 'Kirki_Modules_CSS',
62
'customizer-styling' => 'Kirki_Modules_Customizer_Styling',
63
'icons' => 'Kirki_Modules_Icons',
65
'tooltips' => 'Kirki_Modules_Tooltips',
66
'branding' => 'Kirki_Modules_Customizer_Branding',
67
'postMessage' => 'Kirki_Modules_PostMessage',
68
'selective-refresh' => 'Kirki_Modules_Selective_Refresh',
69
'field-dependencies' => 'Kirki_Modules_Field_Dependencies',
70
'custom-sections' => 'Kirki_Modules_Custom_Sections',
71
'webfonts' => 'Kirki_Modules_Webfonts',
72
)
73
);
core/class-kirki-panel.php CHANGED
@@ -33,7 +33,7 @@ class Kirki_Panel {
33
*/
34
public function __construct( $args ) {
35
36
- $this->panel_types = apply_filters( 'kirki/panel_types', $this->panel_types );
37
$this->add_panel( $args );
38
39
}
33
*/
34
public function __construct( $args ) {
35
36
+ $this->panel_types = apply_filters( 'kirki_panel_types', $this->panel_types );
37
$this->add_panel( $args );
38
39
}
core/class-kirki-sanitize-values.php CHANGED
@@ -21,21 +21,6 @@ if ( ! defined( 'ABSPATH' ) ) {
21
*/
22
class Kirki_Sanitize_Values {
23
24
- /**
25
- * Fallback for non-existing methods.
26
- *
27
- * @static
28
- * @access public
29
- * @param string $name The method we're trying to access.
30
- * @param mixed $arguments The arguments the method we're trying to call accepts.
31
- * @return mixed The $arguments provided.
32
- */
33
- public static function __callStatic( $name, $arguments ) {
34
- /* translators: %s represents the method that was called and does not exist. */
35
- _doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Kirki_Sanitize_Values::%s does not exist', 'kirki' ), esc_attr( $name ) ), '3.0.10' );
36
- return $arguments;
37
- }
38
-
39
/**
40
* Checkbox sanitization callback.
41
*
21
*/
22
class Kirki_Sanitize_Values {
23
24
/**
25
* Checkbox sanitization callback.
26
*
core/class-kirki-section.php CHANGED
@@ -31,7 +31,7 @@ class Kirki_Section {
31
*/
32
public function __construct( $args ) {
33
34
- $this->section_types = apply_filters( 'kirki/section_types', $this->section_types );
35
$this->add_section( $args );
36
37
}
@@ -53,7 +53,7 @@ class Kirki_Section {
53
$section_classname = $this->section_types[ $args['type'] ];
54
}
55
if ( isset( $args['type'] ) && 'kirki-outer' === $args['type'] ) {
56
- $args['type'] = 'outer';
57
$section_classname = 'WP_Customize_Section';
58
}
59
31
*/
32
public function __construct( $args ) {
33
34
+ $this->section_types = apply_filters( 'kirki_section_types', $this->section_types );
35
$this->add_section( $args );
36
37
}
53
$section_classname = $this->section_types[ $args['type'] ];
54
}
55
if ( isset( $args['type'] ) && 'kirki-outer' === $args['type'] ) {
56
+ $args['type'] = 'outer';
57
$section_classname = 'WP_Customize_Section';
58
}
59
core/class-kirki-settings.php CHANGED
@@ -84,7 +84,7 @@ class Kirki_Settings {
84
$args['default'] = array();
85
}
86
foreach ( $args['settings'] as $key => $value ) {
87
- $default = ( isset( $defaults[ $key ] ) ) ? $defaults[ $key ] : '';
88
$this->add_setting( $classname, $value, $default, $args['option_type'], $args['capability'], $args['transport'], $args['sanitize_callback'] );
89
}
90
}
@@ -121,15 +121,15 @@ class Kirki_Settings {
121
122
/**
123
* Sets the $this->setting_types property.
124
- * Makes sure the kirki/setting_types filter is applied
125
* and that the defined classes actually exist.
126
* If a defined class does not exist, it is removed.
127
*/
128
final private function set_setting_types() {
129
130
- // Apply the kirki/setting_types filter.
131
$this->setting_types = apply_filters(
132
- 'kirki/setting_types', array(
133
'default' => 'WP_Customize_Setting',
134
'repeater' => 'Kirki_Settings_Repeater_Setting',
135
'user_meta' => 'Kirki_Setting_User_Meta',
84
$args['default'] = array();
85
}
86
foreach ( $args['settings'] as $key => $value ) {
87
+ $default = ( isset( $defaults[ $key ] ) ) ? $defaults[ $key ] : '';
88
$this->add_setting( $classname, $value, $default, $args['option_type'], $args['capability'], $args['transport'], $args['sanitize_callback'] );
89
}
90
}
121
122
/**
123
* Sets the $this->setting_types property.
124
+ * Makes sure the kirki_setting_types filter is applied
125
* and that the defined classes actually exist.
126
* If a defined class does not exist, it is removed.
127
*/
128
final private function set_setting_types() {
129
130
+ // Apply the kirki_setting_types filter.
131
$this->setting_types = apply_filters(
132
+ 'kirki_setting_types', array(
133
'default' => 'WP_Customize_Setting',
134
'repeater' => 'Kirki_Settings_Repeater_Setting',
135
'user_meta' => 'Kirki_Setting_User_Meta',
core/class-kirki-util.php CHANGED
@@ -108,8 +108,8 @@ class Kirki_Util {
108
}
109
}
110
111
- // Pass the variables through a filter ('kirki/variable') and return the array of variables.
112
- return apply_filters( 'kirki/variable', $variables );
113
114
}
115
108
}
109
}
110
111
+ // Pass the variables through a filter ('kirki_variable') and return the array of variables.
112
+ return apply_filters( 'kirki_variable', $variables );
113
114
}
115
core/class-kirki-values.php CHANGED
@@ -26,7 +26,7 @@ class Kirki_Values {
26
*/
27
public function __construct() {
28
29
- add_filter( 'kirki/values/get_value', array( $this, 'typography_field_tweaks' ), 10, 2 );
30
}
31
32
/**
@@ -95,7 +95,7 @@ class Kirki_Values {
95
$default_value = Kirki::$fields[ $field_id ]['default'];
96
}
97
$value = get_theme_mod( $field_id, $default_value );
98
- return apply_filters( 'kirki/values/get_value', $value, $field_id );
99
}
100
101
if ( 'option' === Kirki::$config[ $config_id ]['option_type'] ) {
@@ -113,18 +113,18 @@ class Kirki_Values {
113
$setting_modified = str_replace( ']', '', str_replace( Kirki::$config[ $config_id ]['option_name'] . '[', '', $field_id ) );
114
115
$default_value = ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ]['default'] ) ) ? Kirki::$fields[ $field_id ]['default'] : '';
116
- $value = ( isset( $options[ $setting_modified ] ) ) ? $options[ $setting_modified ] : $default_value;
117
- $value = maybe_unserialize( $value );
118
- return apply_filters( 'kirki/values/get_value', $value, $field_id );
119
}
120
121
// Each option separately saved in the db.
122
$value = get_option( $field_id, Kirki::$fields[ $field_id ]['default'] );
123
- return apply_filters( 'kirki/values/get_value', $value, $field_id );
124
125
} // End if().
126
127
- return apply_filters( 'kirki/values/get_value', $value, $field_id );
128
129
}
130
@@ -142,7 +142,7 @@ class Kirki_Values {
142
$value = get_theme_mod( $field['settings'], $field['default'] );
143
} elseif ( isset( $field['option_type'] ) && 'option' === $field['option_type'] ) {
144
if ( isset( $field['option_name'] ) && '' !== $field['option_name'] ) {
145
- $all_values = get_option( $field['option_name'], array() );
146
$sub_setting_id = str_replace( array( ']', $field['option_name'] . '[' ), '', $field['settings'] );
147
if ( isset( $all_values[ $sub_setting_id ] ) ) {
148
$value = $all_values[ $sub_setting_id ];
26
*/
27
public function __construct() {
28
29
+ add_filter( 'kirki_values_get_value', array( $this, 'typography_field_tweaks' ), 10, 2 );
30
}
31
32
/**
95
$default_value = Kirki::$fields[ $field_id ]['default'];
96
}
97
$value = get_theme_mod( $field_id, $default_value );
98
+ return apply_filters( 'kirki_values_get_value', $value, $field_id );
99
}
100
101
if ( 'option' === Kirki::$config[ $config_id ]['option_type'] ) {
113
$setting_modified = str_replace( ']', '', str_replace( Kirki::$config[ $config_id ]['option_name'] . '[', '', $field_id ) );
114
115
$default_value = ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ]['default'] ) ) ? Kirki::$fields[ $field_id ]['default'] : '';
116
+ $value = ( isset( $options[ $setting_modified ] ) ) ? $options[ $setting_modified ] : $default_value;
117
+ $value = maybe_unserialize( $value );
118
+ return apply_filters( 'kirki_values_get_value', $value, $field_id );
119
}
120
121
// Each option separately saved in the db.
122
$value = get_option( $field_id, Kirki::$fields[ $field_id ]['default'] );
123
+ return apply_filters( 'kirki_values_get_value', $value, $field_id );
124
125
} // End if().
126
127
+ return apply_filters( 'kirki_values_get_value', $value, $field_id );
128
129
}
130
142
$value = get_theme_mod( $field['settings'], $field['default'] );
143
} elseif ( isset( $field['option_type'] ) && 'option' === $field['option_type'] ) {
144
if ( isset( $field['option_name'] ) && '' !== $field['option_name'] ) {
145
+ $all_values = get_option( $field['option_name'], array() );
146
$sub_setting_id = str_replace( array( ']', $field['option_name'] . '[' ), '', $field['settings'] );
147
if ( isset( $all_values[ $sub_setting_id ] ) ) {
148
$value = $all_values[ $sub_setting_id ];
core/class-kirki.php CHANGED
@@ -142,8 +142,8 @@ class Kirki extends Kirki_Init {
142
*/
143
public static function add_config( $config_id, $args = array() ) {
144
145
- $config = Kirki_Config::get_instance( $config_id, $args );
146
- $config_args = $config->get_config();
147
self::$config[ $config_args['id'] ] = $config_args;
148
}
149
@@ -233,7 +233,7 @@ class Kirki extends Kirki_Init {
233
return;
234
}
235
236
- $str = str_replace( array( '-', '_' ), ' ', $args['type'] );
237
$classname = 'Kirki_Field_' . str_replace( ' ', '_', ucwords( $str ) );
238
if ( class_exists( $classname ) ) {
239
new $classname( $config_id, $args );
142
*/
143
public static function add_config( $config_id, $args = array() ) {
144
145
+ $config = Kirki_Config::get_instance( $config_id, $args );
146
+ $config_args = $config->get_config();
147
self::$config[ $config_args['id'] ] = $config_args;
148
}
149
233
return;
234
}
235
236
+ $str = str_replace( array( '-', '_' ), ' ', $args['type'] );
237
$classname = 'Kirki_Field_' . str_replace( ' ', '_', ucwords( $str ) );
238
if ( class_exists( $classname ) ) {
239
new $classname( $config_id, $args );
core/dynamic-css.php CHANGED
@@ -25,7 +25,7 @@ foreach ( $configs as $config_id => $args ) {
25
}
26
27
$styles = Kirki_Modules_CSS::loop_controls( $config_id );
28
- $styles = apply_filters( "kirki/{$config_id}/dynamic_css", $styles );
29
30
// Some people put weird stuff in their CSS, KSES tends to be greedy.
31
$styles = str_replace( '<=', '&lt;=', $styles );
25
}
26
27
$styles = Kirki_Modules_CSS::loop_controls( $config_id );
28
+ $styles = apply_filters( "kirki_{$config_id}_dynamic_css", $styles );
29
30
// Some people put weird stuff in their CSS, KSES tends to be greedy.
31
$styles = str_replace( '<=', '&lt;=', $styles );
deprecated/classes.php ADDED
@@ -0,0 +1,20 @@
1
+ <?php
2
+ // @codingStandardsIgnoreFile
3
+
4
+ if ( ! class_exists( 'Kirki_Active_Callback' ) ) {
5
+ // Removed in https://github.com/aristath/kirki/pull/1682/files
6
+ class Kirki_Active_Callback {
7
+ public static function evaluate() {
8
+ _deprecated_function( __METHOD__, '3.0.17', null );
9
+ return true;
10
+ }
11
+ private static function evaluate_requirement() {
12
+ _deprecated_function( __METHOD__, '3.0.17', null );
13
+ return true;
14
+ }
15
+ public static function compare( $value1, $value2, $operator ) {
16
+ _deprecated_function( __METHOD__, '3.0.17', 'Kirki_Helper::compare_values' );
17
+ return Kirki_Helper::compare_values( $value1, $value2, $operator );
18
+ }
19
+ }
20
+ }
deprecated/deprecated.php ADDED
@@ -0,0 +1,19 @@
1
+ <?php
2
+ /**
3
+ * This file contains all the deprecated functions.
4
+ * We could easily delete all these but they are kept for backwards-compatibility purposes.
5
+ *
6
+ * @package Kirki
7
+ * @category Core
8
+ * @author Aristeides Stathopoulos
9
+ * @copyright Copyright (c) 2017, Aristeides Stathopoulos
10
+ * @license http://opensource.org/licenses/https://opensource.org/licenses/MIT
11
+ * @since 1.0
12
+ */
13
+
14
+ require_once wp_normalize_path( dirname( __FILE__ ) . '/functions.php' );
15
+ require_once wp_normalize_path( dirname( __FILE__ ) . '/classes.php' );
16
+ // Filters require PHP 5.3.
17
+ if ( version_compare( PHP_VERSION, '5.3.0' ) >= 0 ) {
18
+ require_once wp_normalize_path( dirname( __FILE__ ) . '/filters.php' );
19
+ }
deprecated/filters.php ADDED
@@ -0,0 +1,108 @@
1
+ <?php
2
+ // @codingStandardsIgnoreFile
3
+
4
+ add_filter( 'kirki_config', function( $args ) {
5
+ return apply_filters( 'kirki/config', $args );
6
+ }, 99 );
7
+
8
+ add_filter( 'kirki_control_types', function( $args ) {
9
+ return apply_filters( 'kirki/control_types', $args );
10
+ }, 99 );
11
+
12
+ add_filter( 'kirki_section_types', function( $args ) {
13
+ return apply_filters( 'kirki/section_types', $args );
14
+ }, 99 );
15
+
16
+ add_filter( 'kirki_section_types_exclude', function( $args ) {
17
+ return apply_filters( 'kirki/section_types/exclude', $args );
18
+ }, 99 );
19
+
20
+ add_filter( 'kirki_control_types_exclude', function( $args ) {
21
+ return apply_filters( 'kirki/control_types/exclude', $args );
22
+ }, 99 );
23
+
24
+ add_filter( 'kirki_controls', function( $args ) {
25
+ return apply_filters( 'kirki/controls', $args );
26
+ }, 99 );
27
+
28
+ add_filter( 'kirki_fields', function( $args ) {
29
+ return apply_filters( 'kirki/fields', $args );
30
+ }, 99 );
31
+
32
+ add_filter( 'kirki_modules', function( $args ) {
33
+ return apply_filters( 'kirki/modules', $args );
34
+ }, 99 );
35
+
36
+ add_filter( 'kirki_panel_types', function( $args ) {
37
+ return apply_filters( 'kirki/panel_types', $args );
38
+ }, 99 );
39
+
40
+ add_filter( 'kirki_setting_types', function( $args ) {
41
+ return apply_filters( 'kirki/setting_types', $args );
42
+ }, 99 );
43
+
44
+ add_filter( 'kirki_variable', function( $args ) {
45
+ return apply_filters( 'kirki/variable', $args );
46
+ }, 99 );
47
+
48
+ add_filter( 'kirki_values_get_value', function( $arg1, $arg2 ) {
49
+ return apply_filters( 'kirki/values/get_value', $arg1, $arg2 );
50
+ }, 99, 2 );
51
+
52
+ add_action( 'init', function() {
53
+ $config_ids = Kirki_Config::get_config_ids();
54
+ global $kirki_deprecated_filters_iteration;
55
+ foreach ( $config_ids as $config_id ) {
56
+ foreach( array(
57
+ '/dynamic_css',
58
+ '/output/control-classnames',
59
+ '/css/skip_hidden',
60
+ '/styles',
61
+ '/output/property-classnames',
62
+ '/webfonts/skip_hidden',
63
+ ) as $filter_suffix ) {
64
+ $kirki_deprecated_filters_iteration = array( $config_id, $filter_suffix );
65
+ add_filter( "kirki_{$config_id}_{$filter_suffix}", function( $args ) {
66
+ global $kirki_deprecated_filters_iteration;
67
+ $kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] );
68
+ return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[0]}/{$kirki_deprecated_filters_iteration[1]}", $args );
69
+ }, 99 );
70
+ }
71
+ }
72
+ }, 99 );
73
+
74
+ add_filter( 'kirki_enqueue_google_fonts', function( $args ) {
75
+ return apply_filters( 'kirki/enqueue_google_fonts', $args );
76
+ }, 99 );
77
+
78
+ add_filter( 'kirki_styles_array', function( $args ) {
79
+ return apply_filters( 'kirki/styles_array', $args );
80
+ }, 99 );
81
+
82
+ add_filter( 'kirki_dynamic_css_method', function( $args ) {
83
+ return apply_filters( 'kirki/dynamic_css/method', $args );
84
+ }, 99 );
85
+
86
+ add_filter( 'kirki_postmessage_script', function( $args ) {
87
+ return apply_filters( 'kirki/postmessage/script', $args );
88
+ }, 99 );
89
+
90
+ add_filter( 'kirki_fonts_all', function( $args ) {
91
+ return apply_filters( 'kirki/fonts/all', $args );
92
+ }, 99 );
93
+
94
+ add_filter( 'kirki_fonts_standard_fonts', function( $args ) {
95
+ return apply_filters( 'kirki/fonts/standard_fonts', $args );
96
+ }, 99 );
97
+
98
+ add_filter( 'kirki_fonts_backup_fonts', function( $args ) {
99
+ return apply_filters( 'kirki/fonts/backup_fonts', $args );
100
+ }, 99 );
101
+
102
+ add_filter( 'kirki_fonts_google_fonts', function( $args ) {
103
+ return apply_filters( 'kirki/fonts/google_fonts', $args );
104
+ }, 99 );
105
+
106
+ add_filter( 'kirki_googlefonts_load_method', function( $args ) {
107
+ return apply_filters( 'kirki/googlefonts_load_method', $args );
108
+ }, 99 );
core/deprecated.php → deprecated/functions.php RENAMED
@@ -1,16 +1,4 @@
1
<?php
2
- /**
3
- * This file contains all the deprecated functions.
4
- * We could easily delete all these but they are kept for backwards-compatibility purposes.
5
- *
6
- * @package Kirki
7
- * @category Core
8
- * @author Aristeides Stathopoulos
9
- * @copyright Copyright (c) 2017, Aristeides Stathopoulos
10
- * @license http://opensource.org/licenses/https://opensource.org/licenses/MIT
11
- * @since 1.0
12
- */
13
-
14
// @codingStandardsIgnoreFile
15
16
// Exit if accessed directly.
@@ -66,21 +54,3 @@ if ( ! function_exists( 'Kirki' ) ) {
66
return kirki();
67
}
68
}
69
-
70
- if ( ! class_exists( 'Kirki_Active_Callback' ) ) {
71
- // Removed in https://github.com/aristath/kirki/pull/1682/files
72
- class Kirki_Active_Callback {
73
- public static function evaluate() {
74
- _deprecated_function( __METHOD__, '3.0.17', null );
75
- return true;
76
- }
77
- private static function evaluate_requirement() {
78
- _deprecated_function( __METHOD__, '3.0.17', null );
79
- return true;
80
- }
81
- public static function compare( $value1, $value2, $operator ) {
82
- _deprecated_function( __METHOD__, '3.0.17', 'Kirki_Helper::compare_values' );
83
- return Kirki_Helper::compare_values( $value1, $value2, $operator );
84
- }
85
- }
86
- }
1
<?php
2
// @codingStandardsIgnoreFile
3
4
// Exit if accessed directly.
54
return kirki();
55
}
56
}
field/class-kirki-field-repeater.php CHANGED
@@ -122,7 +122,7 @@ class Kirki_Field_Repeater extends Kirki_Field {
122
break;
123
case 'color':
124
// Instantiate the object.
125
- $color_obj = ariColor::newColor( $subfield_value );
126
$subfield_value = $color_obj->toCSS( $color_obj->mode );
127
break;
128
case 'text':
122
break;
123
case 'color':
124
// Instantiate the object.
125
+ $color_obj = ariColor::newColor( $subfield_value );
126
$subfield_value = $color_obj->toCSS( $color_obj->mode );
127
break;
128
case 'text':
field/class-kirki-field-select.php CHANGED
@@ -93,7 +93,7 @@ class Kirki_Field_Select extends Kirki_Field {
93
if ( is_array( $value ) ) {
94
foreach ( $value as $key => $subvalue ) {
95
if ( '' !== $subvalue || isset( $this->choices[''] ) ) {
96
- $key = sanitize_key( $key );
97
$value[ $key ] = esc_attr( $subvalue );
98
}
99
}
93
if ( is_array( $value ) ) {
94
foreach ( $value as $key => $subvalue ) {
95
if ( '' !== $subvalue || isset( $this->choices[''] ) ) {
96
+ $key = sanitize_key( $key );
97
$value[ $key ] = esc_attr( $subvalue );
98
}
99
}
field/class-kirki-field-spacing.php CHANGED
@@ -73,7 +73,7 @@ class Kirki_Field_Spacing extends Kirki_Field_Number {
73
'left' => ( isset( $this->default['top'] ) ),
74
'right' => ( isset( $this->default['top'] ) ),
75
),
76
- 'labels' => array(
77
'top' => esc_attr__( 'Top', 'kirki' ),
78
'bottom' => esc_attr__( 'Bottom', 'kirki' ),
79
'left' => esc_attr__( 'Left', 'kirki' ),
73
'left' => ( isset( $this->default['top'] ) ),
74
'right' => ( isset( $this->default['top'] ) ),
75
),
76
+ 'labels' => array(
77
'top' => esc_attr__( 'Top', 'kirki' ),
78
'bottom' => esc_attr__( 'Bottom', 'kirki' ),
79
'left' => esc_attr__( 'Left', 'kirki' ),
field/class-kirki-field-typography.php CHANGED
@@ -181,8 +181,8 @@ class Kirki_Field_Typography extends Kirki_Field {
181
}
182
unset( $value['subset'] );
183
// Make sure we're using a valid subset.
184
- $valid_subsets = Kirki_Fonts::get_google_font_subsets();
185
- $subsets_ok = array();
186
$value['subsets'] = (array) $value['subsets'];
187
foreach ( $value['subsets'] as $subset ) {
188
if ( array_key_exists( $subset, $valid_subsets ) ) {
181
}
182
unset( $value['subset'] );
183
// Make sure we're using a valid subset.
184
+ $valid_subsets = Kirki_Fonts::get_google_font_subsets();
185
+ $subsets_ok = array();
186
$value['subsets'] = (array) $value['subsets'];
187
foreach ( $value['subsets'] as $subset ) {
188
if ( array_key_exists( $subset, $valid_subsets ) ) {
kirki.php CHANGED
@@ -5,7 +5,7 @@
5
* Description: The ultimate WordPress Customizer Toolkit
6
* Author: Aristeides Stathopoulos
7
* Author URI: http://aristath.github.io
8
- * Version: 3.0.21
9
* Text Domain: kirki
10
*
11
* GitHub Plugin URI: aristath/kirki
@@ -30,7 +30,7 @@ if ( class_exists( 'Kirki' ) ) {
30
}
31
32
// Include the autoloader.
33
- include_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'class-kirki-autoload.php';
34
new Kirki_Autoload();
35
36
if ( ! defined( 'KIRKI_PLUGIN_FILE' ) ) {
@@ -42,7 +42,7 @@ if ( ! defined( 'KIRKI_VERSION' ) ) {
42
if ( ! function_exists( 'get_plugin_data' ) ) {
43
include_once ABSPATH . 'wp-admin/includes/plugin.php';
44
}
45
- $data = get_plugin_data( KIRKI_PLUGIN_FILE );
46
$version = ( isset( $data['Version'] ) ) ? $data['Version'] : false;
47
define( 'KIRKI_VERSION', $version );
48
}
@@ -77,10 +77,10 @@ new Kirki();
77
new Kirki_L10n();
78
79
// Include deprecated functions & methods.
80
- include_once wp_normalize_path( dirname( __FILE__ ) . '/core/deprecated.php' );
81
82
// Include the ariColor library.
83
- include_once wp_normalize_path( dirname( __FILE__ ) . '/lib/class-aricolor.php' );
84
85
// Add an empty config for global fields.
86
Kirki::add_config( '' );
@@ -88,11 +88,11 @@ Kirki::add_config( '' );
88
$custom_config_path = dirname( __FILE__ ) . '/custom-config.php';
89
$custom_config_path = wp_normalize_path( $custom_config_path );
90
if ( file_exists( $custom_config_path ) ) {
91
- include_once $custom_config_path;
92
}
93
94
// Add upgrade notifications.
95
- include_once wp_normalize_path( dirname( __FILE__ ) . '/upgrade-notifications.php' );
96
97
/**
98
* To enable tests, add this line to your wp-config.php file (or anywhere alse):
5
* Description: The ultimate WordPress Customizer Toolkit
6
* Author: Aristeides Stathopoulos
7
* Author URI: http://aristath.github.io
8
+ * Version: 3.0.22
9
* Text Domain: kirki
10
*
11
* GitHub Plugin URI: aristath/kirki
30
}
31
32
// Include the autoloader.
33
+ require_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'class-kirki-autoload.php';
34
new Kirki_Autoload();
35
36
if ( ! defined( 'KIRKI_PLUGIN_FILE' ) ) {
42
if ( ! function_exists( 'get_plugin_data' ) ) {
43
include_once ABSPATH . 'wp-admin/includes/plugin.php';
44
}
45
+ $data = get_plugin_data( KIRKI_PLUGIN_FILE );
46
$version = ( isset( $data['Version'] ) ) ? $data['Version'] : false;
47
define( 'KIRKI_VERSION', $version );
48
}
77
new Kirki_L10n();
78
79
// Include deprecated functions & methods.
80
+ require_once wp_normalize_path( dirname( __FILE__ ) . '/deprecated/deprecated.php' );
81
82
// Include the ariColor library.
83
+ require_once wp_normalize_path( dirname( __FILE__ ) . '/lib/class-aricolor.php' );
84
85
// Add an empty config for global fields.
86
Kirki::add_config( '' );
88
$custom_config_path = dirname( __FILE__ ) . '/custom-config.php';
89
$custom_config_path = wp_normalize_path( $custom_config_path );
90
if ( file_exists( $custom_config_path ) ) {
91
+ require_once $custom_config_path;
92
}
93
94
// Add upgrade notifications.
95
+ require_once wp_normalize_path( dirname( __FILE__ ) . '/upgrade-notifications.php' );
96
97
/**
98
* To enable tests, add this line to your wp-config.php file (or anywhere alse):
modules/collapsible/class-kirki-modules-collapsible.php CHANGED
@@ -70,7 +70,7 @@ class Kirki_Modules_Collapsible {
70
wp_enqueue_style( 'kirki-collapsible', trailingslashit( Kirki::$url ) . 'modules/collapsible/collapsible.css', array(), KIRKI_VERSION );
71
72
$collapsible_fields = array();
73
- $fields = Kirki::$fields;
74
foreach ( $fields as $field ) {
75
if ( isset( $field['collapsible'] ) && true === $field['collapsible'] && isset( $field['settings'] ) && isset( $field['label'] ) ) {
76
$collapsible_fields[ $field['settings'] ] = $field['label'];
70
wp_enqueue_style( 'kirki-collapsible', trailingslashit( Kirki::$url ) . 'modules/collapsible/collapsible.css', array(), KIRKI_VERSION );
71
72
$collapsible_fields = array();
73
+ $fields = Kirki::$fields;
74
foreach ( $fields as $field ) {
75
if ( isset( $field['collapsible'] ) && true === $field['collapsible'] && isset( $field['settings'] ) && isset( $field['label'] ) ) {
76
$collapsible_fields[ $field['settings'] ] = $field['label'];
modules/css/class-kirki-css-to-file.php CHANGED
@@ -106,11 +106,11 @@ class Kirki_CSS_To_File {
106
*/
107
public function write_file() {
108
109
- $css = array();
110
$configs = Kirki::$config;
111
foreach ( $configs as $config_id => $args ) {
112
// Get the CSS we want to write.
113
- $css[ $config_id ] = apply_filters( "kirki/{$config_id}/dynamic_css", Kirki_Modules_CSS::loop_controls( $config_id ) );
114
}
115
$css = implode( $css, '' );
116
106
*/
107
public function write_file() {
108
109
+ $css = array();
110
$configs = Kirki::$config;
111
foreach ( $configs as $config_id => $args ) {
112
// Get the CSS we want to write.
113
+ $css[ $config_id ] = apply_filters( "kirki_{$config_id}_dynamic_css", Kirki_Modules_CSS::loop_controls( $config_id ) );
114
}
115
$css = implode( $css, '' );
116
modules/css/class-kirki-modules-css-generator.php CHANGED
@@ -163,13 +163,13 @@ final class Kirki_Modules_CSS_Generator {
163
self::$value = Kirki_Values::get_sanitized_field_value( $field );
164
165
// Find the class that will handle the outpout for this field.
166
- $classname = 'Kirki_Output';
167
- $field_output_classes = apply_filters( "kirki/{$field['kirki_config']}/output/control-classnames", array(
168
- 'kirki-background' => 'Kirki_Output_Field_Background',
169
- 'kirki-dimensions' => 'Kirki_Output_Field_Dimensions',
170
- 'kirki-image' => 'Kirki_Output_Field_Image',
171
- 'kirki-typography' => 'Kirki_Output_Field_Typography',
172
- 'kirki-multicolor' => 'Kirki_Output_Field_Multicolor',
173
) );
174
if ( array_key_exists( self::$field_type, $field_output_classes ) ) {
175
$classname = $field_output_classes[ self::$field_type ];
@@ -189,8 +189,8 @@ final class Kirki_Modules_CSS_Generator {
189
*/
190
public static function styles_parse( $css = array() ) {
191
192
- // Pass our styles from the kirki/styles_array filter.
193
- $css = apply_filters( 'kirki/styles_array', $css );
194
195
// Process the array of CSS properties and produce the final CSS.
196
$final_css = '';
163
self::$value = Kirki_Values::get_sanitized_field_value( $field );
164
165
// Find the class that will handle the outpout for this field.
166
+ $classname = 'Kirki_Output';
167
+ $field_output_classes = apply_filters( "kirki_{$field['kirki_config']}_output_control_classnames", array(
168
+ 'kirki-background' => 'Kirki_Output_Field_Background',
169
+ 'kirki-dimensions' => 'Kirki_Output_Field_Dimensions',
170
+ 'kirki-image' => 'Kirki_Output_Field_Image',
171
+ 'kirki-typography' => 'Kirki_Output_Field_Typography',
172
+ 'kirki-multicolor' => 'Kirki_Output_Field_Multicolor',
173
) );
174
if ( array_key_exists( self::$field_type, $field_output_classes ) ) {
175
$classname = $field_output_classes[ self::$field_type ];
189
*/
190
public static function styles_parse( $css = array() ) {
191
192
+ // Pass our styles from the kirki_styles_array filter.
193
+ $css = apply_filters( 'kirki_styles_array', $css );
194
195
// Process the array of CSS properties and produce the final CSS.
196
$final_css = '';
modules/css/class-kirki-modules-css.php CHANGED
@@ -117,7 +117,7 @@ class Kirki_Modules_CSS {
117
118
global $wp_customize;
119
120
- $config = apply_filters( 'kirki/config', array() );
121
$priority = 999;
122
if ( isset( $config['styles_priority'] ) ) {
123
$priority = absint( $config['styles_priority'] );
@@ -128,7 +128,7 @@ class Kirki_Modules_CSS {
128
return;
129
}
130
131
- $method = apply_filters( 'kirki/dynamic_css/method', 'inline' );
132
if ( $wp_customize ) {
133
// If we're in the customizer, load inline no matter what.
134
add_action( 'wp_enqueue_scripts', array( $this, 'inline_dynamic_css' ), $priority );
@@ -190,7 +190,7 @@ class Kirki_Modules_CSS {
190
continue;
191
}
192
$styles = self::loop_controls( $config_id );
193
- $styles = apply_filters( "kirki/{$config_id}/dynamic_css", $styles );
194
if ( ! empty( $styles ) ) {
195
wp_enqueue_style( 'kirki-styles-' . $config_id, trailingslashit( Kirki::$url ) . 'assets/css/kirki-styles.css', array(), KIRKI_VERSION );
196
wp_add_inline_style( 'kirki-styles-' . $config_id, $styles );
@@ -247,7 +247,7 @@ class Kirki_Modules_CSS {
247
continue;
248
}
249
250
- if ( true === apply_filters( "kirki/{$config_id}/css/skip_hidden", true ) ) {
251
// Only continue if field dependencies are met.
252
if ( ! empty( $field['required'] ) ) {
253
$valid = true;
@@ -278,7 +278,7 @@ class Kirki_Modules_CSS {
278
}
279
}
280
281
- $css = apply_filters( "kirki/{$config_id}/styles", $css );
282
283
if ( is_array( $css ) ) {
284
return Kirki_Modules_CSS_Generator::styles_parse( Kirki_Modules_CSS_Generator::add_prefixes( $css ) );
117
118
global $wp_customize;
119
120
+ $config = apply_filters( 'kirki_config', array() );
121
$priority = 999;
122
if ( isset( $config['styles_priority'] ) ) {
123
$priority = absint( $config['styles_priority'] );
128
return;
129
}
130
131
+ $method = apply_filters( 'kirki_dynamic_css_method', 'inline' );
132
if ( $wp_customize ) {
133
// If we're in the customizer, load inline no matter what.
134
add_action( 'wp_enqueue_scripts', array( $this, 'inline_dynamic_css' ), $priority );
190
continue;
191
}
192
$styles = self::loop_controls( $config_id );
193
+ $styles = apply_filters( "kirki_{$config_id}_dynamic_css", $styles );
194
if ( ! empty( $styles ) ) {
195
wp_enqueue_style( 'kirki-styles-' . $config_id, trailingslashit( Kirki::$url ) . 'assets/css/kirki-styles.css', array(), KIRKI_VERSION );
196
wp_add_inline_style( 'kirki-styles-' . $config_id, $styles );
247
continue;
248
}
249
250
+ if ( true === apply_filters( "kirki_{$config_id}_css_skip_hidden", true ) ) {
251
// Only continue if field dependencies are met.
252
if ( ! empty( $field['required'] ) ) {
253
$valid = true;
278
}
279
}
280
281
+ $css = apply_filters( "kirki_{$config_id}_styles", $css );
282
283
if ( is_array( $css ) ) {
284
return Kirki_Modules_CSS_Generator::styles_parse( Kirki_Modules_CSS_Generator::add_prefixes( $css ) );
modules/css/class-kirki-output.php CHANGED
@@ -149,7 +149,7 @@ class Kirki_Output {
149
case 'option':
150
if ( is_array( $options ) ) {
151
if ( $option_name ) {
152
- $subkey = str_replace( array( $option_name, '[', ']' ), '', $replace );
153
$replacement = ( isset( $options[ $subkey ] ) ) ? $options[ $subkey ] : '';
154
break;
155
}
@@ -174,7 +174,7 @@ class Kirki_Output {
174
$replacement = ( false === $replacement ) ? '' : $replacement;
175
if ( is_array( $value ) ) {
176
foreach ( $value as $k => $v ) {
177
- $_val = ( isset( $value[ $v ] ) ) ? $value[ $v ] : $v;
178
$value[ $k ] = str_replace( $search, $replacement, $_val );
179
}
180
return $value;
@@ -217,7 +217,8 @@ class Kirki_Output {
217
}
218
// If 'choice' is defined check for sub-values too.
219
// Fixes https://github.com/aristath/kirki/issues/1416.
220
- if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) {
221
$skip = true;
222
}
223
}
@@ -296,7 +297,7 @@ class Kirki_Output {
296
*/
297
protected function process_property_value( $property, $value ) {
298
$properties = apply_filters(
299
- "kirki/{$this->config_id}/output/property-classnames", array(
300
'font-family' => 'Kirki_Output_Property_Font_Family',
301
'background-image' => 'Kirki_Output_Property_Background_Image',
302
'background-position' => 'Kirki_Output_Property_Background_Position',
@@ -304,7 +305,7 @@ class Kirki_Output {
304
);
305
if ( array_key_exists( $property, $properties ) ) {
306
$classname = $properties[ $property ];
307
- $obj = new $classname( $property, $value );
308
return $obj->get_value();
309
}
310
return $value;
149
case 'option':
150
if ( is_array( $options ) ) {
151
if ( $option_name ) {
152
+ $subkey = str_replace( array( $option_name, '[', ']' ), '', $replace );
153
$replacement = ( isset( $options[ $subkey ] ) ) ? $options[ $subkey ] : '';
154
break;
155
}
174
$replacement = ( false === $replacement ) ? '' : $replacement;
175
if ( is_array( $value ) ) {
176
foreach ( $value as $k => $v ) {
177
+ $_val = ( isset( $value[ $v ] ) ) ? $value[ $v ] : $v;
178
$value[ $k ] = str_replace( $search, $replacement, $_val );
179
}
180
return $value;
217
}
218
// If 'choice' is defined check for sub-values too.
219
// Fixes https://github.com/aristath/kirki/issues/1416.
220
+ // @codingStandardsIgnoreLine WordPress.PHP.StrictComparisons.LooseComparison
221
+ if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
222
$skip = true;
223
}
224
}
297
*/
298
protected function process_property_value( $property, $value ) {
299
$properties = apply_filters(
300
+ "kirki_{$this->config_id}_output_property-classnames", array(
301
'font-family' => 'Kirki_Output_Property_Font_Family',
302
'background-image' => 'Kirki_Output_Property_Background_Image',
303
'background-position' => 'Kirki_Output_Property_Background_Position',
305
);
306
if ( array_key_exists( $property, $properties ) ) {
307
$classname = $properties[ $property ];
308
+ $obj = new $classname( $property, $value );
309
return $obj->get_value();
310
}
311
return $value;
modules/css/field/class-kirki-output-field-typography.php CHANGED
@@ -63,11 +63,11 @@ class Kirki_Output_Field_Typography extends Kirki_Output {
63
}
64
65
// Take care of variants.
66
- if ( 'variant' == $property && isset( $value['variant'] ) && ! empty( $value['variant'] ) ) {
67
68
// Get the font_weight.
69
$font_weight = str_replace( 'italic', '', $value['variant'] );
70
- $font_weight = ( in_array( $font_weight, array( '', 'regular' ) ) ) ? '400' : $font_weight;
71
72
// Is this italic?
73
$is_italic = ( false !== strpos( $value['variant'], 'italic' ) );
@@ -81,12 +81,12 @@ class Kirki_Output_Field_Typography extends Kirki_Output {
81
$property_value = $this->process_property_value( $property, $value[ $property ] );
82
if ( 'font-family' === $property ) {
83
$value['font-backup'] = ( isset( $value['font-backup'] ) ) ? $value['font-backup'] : '';
84
- $property_value = $this->process_property_value( $property, array(
85
$value['font-family'],
86
$value['font-backup'],
87
) );
88
}
89
- $property = ( isset( $output['choice'] ) && isset( $output['property'] ) ) ? $output['property'] : $property;
90
$property_value = ( is_array( $property_value ) && isset( $property_value[0] ) ) ? $property_value[0] : $property_value;
91
$this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $property_value . $output['suffix'];
92
}
63
}
64
65
// Take care of variants.
66
+ if ( 'variant' === $property && isset( $value['variant'] ) && ! empty( $value['variant'] ) ) {
67
68
// Get the font_weight.
69
$font_weight = str_replace( 'italic', '', $value['variant'] );
70
+ $font_weight = ( in_array( $font_weight, array( '', 'regular' ), true ) ) ? '400' : $font_weight;
71
72
// Is this italic?
73
$is_italic = ( false !== strpos( $value['variant'], 'italic' ) );
81
$property_value = $this->process_property_value( $property, $value[ $property ] );
82
if ( 'font-family' === $property ) {
83
$value['font-backup'] = ( isset( $value['font-backup'] ) ) ? $value['font-backup'] : '';
84
+ $property_value = $this->process_property_value( $property, array(
85
$value['font-family'],
86
$value['font-backup'],
87
) );
88
}
89
+ $property = ( isset( $output['choice'] ) && isset( $output['property'] ) ) ? $output['property'] : $property;
90
$property_value = ( is_array( $property_value ) && isset( $property_value[0] ) ) ? $property_value[0] : $property_value;
91
$this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $property_value . $output['suffix'];
92
}
modules/custom-sections/class-kirki-modules-custom-sections.php CHANGED
@@ -39,9 +39,9 @@ class Kirki_Modules_Custom_Sections {
39
*/
40
protected function __construct() {
41
// Register the new section types.
42
- add_filter( 'kirki/section_types', array( $this, 'set_section_types' ) );
43
// Register the new panel types.
44
- add_filter( 'kirki/panel_types', array( $this, 'set_panel_types' ) );
45
// Include the section-type files.
46
add_action( 'customize_register', array( $this, 'include_sections_and_panels' ) );
47
// Enqueue styles & scripts.
@@ -110,7 +110,7 @@ class Kirki_Modules_Custom_Sections {
110
111
// Sections.
112
$folder_path = dirname( __FILE__ ) . '/sections/';
113
- $section_types = apply_filters( 'kirki/section_types', array() );
114
115
foreach ( $section_types as $id => $class ) {
116
if ( ! class_exists( $class ) ) {
@@ -128,7 +128,7 @@ class Kirki_Modules_Custom_Sections {
128
129
// Panels.
130
$folder_path = dirname( __FILE__ ) . '/panels/';
131
- $panel_types = apply_filters( 'kirki/panel_types', array() );
132
133
foreach ( $panel_types as $id => $class ) {
134
if ( ! class_exists( $class ) ) {
39
*/
40
protected function __construct() {
41
// Register the new section types.
42
+ add_filter( 'kirki_section_types', array( $this, 'set_section_types' ) );
43
// Register the new panel types.
44
+ add_filter( 'kirki_panel_types', array( $this, 'set_panel_types' ) );
45
// Include the section-type files.
46
add_action( 'customize_register', array( $this, 'include_sections_and_panels' ) );
47
// Enqueue styles & scripts.
110
111
// Sections.
112
$folder_path = dirname( __FILE__ ) . '/sections/';
113
+ $section_types = apply_filters( 'kirki_section_types', array() );
114
115
foreach ( $section_types as $id => $class ) {
116
if ( ! class_exists( $class ) ) {
128
129
// Panels.
130
$folder_path = dirname( __FILE__ ) . '/panels/';
131
+ $panel_types = apply_filters( 'kirki_panel_types', array() );
132
133
foreach ( $panel_types as $id => $class ) {
134
if ( ! class_exists( $class ) ) {
modules/customizer-branding/class-kirki-modules-customizer-branding.php CHANGED
@@ -68,7 +68,7 @@ class Kirki_Modules_Customizer_Branding {
68
*/
69
public function customize_controls_print_scripts() {
70
71
- $config = apply_filters( 'kirki/config', array() );
72
$vars = array(
73
'logoImage' => '',
74
'description' => '',
68
*/
69
public function customize_controls_print_scripts() {
70
71
+ $config = apply_filters( 'kirki_config', array() );
72
$vars = array(
73
'logoImage' => '',
74
'description' => '',
modules/customizer-styling/class-kirki-modules-customizer-styling.php CHANGED
@@ -1,7 +1,7 @@
1
<?php
2
/**
3
* Changes the styling of the customizer
4
- * based on the settings set using the kirki/config filter.
5
* For documentation please see
6
* https://github.com/aristath/kirki/wiki/Styling-the-Customizer
7
*
@@ -67,7 +67,7 @@ class Kirki_Modules_Customizer_Styling {
67
*/
68
public function custom_css() {
69
70
- $config = apply_filters( 'kirki/config', array() );
71
if ( ! isset( $config['color_accent'] ) && ! isset( $config['color_back'] ) ) {
72
return;
73
}
1
<?php
2
/**
3
* Changes the styling of the customizer
4
+ * based on the settings set using the kirki_config filter.
5
* For documentation please see
6
* https://github.com/aristath/kirki/wiki/Styling-the-Customizer
7
*
67
*/
68
public function custom_css() {
69
70
+ $config = apply_filters( 'kirki_config', array() );
71
if ( ! isset( $config['color_accent'] ) && ! isset( $config['color_back'] ) ) {
72
return;
73
}
modules/loading/class-kirki-modules-loading.php CHANGED
@@ -61,8 +61,8 @@ class Kirki_Modules_Loading {
61
if ( ! $wp_customize ) {
62
return;
63
}
64
- // Allow disabling the custom loader using the kirki/config filter.
65
- $config = apply_filters( 'kirki/config', array() );
66
if ( isset( $config['disable_loader'] ) && true === $config['disable_loader'] ) {
67
return;
68
}
61
if ( ! $wp_customize ) {
62
return;
63
}
64
+ // Allow disabling the custom loader using the kirki_config filter.
65
+ $config = apply_filters( 'kirki_config', array() );
66
if ( isset( $config['disable_loader'] ) && true === $config['disable_loader'] ) {
67
return;
68
}
modules/post-meta/class-kirki-modules-post-meta.php CHANGED
@@ -83,7 +83,7 @@ class Kirki_Modules_Post_Meta {
83
$wp_scripts = wp_scripts();
84
$queried_post = null;
85
if ( is_singular() && get_queried_object() ) {
86
- $queried_post = get_queried_object();
87
$queried_post->meta = get_post_custom( $queried_post->id );
88
}
89
$wp_scripts->add_data( 'kirki_post_meta_previewed_preview', 'data', sprintf( 'var _customizePostPreviewedQueriedObject = %s;', wp_json_encode( $queried_post ) ) );
83
$wp_scripts = wp_scripts();
84
$queried_post = null;
85
if ( is_singular() && get_queried_object() ) {
86
+ $queried_post = get_queried_object();
87
$queried_post->meta = get_post_custom( $queried_post->id );
88
}
89
$wp_scripts->add_data( 'kirki_post_meta_previewed_preview', 'data', sprintf( 'var _customizePostPreviewedQueriedObject = %s;', wp_json_encode( $queried_post ) ) );
modules/postmessage/class-kirki-modules-postmessage.php CHANGED
@@ -78,7 +78,7 @@ class Kirki_Modules_PostMessage {
78
$this->script .= $this->script( $field );
79
}
80
}
81
- $this->script = apply_filters( 'kirki/postmessage/script', $this->script );
82
wp_add_inline_script( 'kirki_auto_postmessage', $this->script, 'after' );
83
84
}
@@ -106,7 +106,7 @@ class Kirki_Modules_PostMessage {
106
// append unique style tag if not exist
107
// The style ID.
108
$style_id = 'kirki-postmessage-' . str_replace( array( '[', ']' ), '', $args['settings'] );
109
- $script .= 'if(null===document.getElementById(\'' . $style_id . '\')||\'undefined\'===typeof document.getElementById(\'' . $style_id . '\')){jQuery(\'head\').append(\'<style id="' . $style_id . '"></style>\');}';
110
}
111
112
// Add anything we need before the main script.
@@ -121,7 +121,7 @@ class Kirki_Modules_PostMessage {
121
// Skip styles if "exclude" is defined and value is excluded.
122
if ( isset( $js_var['exclude'] ) ) {
123
$js_var['exclude'] = (array) $js_var['exclude'];
124
- $script .= 'exclude=false;';
125
foreach ( $js_var['exclude'] as $exclussion ) {
126
$script .= "if(newval=='{$exclussion}'||(''==='{$exclussion}'&&_.isObject(newval)&&_.isEmpty(newval))){exclude=true;}";
127
}
@@ -139,7 +139,7 @@ class Kirki_Modules_PostMessage {
139
continue;
140
}
141
$js_var['index_key'] = $key;
142
- $callback = $this->get_callback( $args );
143
if ( is_callable( $callback ) ) {
144
$field['scripts'][ $key ] = call_user_func_array( $callback, array( $js_var, $args ) );
145
continue;
@@ -197,10 +197,10 @@ class Kirki_Modules_PostMessage {
197
* @param array $args The arguments for this js_var.
198
*/
199
protected function script_var( $args ) {
200
- $script = '';
201
$property_script = '';
202
203
- $value_key = 'newval' . $args['index_key'];
204
$property_script .= $value_key . '=newval;';
205
206
$args = $this->get_args( $args );
@@ -244,13 +244,13 @@ class Kirki_Modules_PostMessage {
244
*/
245
protected function script_var_array( $args ) {
246
247
- $script = ( 0 === $args['index_key'] ) ? 'css=\'\';' : '';
248
$property_script = '';
249
250
// Define choice.
251
$choice = ( isset( $args['choice'] ) && '' !== $args['choice'] ) ? $args['choice'] : '';
252
253
- $value_key = 'newval' . $args['index_key'];
254
$property_script .= $value_key . '=newval;';
255
256
$args = $this->get_args( $args );
@@ -283,6 +283,7 @@ class Kirki_Modules_PostMessage {
283
// Allows us to apply this just for a specific choice in the array of the values.
284
if ( '' !== $choice ) {
285
$choice_is_direction = ( false !== strpos( $choice, 'top' ) || false !== strpos( $choice, 'bottom' ) || false !== strpos( $choice, 'left' ) || false !== strpos( $choice, 'right' ) );
286
$script .= 'if(\'' . $choice . '\'===subKey){';
287
$script .= ( $choice_is_direction ) ? $direction_script . 'else{' : '';
288
$script .= 'css+=\'' . $args['element'] . '{' . $args['property'] . ':\'+subValue+\';}\';';
@@ -325,7 +326,7 @@ class Kirki_Modules_PostMessage {
325
$webfont_loader = 'sc=\'a\';jQuery(\'head\').append(sc.replace(\'a\',\'<\')+\'script>if(!_.isUndefined(WebFont)&&fontFamily){WebFont.load({google:{families:["\'+fontFamily.replace( /\"/g, \'&quot;\' )+\':\'+variant+subsetsString+\'"]}});}\'+sc.replace(\'a\',\'<\')+\'/script>\');';
326
327
// Add the css.
328
- $css_build_array = array(
329
'font-family' => 'fontFamily',
330
'font-size' => 'fontSize',
331
'line-height' => 'lineHeight',
@@ -339,7 +340,7 @@ class Kirki_Modules_PostMessage {
339
'font-style' => 'fontStyle',
340
);
341
$choice_condition = ( isset( $args['choice'] ) && '' !== $args['choice'] && isset( $css_build_array[ $args['choice'] ] ) );
342
- $script .= ( ! $choice_condition ) ? $webfont_loader : '';
343
foreach ( $css_build_array as $property => $var ) {
344
if ( $choice_condition && $property !== $args['choice'] ) {
345
continue;
@@ -364,9 +365,9 @@ class Kirki_Modules_PostMessage {
364
365
if ( 'font-family' === $property || ( isset( $args['choice'] ) && 'font-family' === $args['choice'] ) ) {
366
$css .= 'fontFamilyCSS=fontFamily;if(0<fontFamily.indexOf(\' \')&&-1===fontFamily.indexOf(\'"\')){fontFamilyCSS=\'"\'+fontFamily+\'"\';}';
367
- $var = 'fontFamilyCSS';
368
}
369
- $var = ( ( empty( $args['prefix'] ) ) ? '' : '\'' . $args['prefix'] . '\'+' ) . $var . ( ( empty( $args['units'] ) ) ? '' : '+\'' . $args['units'] . '\'' ) . ( ( empty( $args['suffix'] ) ) ? '' : '+\'' . $args['suffix'] . '\'' );
370
$css .= 'css+=(\'\'!==' . $var . ')?\'' . $args['element'] . '\'+\'{' . $property . ':\'+' . $var . '+\';}\':\'\';';
371
}
372
@@ -477,8 +478,8 @@ class Kirki_Modules_PostMessage {
477
$script .= 'settings=window.wp.customize.get();';
478
foreach ( $js_vars['pattern_replace'] as $search => $replace ) {
479
$replace = '\'+settings["' . $replace . '"]+\'';
480
- $value = str_replace( $search, $replace, $js_vars['value_pattern'] );
481
- $value = trim( $value, '+' );
482
}
483
}
484
$value_compiled = str_replace( '#x27;, '\'+' . $alias . '+\'', $value );
78
$this->script .= $this->script( $field );
79
}
80
}
81
+ $this->script = apply_filters( 'kirki_postmessage_script', $this->script );
82
wp_add_inline_script( 'kirki_auto_postmessage', $this->script, 'after' );
83
84
}
106
// append unique style tag if not exist
107
// The style ID.
108
$style_id = 'kirki-postmessage-' . str_replace( array( '[', ']' ), '', $args['settings'] );
109
+ $script .= 'if(null===document.getElementById(\'' . $style_id . '\')||\'undefined\'===typeof document.getElementById(\'' . $style_id . '\')){jQuery(\'head\').append(\'<style id="' . $style_id . '"></style>\');}';
110
}
111
112
// Add anything we need before the main script.
121
// Skip styles if "exclude" is defined and value is excluded.
122
if ( isset( $js_var['exclude'] ) ) {
123
$js_var['exclude'] = (array) $js_var['exclude'];
124
+ $script .= 'exclude=false;';
125
foreach ( $js_var['exclude'] as $exclussion ) {
126
$script .= "if(newval=='{$exclussion}'||(''==='{$exclussion}'&&_.isObject(newval)&&_.isEmpty(newval))){exclude=true;}";
127
}
139
continue;
140
}
141
$js_var['index_key'] = $key;
142
+ $callback = $this->get_callback( $args );
143
if ( is_callable( $callback ) ) {
144
$field['scripts'][ $key ] = call_user_func_array( $callback, array( $js_var, $args ) );
145
continue;
197
* @param array $args The arguments for this js_var.
198
*/
199
protected function script_var( $args ) {
200
+ $script = '';
201
$property_script = '';
202
203
+ $value_key = 'newval' . $args['index_key'];
204
$property_script .= $value_key . '=newval;';
205
206
$args = $this->get_args( $args );
244
*/
245
protected function script_var_array( $args ) {
246
247
+ $script = ( 0 === $args['index_key'] ) ? 'css=\'\';' : '';
248
$property_script = '';
249
250
// Define choice.
251
$choice = ( isset( $args['choice'] ) && '' !== $args['choice'] ) ? $args['choice'] : '';
252
253
+ $value_key = 'newval' . $args['index_key'];
254
$property_script .= $value_key . '=newval;';
255
256
$args = $this->get_args( $args );
283
// Allows us to apply this just for a specific choice in the array of the values.
284
if ( '' !== $choice ) {
285
$choice_is_direction = ( false !== strpos( $choice, 'top' ) || false !== strpos( $choice, 'bottom' ) || false !== strpos( $choice, 'left' ) || false !== strpos( $choice, 'right' ) );
286
+ // The script.
287
$script .= 'if(\'' . $choice . '\'===subKey){';
288
$script .= ( $choice_is_direction ) ? $direction_script . 'else{' : '';
289
$script .= 'css+=\'' . $args['element'] . '{' . $args['property'] . ':\'+subValue+\';}\';';
326
$webfont_loader = 'sc=\'a\';jQuery(\'head\').append(sc.replace(\'a\',\'<\')+\'script>if(!_.isUndefined(WebFont)&&fontFamily){WebFont.load({google:{families:["\'+fontFamily.replace( /\"/g, \'&quot;\' )+\':\'+variant+subsetsString+\'"]}});}\'+sc.replace(\'a\',\'<\')+\'/script>\');';
327
328
// Add the css.
329
+ $css_build_array = array(
330
'font-family' => 'fontFamily',
331
'font-size' => 'fontSize',
332
'line-height' => 'lineHeight',
340
'font-style' => 'fontStyle',
341
);
342
$choice_condition = ( isset( $args['choice'] ) && '' !== $args['choice'] && isset( $css_build_array[ $args['choice'] ] ) );
343
+ $script .= ( ! $choice_condition ) ? $webfont_loader : '';
344
foreach ( $css_build_array as $property => $var ) {
345
if ( $choice_condition && $property !== $args['choice'] ) {
346
continue;
365
366
if ( 'font-family' === $property || ( isset( $args['choice'] ) && 'font-family' === $args['choice'] ) ) {
367
$css .= 'fontFamilyCSS=fontFamily;if(0<fontFamily.indexOf(\' \')&&-1===fontFamily.indexOf(\'"\')){fontFamilyCSS=\'"\'+fontFamily+\'"\';}';
368
+ $var = 'fontFamilyCSS';
369
}
370
+ $var = ( ( empty( $args['prefix'] ) ) ? '' : '\'' . $args['prefix'] . '\'+' ) . $var . ( ( empty( $args['units'] ) ) ? '' : '+\'' . $args['units'] . '\'' ) . ( ( empty( $args['suffix'] ) ) ? '' : '+\'' . $args['suffix'] . '\'' );
371
$css .= 'css+=(\'\'!==' . $var . ')?\'' . $args['element'] . '\'+\'{' . $property . ':\'+' . $var . '+\';}\':\'\';';
372
}
373
478
$script .= 'settings=window.wp.customize.get();';
479
foreach ( $js_vars['pattern_replace'] as $search => $replace ) {
480
$replace = '\'+settings["' . $replace . '"]+\'';
481
+ $value = str_replace( $search, $replace, $js_vars['value_pattern'] );
482
+ $value = trim( $value, '+' );
483
}
484
}
485
$value_compiled = str_replace( '#x27;, '\'+' . $alias . '+\'', $value );
modules/webfonts/class-kirki-fonts-google.php CHANGED
@@ -73,7 +73,7 @@ final class Kirki_Fonts_Google {
73
*/
74
private function __construct() {
75
76
- $config = apply_filters( 'kirki/config', array() );
77
78
// If we have set $config['disable_google_fonts'] to true then do not proceed any further.
79
if ( isset( $config['disable_google_fonts'] ) && true === $config['disable_google_fonts'] ) {
@@ -154,7 +154,7 @@ final class Kirki_Fonts_Google {
154
}
155
// Are we force-loading all variants?
156
if ( true === self::$force_load_all_variants ) {
157
- $all_variants = Kirki_Fonts::get_all_variants();
158
$args['choices']['variant'] = array_keys( $all_variants );
159
}
160
73
*/
74
private function __construct() {
75
76
+ $config = apply_filters( 'kirki_config', array() );
77
78
// If we have set $config['disable_google_fonts'] to true then do not proceed any further.
79
if ( isset( $config['disable_google_fonts'] ) && true === $config['disable_google_fonts'] ) {
154
}
155
// Are we force-loading all variants?
156
if ( true === self::$force_load_all_variants ) {
157
+ $all_variants = Kirki_Fonts::get_all_variants();
158
$args['choices']['variant'] = array_keys( $all_variants );
159
}
160
modules/webfonts/class-kirki-fonts.php CHANGED
@@ -71,7 +71,7 @@ final class Kirki_Fonts {
71
$standard_fonts = self::get_standard_fonts();
72
$google_fonts = self::get_google_fonts();
73
74
- return apply_filters( 'kirki/fonts/all', array_merge( $standard_fonts, $google_fonts ) );
75
}
76
77
/**
@@ -81,20 +81,20 @@ final class Kirki_Fonts {
81
*/
82
public static function get_standard_fonts() {
83
$standard_fonts = array(
84
- 'serif' => array(
85
'label' => 'Serif',
86
'stack' => 'Georgia,Times,"Times New Roman",serif',
87
),
88
'sans-serif' => array(
89
- 'label' => 'Sans Serif',
90
- 'stack' => '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif',
91
),
92
- 'monospace' => array(
93
'label' => 'Monospace',
94
'stack' => 'Monaco,"Lucida Sans Typewriter","Lucida Typewriter","Courier New",Courier,monospace',
95
),
96
);
97
- return apply_filters( 'kirki/fonts/standard_fonts', $standard_fonts );
98
}
99
100
/**
@@ -110,7 +110,7 @@ final class Kirki_Fonts {
110
'handwriting' => '"Comic Sans MS", cursive, sans-serif',
111
'monospace' => '"Lucida Console", Monaco, monospace',
112
);
113
- return apply_filters( 'kirki/fonts/backup_fonts', $backup_fonts );
114
}
115
116
/**
@@ -122,7 +122,10 @@ final class Kirki_Fonts {
122
123
if ( null === self::$google_fonts || empty( self::$google_fonts ) ) {
124
125
- $fonts = include_once wp_normalize_path( dirname( __FILE__ ) . '/webfonts.php' );
126
127
$google_fonts = array();
128
if ( is_array( $fonts ) ) {
@@ -136,7 +139,7 @@ final class Kirki_Fonts {
136
}
137
}
138
139
- self::$google_fonts = apply_filters( 'kirki/fonts/google_fonts', $google_fonts );
140
141
}
142
@@ -236,7 +239,7 @@ final class Kirki_Fonts {
236
* @return array
237
*/
238
public static function get_font_choices() {
239
- $fonts = self::get_all_fonts();
240
$fonts_array = array();
241
foreach ( $fonts as $key => $args ) {
242
$fonts_array[ $key ] = $key;
71
$standard_fonts = self::get_standard_fonts();
72
$google_fonts = self::get_google_fonts();
73
74
+ return apply_filters( 'kirki_fonts_all', array_merge( $standard_fonts, $google_fonts ) );
75
}
76
77
/**
81
*/
82
public static function get_standard_fonts() {
83
$standard_fonts = array(
84
+ 'serif' => array(
85
'label' => 'Serif',
86
'stack' => 'Georgia,Times,"Times New Roman",serif',
87
),
88
'sans-serif' => array(
89
+ 'label' => 'Sans Serif',
90
+ 'stack' => '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif',
91
),
92
+ 'monospace' => array(
93
'label' => 'Monospace',
94
'stack' => 'Monaco,"Lucida Sans Typewriter","Lucida Typewriter","Courier New",Courier,monospace',
95
),
96
);
97
+ return apply_filters( 'kirki_fonts_standard_fonts', $standard_fonts );
98
}
99
100
/**
110
'handwriting' => '"Comic Sans MS", cursive, sans-serif',
111
'monospace' => '"Lucida Console", Monaco, monospace',
112
);
113
+ return apply_filters( 'kirki_fonts_backup_fonts', $backup_fonts );
114
}
115
116
/**
122
123
if ( null === self::$google_fonts || empty( self::$google_fonts ) ) {
124
125
+ ob_start();
126
+ include wp_normalize_path( dirname( __FILE__ ) . '/webfonts.json' );
127
+ $fonts_json = ob_get_clean();
128
+ $fonts = json_decode( $fonts_json, true );
129
130
$google_fonts = array();
131
if ( is_array( $fonts ) ) {
139
}
140
}
141
142
+ self::$google_fonts = apply_filters( 'kirki_fonts_google_fonts', $google_fonts );
143
144
}
145
239
* @return array
240
*/
241
public static function get_font_choices() {
242
+ $fonts = self::get_all_fonts();
243
$fonts_array = array();
244
foreach ( $fonts as $key => $args ) {
245
$fonts_array[ $key ] = $key;
modules/webfonts/class-kirki-modules-webfonts-async.php CHANGED
@@ -72,7 +72,7 @@ final class Kirki_Modules_Webfonts_Async {
72
// Go through our fields and populate $this->fonts.
73
$this->webfonts->loop_fields( $this->config_id );
74
75
- $this->googlefonts->fonts = apply_filters( 'kirki/enqueue_google_fonts', $this->googlefonts->fonts );
76
77
// Goes through $this->fonts and adds or removes things as needed.
78
$this->googlefonts->process_fonts();
72
// Go through our fields and populate $this->fonts.
73
$this->webfonts->loop_fields( $this->config_id );
74
75
+ $this->googlefonts->fonts = apply_filters( 'kirki_enqueue_google_fonts', $this->googlefonts->fonts );
76
77
// Goes through $this->fonts and adds or removes things as needed.
78
$this->googlefonts->process_fonts();
modules/webfonts/class-kirki-modules-webfonts-embed.php DELETED
@@ -1,175 +0,0 @@
1
- <?php
2
- /**
3
- * Embeds webfonts in styles.
4
- *
5
- * @package Kirki
6
- * @category Core
7
- * @author Aristeides Stathopoulos
8
- * @copyright Copyright (c) 2017, Aristeides Stathopoulos
9
- * @license http://opensource.org/licenses/https://opensource.org/licenses/MIT
10
- * @since 3.0
11
- */
12
-
13
- /**
14
- * Manages the way Google Fonts are enqueued.
15
- */
16
- final class Kirki_Modules_Webfonts_Embed {
17
-
18
- /**
19
- * The config ID.
20
- *
21
- * @access protected
22
- * @since 3.0.0
23
- * @var string
24
- */
25
- protected $config_id;
26
-
27
- /**
28
- * The Kirki_Modules_Webfonts object.
29
- *
30
- * @access protected
31
- * @since 3.0.0
32
- * @var object
33
- */
34
- protected $webfonts;
35
-
36
- /**
37
- * The Kirki_Fonts_Google object.
38
- *
39
- * @access protected
40
- * @since 3.0.0
41
- * @var object
42
- */
43
- protected $googlefonts;
44
-
45
- /**
46
- * The google link
47
- *
48
- * @access public
49
- * @var string
50
- */
51
- public $link = '';
52
-
53
- /**
54
- * Constructor.
55
- *
56
- * @access public
57
- * @since 3.0
58
- * @param string $config_id The config-ID.
59
- * @param object $webfonts The Kirki_Modules_Webfonts object.
60
- * @param object $googlefonts The Kirki_Fonts_Google object.
61
- * @param array $args Extra args we want to pass.
62
- */
63
- public function __construct( $config_id, $webfonts, $googlefonts, $args = array() ) {
64
-
65
- $this->config_id = $config_id;
66
- $this->webfonts = $webfonts;
67
- $this->googlefonts = $googlefonts;
68
-
69
- add_filter( "kirki/{$config_id}/dynamic_css", array( $this, 'embed_css' ) );
70
- add_action( 'wp_enqueue_scripts', array( $this, 'inline_css' ), 999 );
71
- }
72
-
73
- /**
74
- * Adds inline css.
75
- *
76
- * @access public
77
- * @since 3.0.0
78
- */
79
- public function inline_css() {
80
- wp_add_inline_style( 'kirki-styles', $this->embed_css() );
81
- }
82
-
83
- /**
84
- * Embeds the CSS from googlefonts API inside the Kirki output CSS.
85
- *
86
- * @access public
87
- * @since 3.0.0
88
- * @param string $css The original CSS.
89
- * @return string The modified CSS.
90
- */
91
- public function embed_css( $css = '' ) {
92
-
93
- // Go through our fields and populate $this->fonts.
94
- $this->webfonts->loop_fields( $this->config_id );
95
-
96
- $this->googlefonts->fonts = apply_filters( 'kirki/enqueue_google_fonts', $this->googlefonts->fonts );
97
-
98
- // Goes through $this->fonts and adds or removes things as needed.
99
- $this->googlefonts->process_fonts();
100
-
101
- // Go through $this->fonts and populate $this->link.
102
- $link_obj = new Kirki_Modules_Webfonts_Link( $this->config_id, $this->webfonts, $this->googlefonts );
103
- $link_obj->create_link();
104
- $this->link = $link_obj->link;
105
-
106
- // If $this->link is not empty then enqueue it.
107
- if ( '' !== $this->link ) {
108
- return $this->get_url_contents( $this->link ) . "\n" . $css;
109
- }
110
- return $css;
111
- }
112
-
113
- /**
114
- * Get the contents of a remote google-fonts link.
115
- * Responses get cached for 1 day.
116
- *
117
- * @access protected
118
- * @since 3.0.0
119
- * @param string $url The link we want to get.
120
- * @return string|false Returns false if there's an error.
121
- */
122
- protected function get_url_contents( $url = '' ) {
123
-
124
- // If $url is not set, use $this->link.
125
- $url = ( '' === $url ) ? $this->link : $url;
126
-
127
- // Sanitize the URL.
128
- $url = esc_url_raw( $url );
129
-
130
- // The transient name.
131
- $transient_name = 'kirki_googlefonts_contents_' . md5( $url );
132
-
133
- // Get the transient value.
134
- $data = get_transient( $transient_name );
135
-
136
- // Check for transient, if none, grab remote HTML file.
137
- if ( false === $data ) {
138
-
139
- // Get remote HTML file.
140
- $response = wp_remote_get( $url );
141
-
142
- // Check for error.
143
- if ( is_wp_error( $response ) ) {
144
- set_transient( 'kirki_googlefonts_fallback_to_link', 'yes', HOUR_IN_SECONDS );
145
- return false;
146
- }
147
-
148
- if ( ! isset( $response['response'] ) || ! is_array( $response['response'] ) || ! isset( $response['response']['code'] ) || 200 !== $response['response']['code'] ) {
149
- return false;
150
- }
151
-
152
- // Parse remote HTML file.
153
- $data = wp_remote_retrieve_body( $response );
154
-
155
- // Check for error.
156
- if ( is_wp_error( $data ) ) {
157
- set_transient( 'kirki_googlefonts_fallback_to_link', 'yes', HOUR_IN_SECONDS );
158
- return false;
159
- }
160
-
161
- // Return false if the data is empty.
162
- if ( ! $data ) {
163
- set_transient( 'kirki_googlefonts_fallback_to_link', 'yes', HOUR_IN_SECONDS );
164
- return false;
165
- }
166
-
167
- // Store remote HTML file in transient, expire after 24 hours.
168
- set_transient( $transient_name, $data, DAY_IN_SECONDS );
169
- set_transient( 'kirki_googlefonts_fallback_to_link', 'no', DAY_IN_SECONDS );
170
- }
171
-
172
- return $data;
173
-
174
- }
175
- }
modules/webfonts/class-kirki-modules-webfonts-link.php DELETED
@@ -1,150 +0,0 @@
1
- <?php
2
- /**
3
- * Adds a link for webfonts.
4
- *
5
- * @package Kirki
6
- * @category Core
7
- * @author Aristeides Stathopoulos
8
- * @copyright Copyright (c) 2017, Aristeides Stathopoulos
9
- * @license http://opensource.org/licenses/https://opensource.org/licenses/MIT
10
- * @since 3.0
11
- */
12
-
13
- /**
14
- * Manages the way Google Fonts are enqueued.
15
- */
16
- final class Kirki_Modules_Webfonts_Link {
17
-
18
- /**
19
- * The config ID.
20
- *
21
- * @access protected
22
- * @since 3.0.0
23
- * @var string
24
- */
25
- protected $config_id;
26
-
27
- /**
28
- * The Kirki_Modules_Webfonts object.
29
- *
30
- * @access protected
31
- * @since 3.0.0
32
- * @var object
33
- */
34
- protected $webfonts;
35
-
36
- /**
37
- * The Kirki_Fonts_Google object.
38
- *
39
- * @access protected
40
- * @since 3.0.0
41
- * @var object
42
- */
43
- protected $googlefonts;
44
-
45
- /**
46
- * The google link
47
- *
48
- * @access public
49
- * @var string
50
- */
51
- public $link = '';
52
-
53
- /**
54
- * An array of subsets.
55
- *
56
- * @access public
57
- * @var array
58
- */
59
- public $subsets = array();
60
-
61
- /**
62
- * Constructor.
63
- *
64
- * @access public
65
- * @since 3.0
66
- * @param string $config_id The config-ID.
67
- * @param object $webfonts The Kirki_Modules_Webfonts object.
68
- * @param object $googlefonts The Kirki_Fonts_Google object.
69
- * @param array $args Extra args we want to pass.
70
- */
71
- public function __construct( $config_id, $webfonts, $googlefonts, $args = array() ) {
72
-
73
- $this->config_id = $config_id;
74
- $this->webfonts = $webfonts;
75
- $this->googlefonts = $googlefonts;
76
-
77
- if ( ! isset( $args['enqueue'] ) || false !== $args['enqueue'] ) {
78
- add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ), 105 );
79
- }
80
- }
81
-
82
- /**
83
- * Calls all the other necessary methods to populate and create the link.
84
- */
85
- public function enqueue() {
86
-
87
- // Go through our fields and populate $this->fonts.
88
- $this->webfonts->loop_fields( $this->config_id );
89
-
90
- $this->googlefonts->fonts = apply_filters( 'kirki/enqueue_google_fonts', $this->googlefonts->fonts );
91
-
92
- // Goes through $this->fonts and adds or removes things as needed.
93
- $this->googlefonts->process_fonts();
94
-
95
- // Go through $this->fonts and populate $this->link.
96
- $this->create_link();
97
-
98
- // If $this->link is not empty then enqueue it.
99
- if ( '' !== $this->link ) {
100
- wp_enqueue_style( 'kirki_google_fonts', $this->link, array(), KIRKI_VERSION );
101
- }
102
- }
103
-
104
- /**
105
- * Creates the google-fonts link.
106
- */
107
- public function create_link() {
108
-
109
- // If we don't have any fonts then we can exit.
110
- if ( empty( $this->googlefonts->fonts ) ) {
111
- return;
112
- }
113
-
114
- // Add a fallback to Roboto.
115
- $font = 'Roboto';
116
-
117
- // Get font-family + subsets.
118
- $link_fonts = array();
119
- foreach ( $this->googlefonts->fonts as $font => $variants ) {
120
-
121
- $variants = implode( ',', $variants );
122
-
123
- $link_font = str_replace( ' ', '+', $font );
124
- if ( ! empty( $variants ) ) {
125
- $link_font .= ':' . $variants;
126
- }
127
- $link_fonts[] = $link_font;
128
- }
129
-
130
- // Are we force-loading all subsets?
131
- if ( true === Kirki_Fonts_Google::$force_load_all_subsets ) {
132
-
133
- if ( isset( $this->googlefonts->fonts[ $font ]['subsets'] ) ) {
134
- foreach ( $this->googlefonts->fonts[ $font ]['subsets'] as $subset ) {
135
- $this->subsets[] = $subset;
136
- }
137
- }
138
- }
139
-
140
- if ( ! empty( $this->googlefonts->subsets ) ) {
141
- $this->subsets = array_unique( $this->googlefonts->subsets );
142
- }
143
-
144
- $this->link = add_query_arg( array(
145
- 'family' => str_replace( '%2B', '+', rawurlencode( implode( '|', $link_fonts ) ) ),
146
- 'subset' => rawurlencode( implode( ',', $this->subsets ) ),
147
- ), 'https://fonts.googleapis.com/css' );
148
-
149
- }
150
- }
</