@@ -46,17 +46,17 @@ discard block |
||
46 | 46 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
47 | 47 | * @return array |
48 | 48 | */ |
49 | - public function filter_setting_args( $args, $wp_customize ) { |
|
50 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
51 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
49 | + public function filter_setting_args($args, $wp_customize) { |
|
50 | + if ($args['settings'] === $this->args['settings']) { |
|
51 | + $args = parent::filter_setting_args($args, $wp_customize); |
|
52 | 52 | |
53 | 53 | // Set the sanitize-callback if none is defined. |
54 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
54 | + if (!isset($args['sanitize_callback']) || !$args['sanitize_callback']) { |
|
55 | 55 | |
56 | - $args['sanitize_callback'] = function( $value ) { |
|
57 | - $save_as = isset( $this->args['choices']['save_as'] ) ? $this->args['choices']['save_as'] : 'url'; |
|
56 | + $args['sanitize_callback'] = function($value) { |
|
57 | + $save_as = isset($this->args['choices']['save_as']) ? $this->args['choices']['save_as'] : 'url'; |
|
58 | 58 | |
59 | - return self::sanitize( $value, $save_as ); |
|
59 | + return self::sanitize($value, $save_as); |
|
60 | 60 | }; |
61 | 61 | |
62 | 62 | } |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
75 | 75 | * @return array |
76 | 76 | */ |
77 | - public function filter_control_args( $args, $wp_customize ) { |
|
78 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
79 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
77 | + public function filter_control_args($args, $wp_customize) { |
|
78 | + if ($args['settings'] === $this->args['settings']) { |
|
79 | + $args = parent::filter_control_args($args, $wp_customize); |
|
80 | 80 | $args['type'] = 'upload'; |
81 | 81 | } |
82 | 82 | return $args; |
@@ -92,57 +92,57 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return mixed |
94 | 94 | */ |
95 | - public static function sanitize( $value, $save_as = 'url' ) { |
|
95 | + public static function sanitize($value, $save_as = 'url') { |
|
96 | 96 | |
97 | - if ( 'array' === $save_as ) { |
|
97 | + if ('array' === $save_as) { |
|
98 | 98 | |
99 | - if ( is_array( $value ) ) { |
|
99 | + if (is_array($value)) { |
|
100 | 100 | return [ |
101 | - 'id' => ( isset( $value['id'] ) && '' !== $value['id'] ) ? (int) $value['id'] : '', |
|
102 | - 'url' => ( isset( $value['url'] ) && '' !== $value['url'] ) ? esc_url_raw( $value['url'] ) : '', |
|
103 | - 'filename' => ( isset( $value['filename'] ) && '' !== $value['filename'] ) ? sanitize_text_field( $value['filename'] ) : '', |
|
101 | + 'id' => (isset($value['id']) && '' !== $value['id']) ? (int) $value['id'] : '', |
|
102 | + 'url' => (isset($value['url']) && '' !== $value['url']) ? esc_url_raw($value['url']) : '', |
|
103 | + 'filename' => (isset($value['filename']) && '' !== $value['filename']) ? sanitize_text_field($value['filename']) : '', |
|
104 | 104 | ]; |
105 | - } elseif ( is_string( $value ) && ! is_numeric( $value ) ) { |
|
105 | + } elseif (is_string($value) && !is_numeric($value)) { |
|
106 | 106 | // Here, we assume that the value is the URL. |
107 | - $attachment_id = attachment_url_to_postid( $value ); |
|
107 | + $attachment_id = attachment_url_to_postid($value); |
|
108 | 108 | |
109 | 109 | return [ |
110 | 110 | 'id' => $attachment_id, |
111 | 111 | 'url' => $value, |
112 | - 'filename' => basename( get_attached_file( $attachment_id ) ), |
|
112 | + 'filename' => basename(get_attached_file($attachment_id)), |
|
113 | 113 | ]; |
114 | 114 | } else { |
115 | 115 | // Here, we assume that the value is int or numeric (the attachment ID). |
116 | - $value = absint( $value ); |
|
116 | + $value = absint($value); |
|
117 | 117 | |
118 | 118 | return [ |
119 | 119 | 'id' => $value, |
120 | - 'url' => wp_get_attachment_url( $value ), |
|
121 | - 'filename' => basename( get_attached_file( $value ) ), |
|
120 | + 'url' => wp_get_attachment_url($value), |
|
121 | + 'filename' => basename(get_attached_file($value)), |
|
122 | 122 | ]; |
123 | 123 | } |
124 | - } elseif ( 'id' === $save_as ) { |
|
124 | + } elseif ('id' === $save_as) { |
|
125 | 125 | |
126 | - if ( is_string( $value ) && ! is_numeric( $value ) ) { |
|
126 | + if (is_string($value) && !is_numeric($value)) { |
|
127 | 127 | // Here, we assume that the value is the URL. |
128 | - return attachment_url_to_postid( $value ); |
|
129 | - } elseif ( is_array( $value ) && isset( $value['id'] ) ) { |
|
130 | - return absint( $value['id'] ); |
|
128 | + return attachment_url_to_postid($value); |
|
129 | + } elseif (is_array($value) && isset($value['id'])) { |
|
130 | + return absint($value['id']); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | // Here, we assume that the value is int or numeric (the attachment ID). |
134 | - return absint( $value ); |
|
134 | + return absint($value); |
|
135 | 135 | |
136 | 136 | } |
137 | 137 | |
138 | 138 | // If we're reaching this point, then we're saving the URL. |
139 | - if ( is_array( $value ) && isset( $value['url'] ) ) { |
|
139 | + if (is_array($value) && isset($value['url'])) { |
|
140 | 140 | $value = $value['url']; |
141 | - } elseif ( is_numeric( $value ) ) { |
|
142 | - $value = absint( $value ); |
|
143 | - $value = wp_get_attachment_url( $value ); |
|
141 | + } elseif (is_numeric($value)) { |
|
142 | + $value = absint($value); |
|
143 | + $value = wp_get_attachment_url($value); |
|
144 | 144 | } else { |
145 | - $value = esc_url_raw( $value ); |
|
145 | + $value = esc_url_raw($value); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | return $value; |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | namespace Kirki\Control; |
10 | 10 | |
11 | 11 | // Exit if accessed directly. |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if (!defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -54,17 +54,17 @@ discard block |
||
54 | 54 | |
55 | 55 | $value = $this->value(); |
56 | 56 | |
57 | - if ( ! empty( $value ) ) { |
|
58 | - if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
57 | + if (!empty($value)) { |
|
58 | + if (is_array($value) && isset($value['id'])) { |
|
59 | 59 | $attachment_id = $value['id']; |
60 | - } elseif ( is_numeric( $value ) ) { |
|
61 | - $attachment_id = absint( $value ); |
|
62 | - } elseif ( is_string( $value ) && ! is_numeric( $value ) ) { |
|
63 | - $attachment_id = attachment_url_to_postid( $value ); |
|
60 | + } elseif (is_numeric($value)) { |
|
61 | + $attachment_id = absint($value); |
|
62 | + } elseif (is_string($value) && !is_numeric($value)) { |
|
63 | + $attachment_id = attachment_url_to_postid($value); |
|
64 | 64 | } |
65 | 65 | |
66 | - if ( ! empty( $attachment_id ) ) { |
|
67 | - $this->json['attachment'] = wp_prepare_attachment_for_js( $attachment_id ); |
|
66 | + if (!empty($attachment_id)) { |
|
67 | + $this->json['attachment'] = wp_prepare_attachment_for_js($attachment_id); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | } |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | * @since 1.0.0 |
49 | 49 | */ |
50 | 50 | public function __construct() { |
51 | - add_action( 'kirki_field_init', [ $this, 'field_init' ], 10, 2 ); |
|
52 | - add_action( 'wp_loaded', [ $this, 'run' ] ); |
|
51 | + add_action('kirki_field_init', [$this, 'field_init'], 10, 2); |
|
52 | + add_action('wp_loaded', [$this, 'run']); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | * @since 1.0.0 |
71 | 71 | */ |
72 | 72 | protected function init() { |
73 | - foreach ( array_keys( Kirki::$config ) as $config_id ) { |
|
74 | - if ( 'async' === $this->get_method() ) { |
|
75 | - new Async( $config_id, $this, $this->fonts_google ); |
|
73 | + foreach (array_keys(Kirki::$config) as $config_id) { |
|
74 | + if ('async' === $this->get_method()) { |
|
75 | + new Async($config_id, $this, $this->fonts_google); |
|
76 | 76 | } |
77 | - new Embed( $config_id, $this, $this->fonts_google ); |
|
77 | + new Embed($config_id, $this, $this->fonts_google); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @return string |
88 | 88 | */ |
89 | 89 | public function get_method() { |
90 | - return ( is_customize_preview() || is_admin() ) ? 'async' : 'embed'; |
|
90 | + return (is_customize_preview() || is_admin()) ? 'async' : 'embed'; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -100,17 +100,17 @@ discard block |
||
100 | 100 | * @param Object $object The field object. |
101 | 101 | * @return void |
102 | 102 | */ |
103 | - public function field_init( $args, $object ) { |
|
104 | - if ( ! isset( $args['type'] ) && isset( $object->type ) ) { |
|
103 | + public function field_init($args, $object) { |
|
104 | + if (!isset($args['type']) && isset($object->type)) { |
|
105 | 105 | $args['type'] = $object->type; |
106 | 106 | } |
107 | 107 | |
108 | - if ( ! isset( $args['type'] ) || $args['type'] !== 'kirki-typography' ) { |
|
108 | + if (!isset($args['type']) || $args['type'] !== 'kirki-typography') { |
|
109 | 109 | return; |
110 | 110 | } |
111 | 111 | |
112 | 112 | // Use the settings ID as key: |
113 | - self::$fields[ $args['settings'] ] = $args; |
|
113 | + self::$fields[$args['settings']] = $args; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | * @access public |
121 | 121 | * @param string $config_id The config-ID. |
122 | 122 | */ |
123 | - public function loop_fields( $config_id ) { |
|
124 | - foreach ( self::$fields as $field ) { |
|
125 | - if ( isset( $field['kirki_config'] ) && $config_id !== $field['kirki_config'] ) { |
|
123 | + public function loop_fields($config_id) { |
|
124 | + foreach (self::$fields as $field) { |
|
125 | + if (isset($field['kirki_config']) && $config_id !== $field['kirki_config']) { |
|
126 | 126 | continue; |
127 | 127 | } |
128 | 128 | |
129 | - $this->fonts_google->generate_google_font( $field ); |
|
129 | + $this->fonts_google->generate_google_font($field); |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @return object Fonts |
60 | 60 | */ |
61 | 61 | public static function get_instance() { |
62 | - if ( null === self::$instance ) { |
|
62 | + if (null === self::$instance) { |
|
63 | 63 | self::$instance = new self(); |
64 | 64 | } |
65 | 65 | return self::$instance; |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public static function get_all_fonts() { |
74 | 74 | $standard_fonts = self::get_standard_fonts(); |
75 | 75 | $google_fonts = self::get_google_fonts(); |
76 | - return apply_filters( 'kirki_fonts_all', array_merge( $standard_fonts, $google_fonts ) ); |
|
76 | + return apply_filters('kirki_fonts_all', array_merge($standard_fonts, $google_fonts)); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | ], |
98 | 98 | ]; |
99 | 99 | |
100 | - return apply_filters( 'kirki_fonts_standard_fonts', $standard_fonts ); |
|
100 | + return apply_filters('kirki_fonts_standard_fonts', $standard_fonts); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @return array All Google Fonts. |
107 | 107 | */ |
108 | 108 | public static function get_google_fonts() { |
109 | - if ( ! self::$google_fonts ) { |
|
109 | + if (!self::$google_fonts) { |
|
110 | 110 | $googlefonts = new GoogleFonts(); |
111 | 111 | self::$google_fonts = $googlefonts->get_google_fonts(); |
112 | 112 | } |
@@ -159,29 +159,29 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public static function get_all_variants() { |
161 | 161 | return [ |
162 | - '100' => esc_html__( 'Ultra-Light 100', 'kirki' ), |
|
163 | - '100light' => esc_html__( 'Ultra-Light 100', 'kirki' ), |
|
164 | - '100italic' => esc_html__( 'Ultra-Light 100 Italic', 'kirki' ), |
|
165 | - '200' => esc_html__( 'Light 200', 'kirki' ), |
|
166 | - '200italic' => esc_html__( 'Light 200 Italic', 'kirki' ), |
|
167 | - '300' => esc_html__( 'Book 300', 'kirki' ), |
|
168 | - '300italic' => esc_html__( 'Book 300 Italic', 'kirki' ), |
|
169 | - '400' => esc_html__( 'Normal 400', 'kirki' ), |
|
170 | - 'regular' => esc_html__( 'Normal 400', 'kirki' ), |
|
171 | - 'italic' => esc_html__( 'Normal 400 Italic', 'kirki' ), |
|
172 | - '500' => esc_html__( 'Medium 500', 'kirki' ), |
|
173 | - '500italic' => esc_html__( 'Medium 500 Italic', 'kirki' ), |
|
174 | - '600' => esc_html__( 'Semi-Bold 600', 'kirki' ), |
|
175 | - '600bold' => esc_html__( 'Semi-Bold 600', 'kirki' ), |
|
176 | - '600italic' => esc_html__( 'Semi-Bold 600 Italic', 'kirki' ), |
|
177 | - '700' => esc_html__( 'Bold 700', 'kirki' ), |
|
178 | - '700italic' => esc_html__( 'Bold 700 Italic', 'kirki' ), |
|
179 | - '800' => esc_html__( 'Extra-Bold 800', 'kirki' ), |
|
180 | - '800bold' => esc_html__( 'Extra-Bold 800', 'kirki' ), |
|
181 | - '800italic' => esc_html__( 'Extra-Bold 800 Italic', 'kirki' ), |
|
182 | - '900' => esc_html__( 'Ultra-Bold 900', 'kirki' ), |
|
183 | - '900bold' => esc_html__( 'Ultra-Bold 900', 'kirki' ), |
|
184 | - '900italic' => esc_html__( 'Ultra-Bold 900 Italic', 'kirki' ), |
|
162 | + '100' => esc_html__('Ultra-Light 100', 'kirki'), |
|
163 | + '100light' => esc_html__('Ultra-Light 100', 'kirki'), |
|
164 | + '100italic' => esc_html__('Ultra-Light 100 Italic', 'kirki'), |
|
165 | + '200' => esc_html__('Light 200', 'kirki'), |
|
166 | + '200italic' => esc_html__('Light 200 Italic', 'kirki'), |
|
167 | + '300' => esc_html__('Book 300', 'kirki'), |
|
168 | + '300italic' => esc_html__('Book 300 Italic', 'kirki'), |
|
169 | + '400' => esc_html__('Normal 400', 'kirki'), |
|
170 | + 'regular' => esc_html__('Normal 400', 'kirki'), |
|
171 | + 'italic' => esc_html__('Normal 400 Italic', 'kirki'), |
|
172 | + '500' => esc_html__('Medium 500', 'kirki'), |
|
173 | + '500italic' => esc_html__('Medium 500 Italic', 'kirki'), |
|
174 | + '600' => esc_html__('Semi-Bold 600', 'kirki'), |
|
175 | + '600bold' => esc_html__('Semi-Bold 600', 'kirki'), |
|
176 | + '600italic' => esc_html__('Semi-Bold 600 Italic', 'kirki'), |
|
177 | + '700' => esc_html__('Bold 700', 'kirki'), |
|
178 | + '700italic' => esc_html__('Bold 700 Italic', 'kirki'), |
|
179 | + '800' => esc_html__('Extra-Bold 800', 'kirki'), |
|
180 | + '800bold' => esc_html__('Extra-Bold 800', 'kirki'), |
|
181 | + '800italic' => esc_html__('Extra-Bold 800 Italic', 'kirki'), |
|
182 | + '900' => esc_html__('Ultra-Bold 900', 'kirki'), |
|
183 | + '900bold' => esc_html__('Ultra-Bold 900', 'kirki'), |
|
184 | + '900italic' => esc_html__('Ultra-Bold 900 Italic', 'kirki'), |
|
185 | 185 | ]; |
186 | 186 | } |
187 | 187 | |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | * @param string $fontname The name of the font we want to check. |
194 | 194 | * @return bool |
195 | 195 | */ |
196 | - public static function is_google_font( $fontname ) { |
|
197 | - if ( is_string( $fontname ) ) { |
|
196 | + public static function is_google_font($fontname) { |
|
197 | + if (is_string($fontname)) { |
|
198 | 198 | $fonts = self::get_google_fonts(); |
199 | - return isset( $fonts[ $fontname ] ); |
|
199 | + return isset($fonts[$fontname]); |
|
200 | 200 | } |
201 | 201 | return false; |
202 | 202 | } |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | public static function get_font_choices() { |
212 | 212 | |
213 | 213 | $fonts = self::get_all_fonts(); |
214 | - $keys = array_keys( $fonts ); |
|
214 | + $keys = array_keys($fonts); |
|
215 | 215 | |
216 | 216 | |
217 | - return array_combine( $keys, $keys ); |
|
217 | + return array_combine($keys, $keys); |
|
218 | 218 | } |
219 | 219 | } |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | * @param string $url The URL. |
28 | 28 | * @return string |
29 | 29 | */ |
30 | - public function get_styles( $url ) { |
|
31 | - $css = $this->get_cached_url_contents( $url ); |
|
32 | - return $this->get_local_font_styles( $css ); |
|
30 | + public function get_styles($url) { |
|
31 | + $css = $this->get_cached_url_contents($url); |
|
32 | + return $this->get_local_font_styles($css); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -40,17 +40,17 @@ discard block |
||
40 | 40 | * @param string $css The styles. |
41 | 41 | * @return string |
42 | 42 | */ |
43 | - protected function get_local_font_styles( $css ) { |
|
44 | - $files = $this->get_local_files_from_css( $css ); |
|
43 | + protected function get_local_font_styles($css) { |
|
44 | + $files = $this->get_local_files_from_css($css); |
|
45 | 45 | |
46 | 46 | // Convert paths to URLs. |
47 | - foreach ( $files as $remote => $local ) { |
|
48 | - $files[ $remote ] = str_replace( WP_CONTENT_DIR, content_url(), $local ); |
|
47 | + foreach ($files as $remote => $local) { |
|
48 | + $files[$remote] = str_replace(WP_CONTENT_DIR, content_url(), $local); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | return str_replace( |
52 | - array_keys( $files ), |
|
53 | - array_values( $files ), |
|
52 | + array_keys($files), |
|
53 | + array_values($files), |
|
54 | 54 | $css |
55 | 55 | ); |
56 | 56 | } |
@@ -63,66 +63,66 @@ discard block |
||
63 | 63 | * @param string $css The CSS we want to parse. |
64 | 64 | * @return array Returns an array of remote URLs and their local counterparts. |
65 | 65 | */ |
66 | - protected function get_local_files_from_css( $css ) { |
|
67 | - $font_files = $this->get_files_from_css( $css ); |
|
68 | - $stored = get_option( 'kirki_downloaded_font_files', array() ); |
|
66 | + protected function get_local_files_from_css($css) { |
|
67 | + $font_files = $this->get_files_from_css($css); |
|
68 | + $stored = get_option('kirki_downloaded_font_files', array()); |
|
69 | 69 | $change = false; // If in the end this is true, we need to update the cache option. |
70 | 70 | |
71 | 71 | // If the fonts folder don't exist, create it. |
72 | - if ( ! file_exists( WP_CONTENT_DIR . '/fonts' ) ) { |
|
73 | - $this->get_filesystem()->mkdir( WP_CONTENT_DIR . '/fonts', FS_CHMOD_DIR ); |
|
72 | + if (!file_exists(WP_CONTENT_DIR . '/fonts')) { |
|
73 | + $this->get_filesystem()->mkdir(WP_CONTENT_DIR . '/fonts', FS_CHMOD_DIR); |
|
74 | 74 | } |
75 | 75 | |
76 | - foreach ( $font_files as $font_family => $files ) { |
|
76 | + foreach ($font_files as $font_family => $files) { |
|
77 | 77 | |
78 | 78 | // The folder path for this font-family. |
79 | 79 | $folder_path = WP_CONTENT_DIR . '/fonts/' . $font_family; |
80 | 80 | |
81 | 81 | // If the folder doesn't exist, create it. |
82 | - if ( ! file_exists( $folder_path ) ) { |
|
83 | - $this->get_filesystem()->mkdir( $folder_path, FS_CHMOD_DIR ); |
|
82 | + if (!file_exists($folder_path)) { |
|
83 | + $this->get_filesystem()->mkdir($folder_path, FS_CHMOD_DIR); |
|
84 | 84 | } |
85 | 85 | |
86 | - foreach ( $files as $url ) { |
|
86 | + foreach ($files as $url) { |
|
87 | 87 | |
88 | 88 | // Get the filename. |
89 | - $filename = basename( wp_parse_url( $url, PHP_URL_PATH ) ); |
|
89 | + $filename = basename(wp_parse_url($url, PHP_URL_PATH)); |
|
90 | 90 | $font_path = $folder_path . '/' . $filename; |
91 | 91 | |
92 | - if ( file_exists( $font_path ) ) { |
|
92 | + if (file_exists($font_path)) { |
|
93 | 93 | |
94 | 94 | // Skip if already cached. |
95 | - if ( isset( $stored[ $url ] ) ) { |
|
95 | + if (isset($stored[$url])) { |
|
96 | 96 | continue; |
97 | 97 | } |
98 | 98 | |
99 | - $stored[ $url ] = $font_path; |
|
99 | + $stored[$url] = $font_path; |
|
100 | 100 | $change = true; |
101 | 101 | } |
102 | 102 | |
103 | - if ( ! function_exists( 'download_url' ) ) { |
|
104 | - require_once wp_normalize_path( ABSPATH . '/wp-admin/includes/file.php' ); |
|
103 | + if (!function_exists('download_url')) { |
|
104 | + require_once wp_normalize_path(ABSPATH . '/wp-admin/includes/file.php'); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | // Download file to temporary location. |
108 | - $tmp_path = download_url( $url ); |
|
108 | + $tmp_path = download_url($url); |
|
109 | 109 | |
110 | 110 | // Make sure there were no errors. |
111 | - if ( is_wp_error( $tmp_path ) ) { |
|
111 | + if (is_wp_error($tmp_path)) { |
|
112 | 112 | continue; |
113 | 113 | } |
114 | 114 | |
115 | 115 | // Move temp file to final destination. |
116 | - $success = $this->get_filesystem()->move( $tmp_path, $font_path, true ); |
|
117 | - if ( $success ) { |
|
118 | - $stored[ $url ] = $font_path; |
|
116 | + $success = $this->get_filesystem()->move($tmp_path, $font_path, true); |
|
117 | + if ($success) { |
|
118 | + $stored[$url] = $font_path; |
|
119 | 119 | $change = true; |
120 | 120 | } |
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | - if ( $change ) { |
|
125 | - update_option( 'kirki_downloaded_font_files', $stored ); |
|
124 | + if ($change) { |
|
125 | + update_option('kirki_downloaded_font_files', $stored); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | return $stored; |
@@ -139,25 +139,25 @@ discard block |
||
139 | 139 | * @param string $user_agent The user-agent to use for our request. |
140 | 140 | * @return string Returns the remote URL contents. |
141 | 141 | */ |
142 | - public function get_cached_url_contents( $url = '', $user_agent = null ) { |
|
142 | + public function get_cached_url_contents($url = '', $user_agent = null) { |
|
143 | 143 | |
144 | 144 | // Try to retrieved cached response from the gfonts API. |
145 | 145 | $contents = false; |
146 | - $cached_responses = get_transient( 'kirki_remote_url_contents' ); |
|
147 | - $cached_responses = ( $cached_responses && is_array( $cached_responses ) ) ? $cached_responses : array(); |
|
148 | - if ( isset( $cached_responses[ md5( $url . $user_agent ) ] ) ) { |
|
149 | - return $cached_responses[ md5( $url . $user_agent ) ]; |
|
146 | + $cached_responses = get_transient('kirki_remote_url_contents'); |
|
147 | + $cached_responses = ($cached_responses && is_array($cached_responses)) ? $cached_responses : array(); |
|
148 | + if (isset($cached_responses[md5($url . $user_agent)])) { |
|
149 | + return $cached_responses[md5($url . $user_agent)]; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | // Get the contents from remote. |
153 | - $contents = $this->get_url_contents( $url, $user_agent ); |
|
153 | + $contents = $this->get_url_contents($url, $user_agent); |
|
154 | 154 | |
155 | 155 | // If we got the contents successfully, store them in a transient. |
156 | 156 | // We're using a transient and not an option because fonts get updated |
157 | 157 | // so we want to be able to get the latest version weekly. |
158 | - if ( $contents ) { |
|
159 | - $cached_responses[ md5( $url . $user_agent ) ] = $contents; |
|
160 | - set_transient( 'kirki_remote_url_contents', $cached_responses, WEEK_IN_SECONDS ); |
|
158 | + if ($contents) { |
|
159 | + $cached_responses[md5($url . $user_agent)] = $contents; |
|
160 | + set_transient('kirki_remote_url_contents', $cached_responses, WEEK_IN_SECONDS); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | return $contents; |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | * @param string $user_agent The user-agent to use for our request. |
173 | 173 | * @return string Returns the remote URL contents. |
174 | 174 | */ |
175 | - public function get_url_contents( $url = '', $user_agent = null ) { |
|
175 | + public function get_url_contents($url = '', $user_agent = null) { |
|
176 | 176 | |
177 | - if ( ! $user_agent ) { |
|
177 | + if (!$user_agent) { |
|
178 | 178 | |
179 | 179 | /** |
180 | 180 | * The user-agent we want to use. |
@@ -187,18 +187,18 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | // Get the response. |
190 | - $response = wp_remote_get( $url, array( 'user-agent' => $user_agent ) ); |
|
190 | + $response = wp_remote_get($url, array('user-agent' => $user_agent)); |
|
191 | 191 | |
192 | 192 | // Early exit if there was an error. |
193 | - if ( is_wp_error( $response ) ) { |
|
193 | + if (is_wp_error($response)) { |
|
194 | 194 | return; |
195 | 195 | } |
196 | 196 | |
197 | 197 | // Get the CSS from our response. |
198 | - $contents = wp_remote_retrieve_body( $response ); |
|
198 | + $contents = wp_remote_retrieve_body($response); |
|
199 | 199 | |
200 | 200 | // Early exit if there was an error. |
201 | - if ( is_wp_error( $contents ) ) { |
|
201 | + if (is_wp_error($contents)) { |
|
202 | 202 | return; |
203 | 203 | } |
204 | 204 | |
@@ -213,58 +213,58 @@ discard block |
||
213 | 213 | * @param string $css The CSS we want to parse. |
214 | 214 | * @return array Returns an array of font-families and the font-files used. |
215 | 215 | */ |
216 | - public function get_files_from_css( $css ) { |
|
216 | + public function get_files_from_css($css) { |
|
217 | 217 | |
218 | - $font_faces = explode( '@font-face', $css ); |
|
218 | + $font_faces = explode('@font-face', $css); |
|
219 | 219 | |
220 | 220 | $result = array(); |
221 | 221 | |
222 | 222 | // Loop all our font-face declarations. |
223 | - foreach ( $font_faces as $font_face ) { |
|
223 | + foreach ($font_faces as $font_face) { |
|
224 | 224 | |
225 | 225 | // Make sure we only process styles inside this declaration. |
226 | - $style = explode( '}', $font_face )[0]; |
|
226 | + $style = explode('}', $font_face)[0]; |
|
227 | 227 | |
228 | 228 | // Sanity check. |
229 | - if ( false === strpos( $style, 'font-family' ) ) { |
|
229 | + if (false === strpos($style, 'font-family')) { |
|
230 | 230 | continue; |
231 | 231 | } |
232 | 232 | |
233 | 233 | // Get an array of our font-families. |
234 | - preg_match_all( '/font-family.*?\;/', $style, $matched_font_families ); |
|
234 | + preg_match_all('/font-family.*?\;/', $style, $matched_font_families); |
|
235 | 235 | |
236 | 236 | // Get an array of our font-files. |
237 | - preg_match_all( '/url\(.*?\)/i', $style, $matched_font_files ); |
|
237 | + preg_match_all('/url\(.*?\)/i', $style, $matched_font_files); |
|
238 | 238 | |
239 | 239 | // Get the font-family name. |
240 | 240 | $font_family = 'unknown'; |
241 | - if ( isset( $matched_font_families[0] ) && isset( $matched_font_families[0][0] ) ) { |
|
242 | - $font_family = rtrim( ltrim( $matched_font_families[0][0], 'font-family:' ), ';' ); |
|
243 | - $font_family = trim( str_replace( array( "'", ';' ), '', $font_family ) ); |
|
244 | - $font_family = sanitize_key( strtolower( str_replace( ' ', '-', $font_family ) ) ); |
|
241 | + if (isset($matched_font_families[0]) && isset($matched_font_families[0][0])) { |
|
242 | + $font_family = rtrim(ltrim($matched_font_families[0][0], 'font-family:'), ';'); |
|
243 | + $font_family = trim(str_replace(array("'", ';'), '', $font_family)); |
|
244 | + $font_family = sanitize_key(strtolower(str_replace(' ', '-', $font_family))); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | // Make sure the font-family is set in our array. |
248 | - if ( ! isset( $result[ $font_family ] ) ) { |
|
249 | - $result[ $font_family ] = array(); |
|
248 | + if (!isset($result[$font_family])) { |
|
249 | + $result[$font_family] = array(); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | // Get files for this font-family and add them to the array. |
253 | 253 | |
254 | - foreach ( $matched_font_files as $match ) { |
|
254 | + foreach ($matched_font_files as $match) { |
|
255 | 255 | |
256 | 256 | // Sanity check. |
257 | - if ( ! isset( $match[0] ) ) { |
|
257 | + if (!isset($match[0])) { |
|
258 | 258 | continue; |
259 | 259 | } |
260 | 260 | |
261 | 261 | // Add the file URL. |
262 | - $result[ $font_family ][] = rtrim( ltrim( $match[0], 'url(' ), ')' ); |
|
262 | + $result[$font_family][] = rtrim(ltrim($match[0], 'url('), ')'); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | // Make sure we have unique items. |
266 | 266 | // We're using array_flip here instead of array_unique for improved performance. |
267 | - $result[ $font_family ] = array_flip( array_flip( $result[ $font_family ] ) ); |
|
267 | + $result[$font_family] = array_flip(array_flip($result[$font_family])); |
|
268 | 268 | } |
269 | 269 | return $result; |
270 | 270 | } |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | */ |
279 | 279 | protected function get_filesystem() { |
280 | 280 | global $wp_filesystem; |
281 | - if ( ! $wp_filesystem ) { |
|
282 | - if ( ! function_exists( 'WP_Filesystem' ) ) { |
|
283 | - require_once wp_normalize_path( ABSPATH . '/wp-admin/includes/file.php' ); |
|
281 | + if (!$wp_filesystem) { |
|
282 | + if (!function_exists('WP_Filesystem')) { |
|
283 | + require_once wp_normalize_path(ABSPATH . '/wp-admin/includes/file.php'); |
|
284 | 284 | } |
285 | 285 | WP_Filesystem(); |
286 | 286 | } |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | * @param object $googlefonts The \Kirki\Module\Webfonts\Google object. |
65 | 65 | * @param array $args Extra args we want to pass. |
66 | 66 | */ |
67 | - public function __construct( $config_id, $webfonts, $googlefonts, $args = [] ) { |
|
67 | + public function __construct($config_id, $webfonts, $googlefonts, $args = []) { |
|
68 | 68 | $this->config_id = $config_id; |
69 | 69 | $this->webfonts = $webfonts; |
70 | 70 | $this->googlefonts = $googlefonts; |
71 | 71 | |
72 | - add_action( 'wp', [ $this, 'init' ], 9 ); |
|
72 | + add_action('wp', [$this, 'init'], 9); |
|
73 | 73 | // add_filter( 'wp_resource_hints', [ $this, 'resource_hints' ], 10, 2 ); |
74 | 74 | } |
75 | 75 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | public function init() { |
84 | 84 | $this->populate_fonts(); |
85 | - add_action( 'kirki_dynamic_css', [ $this, 'the_css' ] ); |
|
85 | + add_action('kirki_dynamic_css', [$this, 'the_css']); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | * @param string $relation_type The relation type the URLs are printed. |
94 | 94 | * @return array $urls URLs to print for resource hints. |
95 | 95 | */ |
96 | - public function resource_hints( $urls, $relation_type ) { |
|
96 | + public function resource_hints($urls, $relation_type) { |
|
97 | 97 | $fonts_to_load = $this->googlefonts->fonts; |
98 | 98 | |
99 | - if ( ! empty( $fonts_to_load ) && 'preconnect' === $relation_type ) { |
|
99 | + if (!empty($fonts_to_load) && 'preconnect' === $relation_type) { |
|
100 | 100 | $urls[] = [ |
101 | 101 | 'href' => 'https://fonts.gstatic.com', |
102 | 102 | 'crossorigin', |
@@ -115,19 +115,19 @@ discard block |
||
115 | 115 | public function populate_fonts() { |
116 | 116 | |
117 | 117 | // Go through our fields and populate $this->fonts. |
118 | - $this->webfonts->loop_fields( $this->config_id ); |
|
118 | + $this->webfonts->loop_fields($this->config_id); |
|
119 | 119 | |
120 | - $this->googlefonts->fonts = apply_filters( 'kirki_enqueue_google_fonts', $this->googlefonts->fonts ); |
|
120 | + $this->googlefonts->fonts = apply_filters('kirki_enqueue_google_fonts', $this->googlefonts->fonts); |
|
121 | 121 | |
122 | 122 | // Goes through $this->fonts and adds or removes things as needed. |
123 | 123 | $this->googlefonts->process_fonts(); |
124 | 124 | |
125 | - foreach ( $this->googlefonts->fonts as $font => $weights ) { |
|
126 | - foreach ( $weights as $key => $value ) { |
|
127 | - if ( 'italic' === $value ) { |
|
128 | - $weights[ $key ] = '400i'; |
|
125 | + foreach ($this->googlefonts->fonts as $font => $weights) { |
|
126 | + foreach ($weights as $key => $value) { |
|
127 | + if ('italic' === $value) { |
|
128 | + $weights[$key] = '400i'; |
|
129 | 129 | } else { |
130 | - $weights[ $key ] = str_replace( [ 'regular', 'bold', 'italic' ], [ '400', '', 'i' ], $value ); |
|
130 | + $weights[$key] = str_replace(['regular', 'bold', 'italic'], ['400', '', 'i'], $value); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | $this->fonts_to_load[] = [ |
@@ -144,16 +144,16 @@ discard block |
||
144 | 144 | * @since 1.0.0 |
145 | 145 | */ |
146 | 146 | public function the_css() { |
147 | - foreach ( $this->fonts_to_load as $font ) { |
|
147 | + foreach ($this->fonts_to_load as $font) { |
|
148 | 148 | |
149 | - $family = str_replace( ' ', '+', trim( $font['family'] ) ); |
|
150 | - $weights = join( ',', $font['weights'] ); |
|
149 | + $family = str_replace(' ', '+', trim($font['family'])); |
|
150 | + $weights = join(',', $font['weights']); |
|
151 | 151 | $url = "https://fonts.googleapis.com/css?family={$family}:{$weights}&subset=cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai&display=swap"; |
152 | 152 | |
153 | 153 | $downloader = new Downloader(); |
154 | - $contents = $downloader->get_styles( $url ); |
|
154 | + $contents = $downloader->get_styles($url); |
|
155 | 155 | |
156 | - if ( $contents ) { |
|
156 | + if ($contents) { |
|
157 | 157 | /** |
158 | 158 | * Note to code reviewers: |
159 | 159 | * |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * For extra security we're using the wp_strip_all_tags() function here |
164 | 164 | * just to make sure there's no <script> tags in there or anything else. |
165 | 165 | */ |
166 | - echo wp_strip_all_tags( $contents ); // phpcs:ignore WordPress.Security.EscapeOutput |
|
166 | + echo wp_strip_all_tags($contents); // phpcs:ignore WordPress.Security.EscapeOutput |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | } |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | * @param string $css The CSS with original URLs. |
178 | 178 | * @return string The CSS with local URLs. |
179 | 179 | */ |
180 | - private function use_local_files( $css ) { |
|
181 | - preg_match_all( '/https\:.*?\.woff/', $css, $matches ); |
|
180 | + private function use_local_files($css) { |
|
181 | + preg_match_all('/https\:.*?\.woff/', $css, $matches); |
|
182 | 182 | |
183 | - $matches = array_shift( $matches ); |
|
183 | + $matches = array_shift($matches); |
|
184 | 184 | |
185 | - foreach ( $matches as $match ) { |
|
186 | - if ( 0 === strpos( $match, 'https://fonts.gstatic.com' ) ) { |
|
187 | - $new_url = Helper::download_font_file( $match ); |
|
188 | - if ( $new_url ) { |
|
189 | - $css = str_replace( $match, $new_url, $css ); |
|
185 | + foreach ($matches as $match) { |
|
186 | + if (0 === strpos($match, 'https://fonts.gstatic.com')) { |
|
187 | + $new_url = Helper::download_font_file($match); |
|
188 | + if ($new_url) { |
|
189 | + $css = str_replace($match, $new_url, $css); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | } |
@@ -74,17 +74,17 @@ discard block |
||
74 | 74 | * @param object $googlefonts The \Kirki\Module\Webfonts\Google object. |
75 | 75 | * @param array $args Extra args we want to pass. |
76 | 76 | */ |
77 | - public function __construct( $config_id, $webfonts, $googlefonts, $args = [] ) { |
|
77 | + public function __construct($config_id, $webfonts, $googlefonts, $args = []) { |
|
78 | 78 | $this->config_id = $config_id; |
79 | 79 | $this->webfonts = $webfonts; |
80 | 80 | $this->googlefonts = $googlefonts; |
81 | 81 | |
82 | - add_action( 'wp_head', [ $this, 'webfont_loader' ] ); |
|
83 | - add_action( 'wp_head', [ $this, 'webfont_loader_script' ], 30 ); |
|
82 | + add_action('wp_head', [$this, 'webfont_loader']); |
|
83 | + add_action('wp_head', [$this, 'webfont_loader_script'], 30); |
|
84 | 84 | |
85 | 85 | // Add these in the dashboard to support editor-styles. |
86 | - add_action( 'admin_enqueue_scripts', [ $this, 'webfont_loader' ] ); |
|
87 | - add_action( 'admin_enqueue_scripts', [ $this, 'webfont_loader_script' ], 30 ); |
|
86 | + add_action('admin_enqueue_scripts', [$this, 'webfont_loader']); |
|
87 | + add_action('admin_enqueue_scripts', [$this, 'webfont_loader_script'], 30); |
|
88 | 88 | |
89 | 89 | // add_filter( 'wp_resource_hints', [ $this, 'resource_hints' ], 10, 2 ); |
90 | 90 | } |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | * @param string $relation_type The relation type the URLs are printed. |
98 | 98 | * @return array $urls URLs to print for resource hints. |
99 | 99 | */ |
100 | - public function resource_hints( $urls, $relation_type ) { |
|
100 | + public function resource_hints($urls, $relation_type) { |
|
101 | 101 | $fonts_to_load = $this->googlefonts->fonts; |
102 | 102 | |
103 | - if ( ! empty( $fonts_to_load ) && 'preconnect' === $relation_type ) { |
|
103 | + if (!empty($fonts_to_load) && 'preconnect' === $relation_type) { |
|
104 | 104 | $urls[] = [ |
105 | 105 | 'href' => 'https://fonts.gstatic.com', |
106 | 106 | 'crossorigin', |
@@ -118,30 +118,30 @@ discard block |
||
118 | 118 | public function webfont_loader() { |
119 | 119 | |
120 | 120 | // Go through our fields and populate $this->fonts. |
121 | - $this->webfonts->loop_fields( $this->config_id ); |
|
121 | + $this->webfonts->loop_fields($this->config_id); |
|
122 | 122 | |
123 | - $this->googlefonts->fonts = apply_filters( 'kirki_enqueue_google_fonts', $this->googlefonts->fonts ); |
|
123 | + $this->googlefonts->fonts = apply_filters('kirki_enqueue_google_fonts', $this->googlefonts->fonts); |
|
124 | 124 | |
125 | 125 | // Goes through $this->fonts and adds or removes things as needed. |
126 | 126 | $this->googlefonts->process_fonts(); |
127 | 127 | |
128 | - foreach ( $this->googlefonts->fonts as $font => $weights ) { |
|
129 | - foreach ( $weights as $key => $value ) { |
|
130 | - if ( 'italic' === $value ) { |
|
131 | - $weights[ $key ] = '400i'; |
|
128 | + foreach ($this->googlefonts->fonts as $font => $weights) { |
|
129 | + foreach ($weights as $key => $value) { |
|
130 | + if ('italic' === $value) { |
|
131 | + $weights[$key] = '400i'; |
|
132 | 132 | } else { |
133 | - $weights[ $key ] = str_replace( [ 'regular', 'bold', 'italic' ], [ '400', '', 'i' ], $value ); |
|
133 | + $weights[$key] = str_replace(['regular', 'bold', 'italic'], ['400', '', 'i'], $value); |
|
134 | 134 | } |
135 | 135 | } |
136 | - $this->fonts_to_load[] = $font . ':' . join( ',', $weights ) . ':cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai'; |
|
136 | + $this->fonts_to_load[] = $font . ':' . join(',', $weights) . ':cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai'; |
|
137 | 137 | } |
138 | - if ( ! empty( $this->fonts_to_load ) ) { |
|
138 | + if (!empty($this->fonts_to_load)) { |
|
139 | 139 | self::$load = true; |
140 | 140 | } |
141 | 141 | |
142 | 142 | global $wp_customize; |
143 | - if ( self::$load || $wp_customize || is_customize_preview() ) { |
|
144 | - wp_enqueue_script( 'webfont-loader', URL::get_from_path( dirname( __DIR__ ) . '/assets/scripts/vendor-typekit/webfontloader.js' ), [], '3.0.28', true ); |
|
143 | + if (self::$load || $wp_customize || is_customize_preview()) { |
|
144 | + wp_enqueue_script('webfont-loader', URL::get_from_path(dirname(__DIR__) . '/assets/scripts/vendor-typekit/webfontloader.js'), [], '3.0.28', true); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | * @since 1.0.0 |
153 | 153 | */ |
154 | 154 | public function webfont_loader_script() { |
155 | - if ( ! empty( $this->fonts_to_load ) ) { |
|
155 | + if (!empty($this->fonts_to_load)) { |
|
156 | 156 | wp_add_inline_script( |
157 | 157 | 'webfont-loader', |
158 | - 'WebFont.load({google:{families:[\'' . join( '\', \'', $this->fonts_to_load ) . '\']}});', |
|
158 | + 'WebFont.load({google:{families:[\'' . join('\', \'', $this->fonts_to_load) . '\']}});', |
|
159 | 159 | 'after' |
160 | 160 | ); |
161 | 161 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * @param bool $load Set to false to disable loading. |
170 | 170 | * @return void |
171 | 171 | */ |
172 | - public function set_load( $load ) { |
|
172 | + public function set_load($load) { |
|
173 | 173 | self::$load = $load; |
174 | 174 | } |
175 | 175 | } |
@@ -77,16 +77,16 @@ discard block |
||
77 | 77 | * The class constructor. |
78 | 78 | */ |
79 | 79 | private function __construct() { |
80 | - $config = apply_filters( 'kirki_config', [] ); |
|
80 | + $config = apply_filters('kirki_config', []); |
|
81 | 81 | |
82 | 82 | // If we have set $config['disable_google_fonts'] to true then do not proceed any further. |
83 | - if ( isset( $config['disable_google_fonts'] ) && true === $config['disable_google_fonts'] ) { |
|
83 | + if (isset($config['disable_google_fonts']) && true === $config['disable_google_fonts']) { |
|
84 | 84 | return; |
85 | 85 | } |
86 | 86 | |
87 | 87 | new GoogleFonts(); |
88 | - add_action( 'wp_ajax_kirki_fonts_standard_all_get', [ $this, 'get_standardfonts_json' ] ); |
|
89 | - add_action( 'wp_ajax_nopriv_kirki_fonts_standard_all_get', [ $this, 'get_standardfonts_json' ] ); |
|
88 | + add_action('wp_ajax_kirki_fonts_standard_all_get', [$this, 'get_standardfonts_json']); |
|
89 | + add_action('wp_ajax_nopriv_kirki_fonts_standard_all_get', [$this, 'get_standardfonts_json']); |
|
90 | 90 | |
91 | 91 | // Populate the array of google fonts. |
92 | 92 | $this->google_fonts = Fonts::get_google_fonts(); |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return object Google |
100 | 100 | */ |
101 | 101 | public static function get_instance() { |
102 | - if ( null === self::$instance ) { |
|
102 | + if (null === self::$instance) { |
|
103 | 103 | self::$instance = new self(); |
104 | 104 | } |
105 | 105 | return self::$instance; |
@@ -112,77 +112,77 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @param array $args The field arguments. |
114 | 114 | */ |
115 | - public function generate_google_font( $args ) { |
|
115 | + public function generate_google_font($args) { |
|
116 | 116 | |
117 | 117 | // Process typography fields. |
118 | - $process = ( ( isset( $args['type'] ) && 'kirki-typography' === $args['type'] ) || ( isset( $args['choices'] ) && isset( $args['choices']['parent_type'] ) && 'kirki-typography' === $args['choices']['parent_type'] ) ); |
|
119 | - if ( apply_filters( 'kirki_generate_google_font', $process, $args ) ) { |
|
118 | + $process = ((isset($args['type']) && 'kirki-typography' === $args['type']) || (isset($args['choices']) && isset($args['choices']['parent_type']) && 'kirki-typography' === $args['choices']['parent_type'])); |
|
119 | + if (apply_filters('kirki_generate_google_font', $process, $args)) { |
|
120 | 120 | |
121 | 121 | // Get the value. |
122 | - $option_type = ( isset( $args['option_type'] ) ) ? $args['option_type'] : 'theme_mod'; |
|
123 | - $default = ( isset( $args['default'] ) ) ? $args['default'] : ''; |
|
124 | - $value = apply_filters( 'kirki_get_value', get_theme_mod( $args['settings'], $default ), $args['settings'], $default, $option_type ); |
|
122 | + $option_type = (isset($args['option_type'])) ? $args['option_type'] : 'theme_mod'; |
|
123 | + $default = (isset($args['default'])) ? $args['default'] : ''; |
|
124 | + $value = apply_filters('kirki_get_value', get_theme_mod($args['settings'], $default), $args['settings'], $default, $option_type); |
|
125 | 125 | |
126 | 126 | // If we don't have a font-family then we can skip this. |
127 | - if ( ! isset( $value['font-family'] ) || in_array( $value['font-family'], $this->hosted_fonts, true ) ) { |
|
127 | + if (!isset($value['font-family']) || in_array($value['font-family'], $this->hosted_fonts, true)) { |
|
128 | 128 | return; |
129 | 129 | } |
130 | 130 | |
131 | 131 | // If not a google-font, then we can skip this. |
132 | - if ( ! isset( $value['font-family'] ) || ! Fonts::is_google_font( $value['font-family'] ) ) { |
|
132 | + if (!isset($value['font-family']) || !Fonts::is_google_font($value['font-family'])) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Set a default value for variants. |
137 | - if ( ! isset( $value['variant'] ) ) { |
|
137 | + if (!isset($value['variant'])) { |
|
138 | 138 | $value['variant'] = 'regular'; |
139 | 139 | } |
140 | 140 | |
141 | 141 | // Add the requested google-font. |
142 | - if ( ! is_array( $value ) || ! isset( $value['font-family'] ) || ! isset( $this->fonts[ $value['font-family'] ] ) ) { |
|
143 | - $this->fonts[ $value['font-family'] ] = []; |
|
142 | + if (!is_array($value) || !isset($value['font-family']) || !isset($this->fonts[$value['font-family']])) { |
|
143 | + $this->fonts[$value['font-family']] = []; |
|
144 | 144 | } |
145 | - if ( ! in_array( $value['variant'], $this->fonts[ $value['font-family'] ], true ) ) { |
|
146 | - $this->fonts[ $value['font-family'] ][] = $value['variant']; |
|
145 | + if (!in_array($value['variant'], $this->fonts[$value['font-family']], true)) { |
|
146 | + $this->fonts[$value['font-family']][] = $value['variant']; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | // Are we force-loading all variants? |
150 | - if ( true === self::$force_load_all_variants ) { |
|
150 | + if (true === self::$force_load_all_variants) { |
|
151 | 151 | $all_variants = Fonts::get_all_variants(); |
152 | - $args['choices']['variant'] = array_keys( $all_variants ); |
|
152 | + $args['choices']['variant'] = array_keys($all_variants); |
|
153 | 153 | } |
154 | 154 | |
155 | - if ( ! empty( $args['choices']['variant'] ) && is_array( $args['choices']['variant'] ) ) { |
|
156 | - foreach ( $args['choices']['variant'] as $extra_variant ) { |
|
157 | - $this->fonts[ $value['font-family'] ][] = $extra_variant; |
|
155 | + if (!empty($args['choices']['variant']) && is_array($args['choices']['variant'])) { |
|
156 | + foreach ($args['choices']['variant'] as $extra_variant) { |
|
157 | + $this->fonts[$value['font-family']][] = $extra_variant; |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | return; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // Process non-typography fields. |
164 | - if ( isset( $args['output'] ) && is_array( $args['output'] ) ) { |
|
165 | - foreach ( $args['output'] as $output ) { |
|
164 | + if (isset($args['output']) && is_array($args['output'])) { |
|
165 | + foreach ($args['output'] as $output) { |
|
166 | 166 | |
167 | 167 | // If we don't have a typography-related output argument we can skip this. |
168 | - if ( ! isset( $output['property'] ) || ! in_array( $output['property'], [ 'font-family', 'font-weight' ], true ) ) { |
|
168 | + if (!isset($output['property']) || !in_array($output['property'], ['font-family', 'font-weight'], true)) { |
|
169 | 169 | continue; |
170 | 170 | } |
171 | 171 | |
172 | 172 | // Get the value. |
173 | - $option_type = ( isset( $args['option_type'] ) ) ? $args['option_type'] : 'theme_mod'; |
|
174 | - $default = ( isset( $args['default'] ) ) ? $args['default'] : ''; |
|
175 | - $value = apply_filters( 'kirki_get_value', get_theme_mod( $args['settings'], $default ), $args['settings'], $default, $option_type ); |
|
176 | - |
|
177 | - if ( is_string( $value ) ) { |
|
178 | - if ( 'font-family' === $output['property'] ) { |
|
179 | - if ( ! array_key_exists( $value, $this->fonts ) ) { |
|
180 | - $this->fonts[ $value ] = []; |
|
173 | + $option_type = (isset($args['option_type'])) ? $args['option_type'] : 'theme_mod'; |
|
174 | + $default = (isset($args['default'])) ? $args['default'] : ''; |
|
175 | + $value = apply_filters('kirki_get_value', get_theme_mod($args['settings'], $default), $args['settings'], $default, $option_type); |
|
176 | + |
|
177 | + if (is_string($value)) { |
|
178 | + if ('font-family' === $output['property']) { |
|
179 | + if (!array_key_exists($value, $this->fonts)) { |
|
180 | + $this->fonts[$value] = []; |
|
181 | 181 | } |
182 | - } elseif ( 'font-weight' === $output['property'] ) { |
|
183 | - foreach ( $this->fonts as $font => $variants ) { |
|
184 | - if ( ! in_array( $value, $variants, true ) ) { |
|
185 | - $this->fonts[ $font ][] = $value; |
|
182 | + } elseif ('font-weight' === $output['property']) { |
|
183 | + foreach ($this->fonts as $font => $variants) { |
|
184 | + if (!in_array($value, $variants, true)) { |
|
185 | + $this->fonts[$font][] = $value; |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | } |
@@ -199,31 +199,31 @@ discard block |
||
199 | 199 | public function process_fonts() { |
200 | 200 | |
201 | 201 | // Early exit if font-family is empty. |
202 | - if ( empty( $this->fonts ) ) { |
|
202 | + if (empty($this->fonts)) { |
|
203 | 203 | return; |
204 | 204 | } |
205 | 205 | |
206 | - foreach ( $this->fonts as $font => $variants ) { |
|
206 | + foreach ($this->fonts as $font => $variants) { |
|
207 | 207 | |
208 | 208 | // Determine if this is indeed a google font or not. |
209 | 209 | // If it's not, then just remove it from the array. |
210 | - if ( ! array_key_exists( $font, $this->google_fonts ) ) { |
|
211 | - unset( $this->fonts[ $font ] ); |
|
210 | + if (!array_key_exists($font, $this->google_fonts)) { |
|
211 | + unset($this->fonts[$font]); |
|
212 | 212 | continue; |
213 | 213 | } |
214 | 214 | |
215 | 215 | // Get all valid font variants for this font. |
216 | 216 | $font_variants = []; |
217 | - if ( isset( $this->google_fonts[ $font ]['variants'] ) ) { |
|
218 | - $font_variants = $this->google_fonts[ $font ]['variants']; |
|
217 | + if (isset($this->google_fonts[$font]['variants'])) { |
|
218 | + $font_variants = $this->google_fonts[$font]['variants']; |
|
219 | 219 | } |
220 | - foreach ( $variants as $variant ) { |
|
220 | + foreach ($variants as $variant) { |
|
221 | 221 | |
222 | 222 | // If this is not a valid variant for this font-family |
223 | 223 | // then unset it and move on to the next one. |
224 | - if ( ! in_array( strval( $variant ), $font_variants, true ) ) { |
|
225 | - $variant_key = array_search( $variant, $this->fonts[ $font ], true ); |
|
226 | - unset( $this->fonts[ $font ][ $variant_key ] ); |
|
224 | + if (!in_array(strval($variant), $font_variants, true)) { |
|
225 | + $variant_key = array_search($variant, $this->fonts[$font], true); |
|
226 | + unset($this->fonts[$font][$variant_key]); |
|
227 | 227 | continue; |
228 | 228 | } |
229 | 229 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @return void |
238 | 238 | */ |
239 | 239 | public function get_standardfonts_json() { |
240 | - echo wp_json_encode( Fonts::get_standard_fonts() ); |
|
240 | + echo wp_json_encode(Fonts::get_standard_fonts()); |
|
241 | 241 | wp_die(); |
242 | 242 | } |
243 | 243 | } |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @param array $args The field arguments. |
57 | 57 | */ |
58 | - protected function init( $args ) { |
|
58 | + protected function init($args) { |
|
59 | 59 | |
60 | - add_action( 'customize_preview_init', [ $this, 'enqueue_customize_preview_scripts' ] ); |
|
61 | - add_filter( 'kirki_output_control_classnames', [ $this, 'output_control_classnames' ] ); |
|
60 | + add_action('customize_preview_init', [$this, 'enqueue_customize_preview_scripts']); |
|
61 | + add_filter('kirki_output_control_classnames', [$this, 'output_control_classnames']); |
|
62 | 62 | |
63 | 63 | } |
64 | 64 | |
@@ -71,30 +71,30 @@ discard block |
||
71 | 71 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
72 | 72 | * @return array |
73 | 73 | */ |
74 | - public function filter_setting_args( $args, $wp_customize ) { |
|
74 | + public function filter_setting_args($args, $wp_customize) { |
|
75 | 75 | |
76 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
77 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
76 | + if ($args['settings'] === $this->args['settings']) { |
|
77 | + $args = parent::filter_setting_args($args, $wp_customize); |
|
78 | 78 | |
79 | 79 | // Set the sanitize-callback if none is defined. |
80 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
81 | - $args['sanitize_callback'] = [ __CLASS__, 'sanitize' ]; |
|
80 | + if (!isset($args['sanitize_callback']) || !$args['sanitize_callback']) { |
|
81 | + $args['sanitize_callback'] = [__CLASS__, 'sanitize']; |
|
82 | 82 | |
83 | 83 | // If this is a hue control then its value should be an integer. |
84 | - if ( isset( $args['mode'] ) && 'hue' === $args['mode'] ) { |
|
84 | + if (isset($args['mode']) && 'hue' === $args['mode']) { |
|
85 | 85 | $args['sanitize_callback'] = 'absint'; |
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | 89 | // For postMessage/preview purpose, if property is not set, then set it to 'color'. |
90 | - if ( isset( $args['output'] ) && ! empty( $args['output'] ) && is_array( $args['output'] ) && ! isset( $args['output']['element'] ) ) { |
|
91 | - foreach ( $args['output'] as $index => $output ) { |
|
92 | - if ( ! isset( $output['property'] ) ) { |
|
93 | - if ( empty( $args['output'][ $index ] ) ) { |
|
94 | - $args['output'][ $index ] = []; |
|
90 | + if (isset($args['output']) && !empty($args['output']) && is_array($args['output']) && !isset($args['output']['element'])) { |
|
91 | + foreach ($args['output'] as $index => $output) { |
|
92 | + if (!isset($output['property'])) { |
|
93 | + if (empty($args['output'][$index])) { |
|
94 | + $args['output'][$index] = []; |
|
95 | 95 | } |
96 | 96 | |
97 | - $args['output'][ $index ]['property'] = 'color'; |
|
97 | + $args['output'][$index]['property'] = 'color'; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | } |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
114 | 114 | * @return array |
115 | 115 | */ |
116 | - public function filter_control_args( $args, $wp_customize ) { |
|
116 | + public function filter_control_args($args, $wp_customize) { |
|
117 | 117 | |
118 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
119 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
118 | + if ($args['settings'] === $this->args['settings']) { |
|
119 | + $args = parent::filter_control_args($args, $wp_customize); |
|
120 | 120 | $args['type'] = 'kirki-react-colorful'; |
121 | 121 | } |
122 | 122 | |
@@ -134,20 +134,20 @@ discard block |
||
134 | 134 | * @param string|array $value The color. |
135 | 135 | * @return string|array |
136 | 136 | */ |
137 | - public static function sanitize( $value ) { |
|
137 | + public static function sanitize($value) { |
|
138 | 138 | |
139 | 139 | $sanitized_value = ''; |
140 | 140 | |
141 | - if ( is_string( $value ) ) { |
|
142 | - $sanitized_value = self::sanitize_color_string( $value ); |
|
143 | - } elseif ( is_array( $value ) ) { |
|
144 | - if ( isset( $value['r'] ) || isset( $value['g'] ) || isset( $value['b'] ) ) { |
|
145 | - $sanitized_value = self::sanitize_color_array( $value, 'rgb' ); |
|
146 | - } elseif ( isset( $value['h'] ) || isset( $value['s'] ) ) { |
|
147 | - if ( isset( $value['l'] ) ) { |
|
148 | - $sanitized_value = self::sanitize_color_array( $value, 'hsl' ); |
|
149 | - } elseif ( isset( $value['v'] ) ) { |
|
150 | - $sanitized_value = self::sanitize_color_array( $value, 'hsv' ); |
|
141 | + if (is_string($value)) { |
|
142 | + $sanitized_value = self::sanitize_color_string($value); |
|
143 | + } elseif (is_array($value)) { |
|
144 | + if (isset($value['r']) || isset($value['g']) || isset($value['b'])) { |
|
145 | + $sanitized_value = self::sanitize_color_array($value, 'rgb'); |
|
146 | + } elseif (isset($value['h']) || isset($value['s'])) { |
|
147 | + if (isset($value['l'])) { |
|
148 | + $sanitized_value = self::sanitize_color_array($value, 'hsl'); |
|
149 | + } elseif (isset($value['v'])) { |
|
150 | + $sanitized_value = self::sanitize_color_array($value, 'hsv'); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | } |
@@ -164,39 +164,39 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return array The sanitized color. |
166 | 166 | */ |
167 | - public static function sanitize_color_array( $color, $color_type = 'rgb' ) { |
|
167 | + public static function sanitize_color_array($color, $color_type = 'rgb') { |
|
168 | 168 | |
169 | - $keys = [ 'r', 'g', 'b' ]; |
|
170 | - $mins = [ 0, 0, 0 ]; |
|
171 | - $maxs = [ 255, 255, 255 ]; |
|
169 | + $keys = ['r', 'g', 'b']; |
|
170 | + $mins = [0, 0, 0]; |
|
171 | + $maxs = [255, 255, 255]; |
|
172 | 172 | |
173 | - if ( 'hsl' === $color_type || 'hsv' === $color_type ) { |
|
174 | - $keys = [ 'h', 's', '' ]; |
|
175 | - $keys[2] = isset( $color['v'] ) ? 'v' : 'l'; |
|
173 | + if ('hsl' === $color_type || 'hsv' === $color_type) { |
|
174 | + $keys = ['h', 's', '']; |
|
175 | + $keys[2] = isset($color['v']) ? 'v' : 'l'; |
|
176 | 176 | |
177 | - $mins = [ 0, 0, 0 ]; |
|
178 | - $maxs = [ 360, 100, 100 ]; |
|
177 | + $mins = [0, 0, 0]; |
|
178 | + $maxs = [360, 100, 100]; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | $sanitized_color = []; |
182 | 182 | |
183 | 183 | $sanitized_color = [ |
184 | - $keys[0] => isset( $color[ $keys[0] ] ) ? absint( $color[ $keys[0] ] ) : $mins[0], |
|
185 | - $keys[1] => isset( $color[ $keys[1] ] ) ? absint( $color[ $keys[1] ] ) : $mins[1], |
|
186 | - $keys[2] => isset( $color[ $keys[2] ] ) ? absint( $color[ $keys[2] ] ) : $mins[2], |
|
184 | + $keys[0] => isset($color[$keys[0]]) ? absint($color[$keys[0]]) : $mins[0], |
|
185 | + $keys[1] => isset($color[$keys[1]]) ? absint($color[$keys[1]]) : $mins[1], |
|
186 | + $keys[2] => isset($color[$keys[2]]) ? absint($color[$keys[2]]) : $mins[2], |
|
187 | 187 | ]; |
188 | 188 | |
189 | - $sanitized_color[ $keys[0] ] = $sanitized_color[ $keys[0] ] < $mins[0] ? $mins[0] : $sanitized_color[ $keys[0] ]; |
|
190 | - $sanitized_color[ $keys[0] ] = $sanitized_color[ $keys[0] ] > $maxs[0] ? $maxs[0] : $sanitized_color[ $keys[0] ]; |
|
189 | + $sanitized_color[$keys[0]] = $sanitized_color[$keys[0]] < $mins[0] ? $mins[0] : $sanitized_color[$keys[0]]; |
|
190 | + $sanitized_color[$keys[0]] = $sanitized_color[$keys[0]] > $maxs[0] ? $maxs[0] : $sanitized_color[$keys[0]]; |
|
191 | 191 | |
192 | - $sanitized_color[ $keys[1] ] = $sanitized_color[ $keys[1] ] < $mins[1] ? $mins[1] : $sanitized_color[ $keys[1] ]; |
|
193 | - $sanitized_color[ $keys[1] ] = $sanitized_color[ $keys[1] ] > $maxs[1] ? $maxs[1] : $sanitized_color[ $keys[1] ]; |
|
192 | + $sanitized_color[$keys[1]] = $sanitized_color[$keys[1]] < $mins[1] ? $mins[1] : $sanitized_color[$keys[1]]; |
|
193 | + $sanitized_color[$keys[1]] = $sanitized_color[$keys[1]] > $maxs[1] ? $maxs[1] : $sanitized_color[$keys[1]]; |
|
194 | 194 | |
195 | - $sanitized_color[ $keys[2] ] = $sanitized_color[ $keys[2] ] < $mins[2] ? $mins[2] : $sanitized_color[ $keys[2] ]; |
|
196 | - $sanitized_color[ $keys[2] ] = $sanitized_color[ $keys[2] ] > $maxs[2] ? $maxs[2] : $sanitized_color[ $keys[2] ]; |
|
195 | + $sanitized_color[$keys[2]] = $sanitized_color[$keys[2]] < $mins[2] ? $mins[2] : $sanitized_color[$keys[2]]; |
|
196 | + $sanitized_color[$keys[2]] = $sanitized_color[$keys[2]] > $maxs[2] ? $maxs[2] : $sanitized_color[$keys[2]]; |
|
197 | 197 | |
198 | - if ( isset( $color['a'] ) ) { |
|
199 | - $sanitized_color['a'] = isset( $color['a'] ) ? filter_var( $color['a'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ) : 1; |
|
198 | + if (isset($color['a'])) { |
|
199 | + $sanitized_color['a'] = isset($color['a']) ? filter_var($color['a'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : 1; |
|
200 | 200 | $sanitized_color['a'] = $sanitized_color['a'] < 0 ? 0 : $sanitized_color['a']; |
201 | 201 | $sanitized_color['a'] = $sanitized_color['a'] > 1 ? 1 : $sanitized_color['a']; |
202 | 202 | } |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | * @param string $value The color. |
216 | 216 | * @return string |
217 | 217 | */ |
218 | - public static function sanitize_color_string( $value ) { |
|
218 | + public static function sanitize_color_string($value) { |
|
219 | 219 | |
220 | - $value = strtolower( $value ); |
|
220 | + $value = strtolower($value); |
|
221 | 221 | |
222 | 222 | /** |
223 | 223 | * This pattern will check and match 3/6/8-character hex, rgb, rgba, hsl, hsla, hsv, and hsva colors. |
@@ -249,15 +249,15 @@ discard block |
||
249 | 249 | */ |
250 | 250 | $pattern = '/^(\#[\da-f]{3}|\#[\da-f]{6}|\#[\da-f]{8}|rgba\(((\d{1,2}|1\d\d|2([0-4]\d|5[0-5]))\s*,\s*){2}((\d{1,2}|1\d\d|2([0-4]\d|5[0-5]))\s*)(,\s*(0\.\d+|1))\)|rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)|hsla\(\s*((\d{1,2}|[1-2]\d{2}|3([0-5]\d|60)))\s*,\s*((\d{1,2}|100)\s*%)\s*,\s*((\d{1,2}|100)\s*%)(,\s*(0\.\d+|1))\)|hsl\(\s*((\d{1,2}|[1-2]\d{2}|3([0-5]\d|60)))\s*,\s*((\d{1,2}|100)\s*%)\s*,\s*((\d{1,2}|100)\s*%)\)|hsva\(\s*((\d{1,2}|[1-2]\d{2}|3([0-5]\d|60)))\s*,\s*((\d{1,2}|100)\s*%)\s*,\s*((\d{1,2}|100)\s*%)(,\s*(0\.\d+|1))\)|hsv\(\s*((\d{1,2}|[1-2]\d{2}|3([0-5]\d|60)))\s*,\s*((\d{1,2}|100)\s*%)\s*,\s*((\d{1,2}|100)\s*%)\))$/'; |
251 | 251 | |
252 | - preg_match( $pattern, $value, $matches ); |
|
252 | + preg_match($pattern, $value, $matches); |
|
253 | 253 | |
254 | 254 | // Return the 1st match found. |
255 | - if ( isset( $matches[0] ) ) { |
|
256 | - if ( is_string( $matches[0] ) ) { |
|
255 | + if (isset($matches[0])) { |
|
256 | + if (is_string($matches[0])) { |
|
257 | 257 | return $matches[0]; |
258 | 258 | } |
259 | 259 | |
260 | - if ( is_array( $matches[0] ) && isset( $matches[0][0] ) ) { |
|
260 | + if (is_array($matches[0]) && isset($matches[0][0])) { |
|
261 | 261 | return $matches[0][0]; |
262 | 262 | } |
263 | 263 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | */ |
275 | 275 | public function enqueue_customize_preview_scripts() { |
276 | 276 | |
277 | - wp_enqueue_script( 'kirki-react-colorful', URL::get_from_path( dirname( dirname( __DIR__ ) ) ) . '/dist/preview.js', [ 'wp-hooks', 'customize-preview' ], $this->control_class::$control_ver, true ); |
|
277 | + wp_enqueue_script('kirki-react-colorful', URL::get_from_path(dirname(dirname(__DIR__))) . '/dist/preview.js', ['wp-hooks', 'customize-preview'], $this->control_class::$control_ver, true); |
|
278 | 278 | |
279 | 279 | } |
280 | 280 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @param array $control_classes The existing control classes. |
288 | 288 | * @return array |
289 | 289 | */ |
290 | - public function output_control_classnames( $control_classes ) { |
|
290 | + public function output_control_classnames($control_classes) { |
|
291 | 291 | |
292 | 292 | $control_classes['kirki-react-colorful'] = '\Kirki\Field\CSS\ReactColorful'; |
293 | 293 |