Test Setup Failed
Pull Request — develop (#1708)
by Aristeides
02:04
created
modules/webfonts/class-kirki-fonts.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -137,11 +137,11 @@
 block discarded – undo
137 137
 
138 138
 		$google_fonts = array();
139 139
 		if ( is_array( $fonts ) ) {
140
-			foreach ( $fonts['items'] as $font ) {
141
-				$google_fonts[ $font['family'] ] = array(
142
-					'label'    => $font['family'],
143
-					'variants' => $font['variants'],
144
-					'category' => $font['category'],
140
+			foreach ( $fonts[ 'items' ] as $font ) {
141
+				$google_fonts[ $font[ 'family' ] ] = array(
142
+					'label'    => $font[ 'family' ],
143
+					'variants' => $font[ 'variants' ],
144
+					'category' => $font[ 'category' ],
145 145
 				);
146 146
 			}
147 147
 		}
Please login to merge, or discard this patch.
modules/webfonts/class-kirki-modules-webfonts-async.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
 		$fonts_to_load = $this->googlefonts->fonts;
77 77
 
78 78
 		if ( ! empty( $fonts_to_load ) && 'preconnect' === $relation_type ) {
79
-			$urls[] = array(
79
+			$urls[ ] = array(
80 80
 				'href' => 'https://fonts.gstatic.com',
81 81
 				'crossorigin',
82 82
 			);
Please login to merge, or discard this patch.
field/class-kirki-field-typography.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
 	protected function set_default() {
50 50
 
51 51
 		// Accomodate the use of font-weight and convert to variant.
52
-		if ( isset( $this->default['font-weight'] ) ) {
53
-			$this->default['variant'] = ( 'regular' === $this->default['font-weight'] ) ? 400 : (string) intval( $this->default['font-weight'] );
52
+		if ( isset( $this->default[ 'font-weight' ] ) ) {
53
+			$this->default[ 'variant' ] = ( 'regular' === $this->default[ 'font-weight' ] ) ? 400 : (string) intval( $this->default[ 'font-weight' ] );
54 54
 		}
55 55
 
56 56
 		// Make sure letter-spacing has units.
57
-		if ( isset( $this->default['letter-spacing'] ) && is_numeric( $this->default['letter-spacing'] ) && $this->default['letter-spacing'] ) {
58
-			$this->default['letter-spacing'] .= 'px';
57
+		if ( isset( $this->default[ 'letter-spacing' ] ) && is_numeric( $this->default[ 'letter-spacing' ] ) && $this->default[ 'letter-spacing' ] ) {
58
+			$this->default[ 'letter-spacing' ] .= 'px';
59 59
 		}
60 60
 	}
61 61
 
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
 			foreach ( $this->output as $output ) {
107 107
 
108 108
 				// If 'element' or 'property' are not defined, skip this.
109
-				if ( ! isset( $output['element'] ) ) {
109
+				if ( ! isset( $output[ 'element' ] ) ) {
110 110
 					continue;
111 111
 				}
112
-				if ( is_array( $output['element'] ) ) {
113
-					$output['element'] = implode( ',', $output['element'] );
112
+				if ( is_array( $output[ 'element' ] ) ) {
113
+					$output[ 'element' ] = implode( ',', $output[ 'element' ] );
114 114
 				}
115 115
 
116 116
 				// If we got this far, it's safe to add this.
117
-				$js_vars[] = $output;
117
+				$js_vars[ ] = $output;
118 118
 			}
119 119
 
120 120
 			// Did we manage to get all the items from 'output'?
@@ -146,26 +146,26 @@  discard block
 block discarded – undo
146 146
 		foreach ( $value as $key => $val ) {
147 147
 			switch ( $key ) {
148 148
 				case 'font-family':
149
-					$value['font-family'] = esc_attr( $val );
149
+					$value[ 'font-family' ] = esc_attr( $val );
150 150
 					break;
151 151
 				case 'font-weight':
152
-					if ( isset( $value['variant'] ) ) {
152
+					if ( isset( $value[ 'variant' ] ) ) {
153 153
 						break;
154 154
 					}
155
-					$value['variant'] = $val;
156
-					if ( isset( $value['font-style'] ) && 'italic' === $value['font-style'] ) {
157
-						$value['variant'] = ( '400' !== $val || 400 !== $val ) ? $value['variant'] . 'italic' : 'italic';
155
+					$value[ 'variant' ] = $val;
156
+					if ( isset( $value[ 'font-style' ] ) && 'italic' === $value[ 'font-style' ] ) {
157
+						$value[ 'variant' ] = ( '400' !== $val || 400 !== $val ) ? $value[ 'variant' ] . 'italic' : 'italic';
158 158
 					}
159 159
 					break;
160 160
 				case 'variant':
161 161
 					// Use 'regular' instead of 400 for font-variant.
162
-					$value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val;
162
+					$value[ 'variant' ] = ( 400 === $val || '400' === $val ) ? 'regular' : $val;
163 163
 					// Get font-weight from variant.
164
-					$value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
165
-					$value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? 400 : absint( $value['font-weight'] );
164
+					$value[ 'font-weight' ] = filter_var( $value[ 'variant' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION );
165
+					$value[ 'font-weight' ] = ( 'regular' === $value[ 'variant' ] || 'italic' === $value[ 'variant' ] ) ? 400 : absint( $value[ 'font-weight' ] );
166 166
 					// Get font-style from variant.
167
-					if ( ! isset( $value['font-style'] ) ) {
168
-						$value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic';
167
+					if ( ! isset( $value[ 'font-style' ] ) ) {
168
+						$value[ 'font-style' ] = ( false === strpos( $value[ 'variant' ], 'italic' ) ) ? 'normal' : 'italic';
169 169
 					}
170 170
 					break;
171 171
 				case 'font-size':
@@ -176,21 +176,21 @@  discard block
 block discarded – undo
176 176
 					break;
177 177
 				case 'text-align':
178 178
 					if ( ! in_array( $val, array( 'inherit', 'left', 'center', 'right', 'justify' ), true ) ) {
179
-						$value['text-align'] = 'inherit';
179
+						$value[ 'text-align' ] = 'inherit';
180 180
 					}
181 181
 					break;
182 182
 				case 'text-transform':
183 183
 					if ( ! in_array( $val, array( 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ), true ) ) {
184
-						$value['text-transform'] = 'none';
184
+						$value[ 'text-transform' ] = 'none';
185 185
 					}
186 186
 					break;
187 187
 				case 'text-decoration':
188 188
 					if ( ! in_array( $val, array( 'none', 'underline', 'overline', 'line-through', 'initial', 'inherit' ), true ) ) {
189
-						$value['text-transform'] = 'none';
189
+						$value[ 'text-transform' ] = 'none';
190 190
 					}
191 191
 					break;
192 192
 				case 'color':
193
-					$value['color'] = ariColor::newColor( $val )->toCSS( 'hex' );
193
+					$value[ 'color' ] = ariColor::newColor( $val )->toCSS( 'hex' );
194 194
 					break;
195 195
 			} // End switch().
196 196
 		} // End foreach().
Please login to merge, or discard this patch.
modules/webfonts/class-kirki-fonts-google.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		$config = apply_filters( 'kirki_config', array() );
60 60
 
61 61
 		// If we have set $config['disable_google_fonts'] to true then do not proceed any further.
62
-		if ( isset( $config['disable_google_fonts'] ) && true === $config['disable_google_fonts'] ) {
62
+		if ( isset( $config[ 'disable_google_fonts' ] ) && true === $config[ 'disable_google_fonts' ] ) {
63 63
 			return;
64 64
 		}
65 65
 
@@ -95,53 +95,53 @@  discard block
 block discarded – undo
95 95
 	public function generate_google_font( $args ) {
96 96
 
97 97
 		// Process typography fields.
98
-		if ( isset( $args['type'] ) && 'kirki-typography' === $args['type'] ) {
98
+		if ( isset( $args[ 'type' ] ) && 'kirki-typography' === $args[ 'type' ] ) {
99 99
 
100 100
 			// Get the value.
101 101
 			$value = Kirki_Values::get_sanitized_field_value( $args );
102 102
 
103 103
 			// If we don't have a font-family then we can skip this.
104
-			if ( ! isset( $value['font-family'] ) ) {
104
+			if ( ! isset( $value[ 'font-family' ] ) ) {
105 105
 				return;
106 106
 			}
107 107
 
108 108
 			// If not a google-font, then we can skip this.
109
-			if ( ! Kirki_Fonts::is_google_font( $value['font-family'] ) ) {
109
+			if ( ! Kirki_Fonts::is_google_font( $value[ 'font-family' ] ) ) {
110 110
 				return;
111 111
 			}
112 112
 
113 113
 			// Set a default value for variants.
114
-			if ( ! isset( $value['variant'] ) ) {
115
-				$value['variant'] = 'regular';
114
+			if ( ! isset( $value[ 'variant' ] ) ) {
115
+				$value[ 'variant' ] = 'regular';
116 116
 			}
117 117
 
118 118
 			// Add the requested google-font.
119
-			if ( ! isset( $this->fonts[ $value['font-family'] ] ) ) {
120
-				$this->fonts[ $value['font-family'] ] = array();
119
+			if ( ! isset( $this->fonts[ $value[ 'font-family' ] ] ) ) {
120
+				$this->fonts[ $value[ 'font-family' ] ] = array();
121 121
 			}
122
-			if ( ! in_array( $value['variant'], $this->fonts[ $value['font-family'] ], true ) ) {
123
-				$this->fonts[ $value['font-family'] ][] = $value['variant'];
122
+			if ( ! in_array( $value[ 'variant' ], $this->fonts[ $value[ 'font-family' ] ], true ) ) {
123
+				$this->fonts[ $value[ 'font-family' ] ][ ] = $value[ 'variant' ];
124 124
 			}
125 125
 			// Are we force-loading all variants?
126 126
 			if ( true === self::$force_load_all_variants ) {
127 127
 				$all_variants               = Kirki_Fonts::get_all_variants();
128
-				$args['choices']['variant'] = array_keys( $all_variants );
128
+				$args[ 'choices' ][ 'variant' ] = array_keys( $all_variants );
129 129
 			}
130 130
 
131
-			if ( ! empty( $args['choices']['variant'] ) && is_array( $args['choices']['variant'] ) ) {
132
-				foreach ( $args['choices']['variant'] as $extra_variant ) {
133
-					$this->fonts[ $value['font-family'] ][] = $extra_variant;
131
+			if ( ! empty( $args[ 'choices' ][ 'variant' ] ) && is_array( $args[ 'choices' ][ 'variant' ] ) ) {
132
+				foreach ( $args[ 'choices' ][ 'variant' ] as $extra_variant ) {
133
+					$this->fonts[ $value[ 'font-family' ] ][ ] = $extra_variant;
134 134
 				}
135 135
 			}
136 136
 			return;
137 137
 		}
138 138
 
139 139
 		// Process non-typography fields.
140
-		if ( isset( $args['output'] ) && is_array( $args['output'] ) ) {
141
-			foreach ( $args['output'] as $output ) {
140
+		if ( isset( $args[ 'output' ] ) && is_array( $args[ 'output' ] ) ) {
141
+			foreach ( $args[ 'output' ] as $output ) {
142 142
 
143 143
 				// If we don't have a typography-related output argument we can skip this.
144
-				if ( ! isset( $output['property'] ) || ! in_array( $output['property'], array( 'font-family', 'font-weight' ), true ) ) {
144
+				if ( ! isset( $output[ 'property' ] ) || ! in_array( $output[ 'property' ], array( 'font-family', 'font-weight' ), true ) ) {
145 145
 					continue;
146 146
 				}
147 147
 
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
 				$value = Kirki_Values::get_sanitized_field_value( $args );
150 150
 
151 151
 				if ( is_string( $value ) ) {
152
-					if ( 'font-family' === $output['property'] ) {
152
+					if ( 'font-family' === $output[ 'property' ] ) {
153 153
 						if ( ! array_key_exists( $value, $this->fonts ) ) {
154 154
 							$this->fonts[ $value ] = array();
155 155
 						}
156
-					} elseif ( 'font-weight' === $output['property'] ) {
156
+					} elseif ( 'font-weight' === $output[ 'property' ] ) {
157 157
 						foreach ( $this->fonts as $font => $variants ) {
158 158
 							if ( ! in_array( $value, $variants, true ) ) {
159
-								$this->fonts[ $font ][] = $value;
159
+								$this->fonts[ $font ][ ] = $value;
160 160
 							}
161 161
 						}
162 162
 					}
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 
189 189
 			// Get all valid font variants for this font.
190 190
 			$font_variants = array();
191
-			if ( isset( $this->google_fonts[ $font ]['variants'] ) ) {
192
-				$font_variants = $this->google_fonts[ $font ]['variants'];
191
+			if ( isset( $this->google_fonts[ $font ][ 'variants' ] ) ) {
192
+				$font_variants = $this->google_fonts[ $font ][ 'variants' ];
193 193
 			}
194 194
 			foreach ( $variants as $variant ) {
195 195
 
Please login to merge, or discard this patch.