Passed
Push — develop ( efe9ef...440c37 )
by Aristeides
03:24
created
core/class-kirki-util.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		$plugins = get_plugins();
46 46
 		$_plugin = '';
47 47
 		foreach ( $plugins as $plugin => $args ) {
48
-			if ( ! $is_plugin && isset( $args['Name'] ) && ( 'Kirki' === $args['Name'] || 'Kirki Toolkit' === $args['Name'] ) ) {
48
+			if ( ! $is_plugin && isset( $args[ 'Name' ] ) && ( 'Kirki' === $args[ 'Name' ] || 'Kirki Toolkit' === $args[ 'Name' ] ) ) {
49 49
 				$is_plugin = true;
50 50
 				$_plugin   = $plugin;
51 51
 			}
@@ -82,26 +82,26 @@  discard block
 block discarded – undo
82 82
 		foreach ( Kirki::$fields as $field ) {
83 83
 
84 84
 			// Check if we have variables for this field.
85
-			if ( isset( $field['variables'] ) && $field['variables'] && ! empty( $field['variables'] ) ) {
85
+			if ( isset( $field[ 'variables' ] ) && $field[ 'variables' ] && ! empty( $field[ 'variables' ] ) ) {
86 86
 
87 87
 				// Loop through the array of variables.
88
-				foreach ( $field['variables'] as $field_variable ) {
88
+				foreach ( $field[ 'variables' ] as $field_variable ) {
89 89
 
90 90
 					// Is the variable ['name'] defined? If yes, then we can proceed.
91
-					if ( isset( $field_variable['name'] ) ) {
91
+					if ( isset( $field_variable[ 'name' ] ) ) {
92 92
 
93 93
 						// Sanitize the variable name.
94
-						$variable_name = esc_attr( $field_variable['name'] );
94
+						$variable_name = esc_attr( $field_variable[ 'name' ] );
95 95
 
96 96
 						// Do we have a callback function defined? If not then set $variable_callback to false.
97
-						$variable_callback = ( isset( $field_variable['callback'] ) && is_callable( $field_variable['callback'] ) ) ? $field_variable['callback'] : false;
97
+						$variable_callback = ( isset( $field_variable[ 'callback' ] ) && is_callable( $field_variable[ 'callback' ] ) ) ? $field_variable[ 'callback' ] : false;
98 98
 
99 99
 						// If we have a variable_callback defined then get the value of the option
100 100
 						// and run it through the callback function.
101 101
 						// If no callback is defined (false) then just get the value.
102
-						$variables[ $variable_name ] = Kirki_Values::get_value( $field['settings'] );
102
+						$variables[ $variable_name ] = Kirki_Values::get_value( $field[ 'settings' ] );
103 103
 						if ( $variable_callback ) {
104
-							$variables[ $variable_name ] = call_user_func( $field_variable['callback'], Kirki_Values::get_value( $field['settings'] ) );
104
+							$variables[ $variable_name ] = call_user_func( $field_variable[ 'callback' ], Kirki_Values::get_value( $field[ 'settings' ] ) );
105 105
 						}
106 106
 					}
107 107
 				}
@@ -128,31 +128,31 @@  discard block
 block discarded – undo
128 128
 		if (
129 129
 			self::is_plugin() ||
130 130
 			false === strpos( $url, 'wordpress.org' ) || (
131
-				! isset( $request['body'] ) ||
132
-				! isset( $request['body']['plugins'] ) ||
133
-				! isset( $request['body']['translations'] ) ||
134
-				! isset( $request['body']['locale'] ) ||
135
-				! isset( $request['body']['all'] )
131
+				! isset( $request[ 'body' ] ) ||
132
+				! isset( $request[ 'body' ][ 'plugins' ] ) ||
133
+				! isset( $request[ 'body' ][ 'translations' ] ) ||
134
+				! isset( $request[ 'body' ][ 'locale' ] ) ||
135
+				! isset( $request[ 'body' ][ 'all' ] )
136 136
 			)
137 137
 		) {
138 138
 			return $request;
139 139
 		}
140 140
 
141
-		$plugins = json_decode( $request['body']['plugins'], true );
142
-		if ( ! isset( $plugins['plugins'] ) ) {
141
+		$plugins = json_decode( $request[ 'body' ][ 'plugins' ], true );
142
+		if ( ! isset( $plugins[ 'plugins' ] ) ) {
143 143
 			return $request;
144 144
 		}
145 145
 		$exists = false;
146
-		foreach ( $plugins['plugins'] as $plugin ) {
147
-			if ( isset( $plugin['Name'] ) && 'Kirki Toolkit' === $plugin['Name'] ) {
146
+		foreach ( $plugins[ 'plugins' ] as $plugin ) {
147
+			if ( isset( $plugin[ 'Name' ] ) && 'Kirki Toolkit' === $plugin[ 'Name' ] ) {
148 148
 				$exists = true;
149 149
 			}
150 150
 		}
151 151
 		// Inject data.
152 152
 		if ( ! $exists && defined( 'KIRKI_PLUGIN_FILE' ) ) {
153
-			$plugins['plugins']['kirki/kirki.php'] = get_plugin_data( KIRKI_PLUGIN_FILE );
153
+			$plugins[ 'plugins' ][ 'kirki/kirki.php' ] = get_plugin_data( KIRKI_PLUGIN_FILE );
154 154
 		}
155
-		$request['body']['plugins'] = wp_json_encode( $plugins );
155
+		$request[ 'body' ][ 'plugins' ] = wp_json_encode( $plugins );
156 156
 		return $request;
157 157
 	}
158 158
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 		// We only need the major version.
173 173
 		if ( 'major' === $context ) {
174 174
 			$version_parts = explode( '.', $wp_version );
175
-			return $version_parts[0];
175
+			return $version_parts[ 0 ];
176 176
 		}
177 177
 
178 178
 		return $wp_version;
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 		// We only need the major version.
195 195
 		if ( 'major' === $context ) {
196 196
 			$version_parts = explode( '.', $wp_version );
197
-			return absint( $version_parts[0] );
197
+			return absint( $version_parts[ 0 ] );
198 198
 		}
199 199
 
200 200
 		// If we got this far, we want the full monty.
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 		if ( false !== strpos( $wp_version, '-' ) ) {
203 203
 			// We're on a dev version.
204 204
 			$version_parts = explode( '-', $wp_version );
205
-			return floatval( $version_parts[0] );
205
+			return floatval( $version_parts[ 0 ] );
206 206
 		}
207 207
 		return floatval( $wp_version );
208 208
 	}
Please login to merge, or discard this patch.