@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | $class_name = 'WP_Customize_Control'; |
| 69 | 69 | |
| 70 | 70 | // Get the classname from the array of control classnames. |
| 71 | - if ( array_key_exists( $args['type'], self::$control_types ) ) { |
|
| 72 | - $class_name = self::$control_types[ $args['type'] ]; |
|
| 71 | + if ( array_key_exists( $args[ 'type' ], self::$control_types ) ) { |
|
| 72 | + $class_name = self::$control_types[ $args[ 'type' ] ]; |
|
| 73 | 73 | } |
| 74 | 74 | return $class_name; |
| 75 | 75 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $class_name = $this->get_control_class_name( $args ); |
| 87 | 87 | |
| 88 | 88 | // Add the control. |
| 89 | - $this->wp_customize->add_control( new $class_name( $this->wp_customize, $args['settings'], $args ) ); |
|
| 89 | + $this->wp_customize->add_control( new $class_name( $this->wp_customize, $args[ 'settings' ], $args ) ); |
|
| 90 | 90 | |
| 91 | 91 | } |
| 92 | 92 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $plugins = get_plugins(); |
| 44 | 44 | $_plugin = ''; |
| 45 | 45 | foreach ( $plugins as $plugin => $args ) { |
| 46 | - if ( ! $is_plugin && isset( $args['Name'] ) && ( 'Kirki' === $args['Name'] || 'Kirki Toolkit' === $args['Name'] ) ) { |
|
| 46 | + if ( ! $is_plugin && isset( $args[ 'Name' ] ) && ( 'Kirki' === $args[ 'Name' ] || 'Kirki Toolkit' === $args[ 'Name' ] ) ) { |
|
| 47 | 47 | $is_plugin = true; |
| 48 | 48 | $_plugin = $plugin; |
| 49 | 49 | } |
@@ -80,23 +80,23 @@ discard block |
||
| 80 | 80 | foreach ( Kirki::$fields as $field ) { |
| 81 | 81 | |
| 82 | 82 | // Check if we have variables for this field. |
| 83 | - if ( isset( $field['variables'] ) && $field['variables'] && ! empty( $field['variables'] ) ) { |
|
| 83 | + if ( isset( $field[ 'variables' ] ) && $field[ 'variables' ] && ! empty( $field[ 'variables' ] ) ) { |
|
| 84 | 84 | |
| 85 | 85 | // Loop through the array of variables. |
| 86 | - foreach ( $field['variables'] as $field_variable ) { |
|
| 86 | + foreach ( $field[ 'variables' ] as $field_variable ) { |
|
| 87 | 87 | |
| 88 | 88 | // Is the variable ['name'] defined? If yes, then we can proceed. |
| 89 | - if ( isset( $field_variable['name'] ) ) { |
|
| 89 | + if ( isset( $field_variable[ 'name' ] ) ) { |
|
| 90 | 90 | |
| 91 | 91 | // Do we have a callback function defined? If not then set $variable_callback to false. |
| 92 | - $variable_callback = ( isset( $field_variable['callback'] ) && is_callable( $field_variable['callback'] ) ) ? $field_variable['callback'] : false; |
|
| 92 | + $variable_callback = ( isset( $field_variable[ 'callback' ] ) && is_callable( $field_variable[ 'callback' ] ) ) ? $field_variable[ 'callback' ] : false; |
|
| 93 | 93 | |
| 94 | 94 | // If we have a variable_callback defined then get the value of the option |
| 95 | 95 | // and run it through the callback function. |
| 96 | 96 | // If no callback is defined (false) then just get the value. |
| 97 | - $variables[ $field_variable['name'] ] = Kirki_Values::get_value( $field['settings'] ); |
|
| 97 | + $variables[ $field_variable[ 'name' ] ] = Kirki_Values::get_value( $field[ 'settings' ] ); |
|
| 98 | 98 | if ( $variable_callback ) { |
| 99 | - $variables[ $field_variable['name'] ] = call_user_func( $field_variable['callback'], Kirki_Values::get_value( $field['settings'] ) ); |
|
| 99 | + $variables[ $field_variable[ 'name' ] ] = call_user_func( $field_variable[ 'callback' ], Kirki_Values::get_value( $field[ 'settings' ] ) ); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -123,31 +123,31 @@ discard block |
||
| 123 | 123 | if ( |
| 124 | 124 | self::is_plugin() || |
| 125 | 125 | false === strpos( $url, 'wordpress.org' ) || ( |
| 126 | - ! isset( $request['body'] ) || |
|
| 127 | - ! isset( $request['body']['plugins'] ) || |
|
| 128 | - ! isset( $request['body']['translations'] ) || |
|
| 129 | - ! isset( $request['body']['locale'] ) || |
|
| 130 | - ! isset( $request['body']['all'] ) |
|
| 126 | + ! isset( $request[ 'body' ] ) || |
|
| 127 | + ! isset( $request[ 'body' ][ 'plugins' ] ) || |
|
| 128 | + ! isset( $request[ 'body' ][ 'translations' ] ) || |
|
| 129 | + ! isset( $request[ 'body' ][ 'locale' ] ) || |
|
| 130 | + ! isset( $request[ 'body' ][ 'all' ] ) |
|
| 131 | 131 | ) |
| 132 | 132 | ) { |
| 133 | 133 | return $request; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - $plugins = json_decode( $request['body']['plugins'], true ); |
|
| 137 | - if ( ! isset( $plugins['plugins'] ) ) { |
|
| 136 | + $plugins = json_decode( $request[ 'body' ][ 'plugins' ], true ); |
|
| 137 | + if ( ! isset( $plugins[ 'plugins' ] ) ) { |
|
| 138 | 138 | return $request; |
| 139 | 139 | } |
| 140 | 140 | $exists = false; |
| 141 | - foreach ( $plugins['plugins'] as $plugin ) { |
|
| 142 | - if ( isset( $plugin['Name'] ) && 'Kirki Toolkit' === $plugin['Name'] ) { |
|
| 141 | + foreach ( $plugins[ 'plugins' ] as $plugin ) { |
|
| 142 | + if ( isset( $plugin[ 'Name' ] ) && 'Kirki Toolkit' === $plugin[ 'Name' ] ) { |
|
| 143 | 143 | $exists = true; |
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | // Inject data. |
| 147 | 147 | if ( ! $exists && defined( 'KIRKI_PLUGIN_FILE' ) ) { |
| 148 | - $plugins['plugins']['kirki/kirki.php'] = get_plugin_data( KIRKI_PLUGIN_FILE ); |
|
| 148 | + $plugins[ 'plugins' ][ 'kirki/kirki.php' ] = get_plugin_data( KIRKI_PLUGIN_FILE ); |
|
| 149 | 149 | } |
| 150 | - $request['body']['plugins'] = wp_json_encode( $plugins ); |
|
| 150 | + $request[ 'body' ][ 'plugins' ] = wp_json_encode( $plugins ); |
|
| 151 | 151 | return $request; |
| 152 | 152 | } |
| 153 | 153 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | // We only need the major version. |
| 168 | 168 | if ( 'major' === $context ) { |
| 169 | 169 | $version_parts = explode( '.', $wp_version ); |
| 170 | - return $version_parts[0]; |
|
| 170 | + return $version_parts[ 0 ]; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | return $wp_version; |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | // We only need the major version. |
| 191 | 191 | if ( 'major' === $context ) { |
| 192 | 192 | $version_parts = explode( '.', $wp_version ); |
| 193 | - return absint( $version_parts[0] ); |
|
| 193 | + return absint( $version_parts[ 0 ] ); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | // If we got this far, we want the full monty. |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | if ( false !== strpos( $wp_version, '-' ) ) { |
| 199 | 199 | // We're on a dev version. |
| 200 | 200 | $version_parts = explode( '-', $wp_version ); |
| 201 | - return floatval( $version_parts[0] ); |
|
| 201 | + return floatval( $version_parts[ 0 ] ); |
|
| 202 | 202 | } |
| 203 | 203 | return floatval( $wp_version ); |
| 204 | 204 | } |
@@ -23,8 +23,8 @@ |
||
| 23 | 23 | if ( ! is_array( $this->choices ) ) { |
| 24 | 24 | $this->choices = array(); |
| 25 | 25 | } |
| 26 | - $this->choices['element'] = 'input'; |
|
| 27 | - $this->choices['type'] = 'text'; |
|
| 26 | + $this->choices[ 'element' ] = 'input'; |
|
| 27 | + $this->choices[ 'type' ] = 'text'; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | $styles = $this->get_styles(); |
| 169 | 169 | |
| 170 | 170 | if ( ! empty( $styles ) ) { |
| 171 | - $settings['styles'][] = array( 'css' => $styles ); |
|
| 171 | + $settings[ 'styles' ][ ] = array( 'css' => $styles ); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | return $settings; |
@@ -220,11 +220,11 @@ discard block |
||
| 220 | 220 | } |
| 221 | 221 | |
| 222 | 222 | if ( ! empty( $args ) ) { |
| 223 | - if ( isset( $args['disable_output'] ) && true === $args['disable_output'] ) { |
|
| 223 | + if ( isset( $args[ 'disable_output' ] ) && true === $args[ 'disable_output' ] ) { |
|
| 224 | 224 | return true; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - if ( ! isset( $args['gutenberg_support'] ) || true !== $args['gutenberg_support'] ) { |
|
| 227 | + if ( ! isset( $args[ 'gutenberg_support' ] ) || true !== $args[ 'gutenberg_support' ] ) { |
|
| 228 | 228 | return true; |
| 229 | 229 | } |
| 230 | 230 | } |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | * @return string|array |
| 82 | 82 | */ |
| 83 | 83 | protected function apply_sanitize_callback( $output, $value ) { |
| 84 | - if ( isset( $output['sanitize_callback'] ) && null !== $output['sanitize_callback'] ) { |
|
| 84 | + if ( isset( $output[ 'sanitize_callback' ] ) && null !== $output[ 'sanitize_callback' ] ) { |
|
| 85 | 85 | |
| 86 | 86 | // If the sanitize_callback is invalid, return the value. |
| 87 | - if ( ! is_callable( $output['sanitize_callback'] ) ) { |
|
| 87 | + if ( ! is_callable( $output[ 'sanitize_callback' ] ) ) { |
|
| 88 | 88 | return $value; |
| 89 | 89 | } |
| 90 | - return call_user_func( $output['sanitize_callback'], $this->value ); |
|
| 90 | + return call_user_func( $output[ 'sanitize_callback' ], $this->value ); |
|
| 91 | 91 | } |
| 92 | 92 | return $value; |
| 93 | 93 | } |
@@ -100,22 +100,22 @@ discard block |
||
| 100 | 100 | * @return string|array |
| 101 | 101 | */ |
| 102 | 102 | protected function apply_value_pattern( $output, $value ) { |
| 103 | - if ( isset( $output['value_pattern'] ) && ! empty( $output['value_pattern'] ) && is_string( $output['value_pattern'] ) ) { |
|
| 103 | + if ( isset( $output[ 'value_pattern' ] ) && ! empty( $output[ 'value_pattern' ] ) && is_string( $output[ 'value_pattern' ] ) ) { |
|
| 104 | 104 | if ( ! is_array( $value ) ) { |
| 105 | - $value = str_replace( '$', $value, $output['value_pattern'] ); |
|
| 105 | + $value = str_replace( '$', $value, $output[ 'value_pattern' ] ); |
|
| 106 | 106 | } |
| 107 | 107 | if ( is_array( $value ) ) { |
| 108 | 108 | foreach ( array_keys( $value ) as $value_k ) { |
| 109 | 109 | if ( ! is_string( $value[ $value_k ] ) ) { |
| 110 | 110 | continue; |
| 111 | 111 | } |
| 112 | - if ( isset( $output['choice'] ) ) { |
|
| 113 | - if ( $output['choice'] === $value_k ) { |
|
| 114 | - $value[ $output['choice'] ] = str_replace( '$', $value[ $output['choice'] ], $output['value_pattern'] ); |
|
| 112 | + if ( isset( $output[ 'choice' ] ) ) { |
|
| 113 | + if ( $output[ 'choice' ] === $value_k ) { |
|
| 114 | + $value[ $output[ 'choice' ] ] = str_replace( '$', $value[ $output[ 'choice' ] ], $output[ 'value_pattern' ] ); |
|
| 115 | 115 | } |
| 116 | 116 | continue; |
| 117 | 117 | } |
| 118 | - $value[ $value_k ] = str_replace( '$', $value[ $value_k ], $output['value_pattern'] ); |
|
| 118 | + $value[ $value_k ] = str_replace( '$', $value[ $value_k ], $output[ 'value_pattern' ] ); |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | $value = $this->apply_pattern_replace( $output, $value ); |
@@ -131,14 +131,14 @@ discard block |
||
| 131 | 131 | * @return string|array |
| 132 | 132 | */ |
| 133 | 133 | protected function apply_pattern_replace( $output, $value ) { |
| 134 | - if ( isset( $output['pattern_replace'] ) && is_array( $output['pattern_replace'] ) ) { |
|
| 134 | + if ( isset( $output[ 'pattern_replace' ] ) && is_array( $output[ 'pattern_replace' ] ) ) { |
|
| 135 | 135 | $option_type = ( '' !== Kirki::get_config_param( $this->config_id, 'option_type' ) ) ? Kirki::get_config_param( $this->config_id, 'option_type' ) : 'theme_mod'; |
| 136 | 136 | $option_name = Kirki::get_config_param( $this->config_id, 'option_name' ); |
| 137 | 137 | $options = array(); |
| 138 | 138 | if ( $option_name ) { |
| 139 | 139 | $options = ( 'site_option' === $option_type ) ? get_site_option( $option_name ) : get_option( $option_name ); |
| 140 | 140 | } |
| 141 | - foreach ( $output['pattern_replace'] as $search => $replace ) { |
|
| 141 | + foreach ( $output[ 'pattern_replace' ] as $search => $replace ) { |
|
| 142 | 142 | $replacement = ''; |
| 143 | 143 | switch ( $option_type ) { |
| 144 | 144 | case 'option': |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | // No need to proceed this if the current value is the same as in the "exclude" value. |
| 201 | - if ( isset( $output['exclude'] ) && is_array( $output['exclude'] ) ) { |
|
| 202 | - foreach ( $output['exclude'] as $exclude ) { |
|
| 201 | + if ( isset( $output[ 'exclude' ] ) && is_array( $output[ 'exclude' ] ) ) { |
|
| 202 | + foreach ( $output[ 'exclude' ] as $exclude ) { |
|
| 203 | 203 | if ( is_array( $value ) ) { |
| 204 | 204 | if ( is_array( $exclude ) ) { |
| 205 | 205 | $diff1 = array_diff( $value, $exclude ); |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | // If 'choice' is defined check for sub-values too. |
| 213 | 213 | // Fixes https://github.com/aristath/kirki/issues/1416. |
| 214 | - if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
| 214 | + if ( isset( $output[ 'choice' ] ) && isset( $value[ $output[ 'choice' ] ] ) && $exclude == $value[ $output[ 'choice' ] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
| 215 | 215 | $skip = true; |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -232,10 +232,10 @@ discard block |
||
| 232 | 232 | // Apply any value patterns defined. |
| 233 | 233 | $value = $this->apply_value_pattern( $output, $value ); |
| 234 | 234 | |
| 235 | - if ( isset( $output['element'] ) && is_array( $output['element'] ) ) { |
|
| 236 | - $output['element'] = array_unique( $output['element'] ); |
|
| 237 | - sort( $output['element'] ); |
|
| 238 | - $output['element'] = implode( ',', $output['element'] ); |
|
| 235 | + if ( isset( $output[ 'element' ] ) && is_array( $output[ 'element' ] ) ) { |
|
| 236 | + $output[ 'element' ] = array_unique( $output[ 'element' ] ); |
|
| 237 | + sort( $output[ 'element' ] ); |
|
| 238 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | 241 | $value = $this->process_value( $value, $output ); |
@@ -243,10 +243,10 @@ discard block |
||
| 243 | 243 | if ( is_admin() && ! is_customize_preview() ) { |
| 244 | 244 | |
| 245 | 245 | // Check if this is an admin style. |
| 246 | - if ( ! isset( $output['context'] ) || ! in_array( 'editor', $output['context'] ) ) { |
|
| 246 | + if ( ! isset( $output[ 'context' ] ) || ! in_array( 'editor', $output[ 'context' ] ) ) { |
|
| 247 | 247 | continue; |
| 248 | 248 | } |
| 249 | - } elseif ( isset( $output['context'] ) && ! in_array( 'front', $output['context'] ) ) { |
|
| 249 | + } elseif ( isset( $output[ 'context' ] ) && ! in_array( 'front', $output[ 'context' ] ) ) { |
|
| 250 | 250 | |
| 251 | 251 | // Check if this is a frontend style. |
| 252 | 252 | continue; |
@@ -265,13 +265,13 @@ discard block |
||
| 265 | 265 | * @return null |
| 266 | 266 | */ |
| 267 | 267 | protected function process_output( $output, $value ) { |
| 268 | - if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { |
|
| 268 | + if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) { |
|
| 269 | 269 | return; |
| 270 | 270 | } |
| 271 | - $output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global'; |
|
| 272 | - $output['prefix'] = ( isset( $output['prefix'] ) ) ? $output['prefix'] : ''; |
|
| 273 | - $output['units'] = ( isset( $output['units'] ) ) ? $output['units'] : ''; |
|
| 274 | - $output['suffix'] = ( isset( $output['suffix'] ) ) ? $output['suffix'] : ''; |
|
| 271 | + $output[ 'media_query' ] = ( isset( $output[ 'media_query' ] ) ) ? $output[ 'media_query' ] : 'global'; |
|
| 272 | + $output[ 'prefix' ] = ( isset( $output[ 'prefix' ] ) ) ? $output[ 'prefix' ] : ''; |
|
| 273 | + $output[ 'units' ] = ( isset( $output[ 'units' ] ) ) ? $output[ 'units' ] : ''; |
|
| 274 | + $output[ 'suffix' ] = ( isset( $output[ 'suffix' ] ) ) ? $output[ 'suffix' ] : ''; |
|
| 275 | 275 | |
| 276 | 276 | // Properties that can accept multiple values. |
| 277 | 277 | // Useful for example for gradients where all browsers use the "background-image" property |
@@ -280,15 +280,15 @@ discard block |
||
| 280 | 280 | 'background-image', |
| 281 | 281 | 'background', |
| 282 | 282 | ); |
| 283 | - if ( in_array( $output['property'], $accepts_multiple, true ) ) { |
|
| 284 | - if ( isset( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) && ! is_array( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) ) { |
|
| 285 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = (array) $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ]; |
|
| 283 | + if ( in_array( $output[ 'property' ], $accepts_multiple, true ) ) { |
|
| 284 | + if ( isset( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) && ! is_array( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) ) { |
|
| 285 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = (array) $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ]; |
|
| 286 | 286 | } |
| 287 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ][] = $output['prefix'] . $value . $output['units'] . $output['suffix']; |
|
| 287 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ][ ] = $output[ 'prefix' ] . $value . $output[ 'units' ] . $output[ 'suffix' ]; |
|
| 288 | 288 | return; |
| 289 | 289 | } |
| 290 | 290 | if ( is_string( $value ) || is_numeric( $value ) ) { |
| 291 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value ) . $output['units'] . $output['suffix']; |
|
| 291 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value ) . $output[ 'units' ] . $output[ 'suffix' ]; |
|
| 292 | 292 | } |
| 293 | 293 | } |
| 294 | 294 | |
@@ -327,8 +327,8 @@ discard block |
||
| 327 | 327 | * @return string|array |
| 328 | 328 | */ |
| 329 | 329 | protected function process_value( $value, $output ) { |
| 330 | - if ( isset( $output['property'] ) ) { |
|
| 331 | - return $this->process_property_value( $output['property'], $value ); |
|
| 330 | + if ( isset( $output[ 'property' ] ) ) { |
|
| 331 | + return $this->process_property_value( $output[ 'property' ], $value ); |
|
| 332 | 332 | } |
| 333 | 333 | return $value; |
| 334 | 334 | } |
@@ -86,15 +86,15 @@ discard block |
||
| 86 | 86 | // Get an array of all fields. |
| 87 | 87 | $fields = Kirki::$fields; |
| 88 | 88 | foreach ( $fields as $id => $args ) { |
| 89 | - if ( ! isset( $args['css_vars'] ) || empty( $args['css_vars'] ) ) { |
|
| 89 | + if ( ! isset( $args[ 'css_vars' ] ) || empty( $args[ 'css_vars' ] ) ) { |
|
| 90 | 90 | continue; |
| 91 | 91 | } |
| 92 | - $val = Kirki_Values::get_value( $args['kirki_config'], $id ); |
|
| 93 | - foreach ( $args['css_vars'] as $css_var ) { |
|
| 94 | - if ( isset( $css_var[2] ) && is_array( $val ) && isset( $val[ $css_var[2] ] ) ) { |
|
| 95 | - $this->vars[ $css_var[0] ] = str_replace( '$', $val[ $css_var[2] ], $css_var[1] ); |
|
| 92 | + $val = Kirki_Values::get_value( $args[ 'kirki_config' ], $id ); |
|
| 93 | + foreach ( $args[ 'css_vars' ] as $css_var ) { |
|
| 94 | + if ( isset( $css_var[ 2 ] ) && is_array( $val ) && isset( $val[ $css_var[ 2 ] ] ) ) { |
|
| 95 | + $this->vars[ $css_var[ 0 ] ] = str_replace( '$', $val[ $css_var[ 2 ] ], $css_var[ 1 ] ); |
|
| 96 | 96 | } else { |
| 97 | - $this->vars[ $css_var[0] ] = str_replace( '$', $val, $css_var[1] ); |
|
| 97 | + $this->vars[ $css_var[ 0 ] ] = str_replace( '$', $val, $css_var[ 1 ] ); |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -147,8 +147,8 @@ discard block |
||
| 147 | 147 | $fields = Kirki::$fields; |
| 148 | 148 | $data = array(); |
| 149 | 149 | foreach ( $fields as $field ) { |
| 150 | - if ( isset( $field['transport'] ) && 'postMessage' === $field['transport'] && isset( $field['css_vars'] ) && ! empty( $field['css_vars'] ) ) { |
|
| 151 | - $data[] = $field; |
|
| 150 | + if ( isset( $field[ 'transport' ] ) && 'postMessage' === $field[ 'transport' ] && isset( $field[ 'css_vars' ] ) && ! empty( $field[ 'css_vars' ] ) ) { |
|
| 151 | + $data[ ] = $field; |
|
| 152 | 152 | } |
| 153 | 153 | } |
| 154 | 154 | wp_localize_script( 'kirki_auto_css_vars', 'kirkiCssVarFields', $data ); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | wp_enqueue_script( 'kirki_auto_postmessage', trailingslashit( Kirki::$url ) . 'modules/postmessage/postmessage.js', array( 'jquery', 'customize-preview' ), KIRKI_VERSION, true ); |
| 75 | 75 | $fields = Kirki::$fields; |
| 76 | 76 | foreach ( $fields as $field ) { |
| 77 | - if ( isset( $field['transport'] ) && 'postMessage' === $field['transport'] && isset( $field['js_vars'] ) && ! empty( $field['js_vars'] ) && is_array( $field['js_vars'] ) && isset( $field['settings'] ) ) { |
|
| 77 | + if ( isset( $field[ 'transport' ] ) && 'postMessage' === $field[ 'transport' ] && isset( $field[ 'js_vars' ] ) && ! empty( $field[ 'js_vars' ] ) && is_array( $field[ 'js_vars' ] ) && isset( $field[ 'settings' ] ) ) { |
|
| 78 | 78 | $this->script .= $this->script( $field ); |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -90,11 +90,11 @@ discard block |
||
| 90 | 90 | * @param array $args The arguments. |
| 91 | 91 | */ |
| 92 | 92 | protected function script( $args ) { |
| 93 | - $script = 'wp.customize(\'' . $args['settings'] . '\',function(value){value.bind(function(newval){'; |
|
| 93 | + $script = 'wp.customize(\'' . $args[ 'settings' ] . '\',function(value){value.bind(function(newval){'; |
|
| 94 | 94 | |
| 95 | 95 | $add_css = false; |
| 96 | - foreach ( $args['js_vars'] as $js_var ) { |
|
| 97 | - if ( ! isset( $js_var['function'] ) || 'html' !== $js_var['function'] ) { |
|
| 96 | + foreach ( $args[ 'js_vars' ] as $js_var ) { |
|
| 97 | + if ( ! isset( $js_var[ 'function' ] ) || 'html' !== $js_var[ 'function' ] ) { |
|
| 98 | 98 | $add_css = true; |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | // append unique style tag if not exist |
| 105 | 105 | // The style ID. |
| 106 | - $style_id = 'kirki-postmessage-' . str_replace( array( '[', ']' ), '', $args['settings'] ); |
|
| 106 | + $style_id = 'kirki-postmessage-' . str_replace( array( '[', ']' ), '', $args[ 'settings' ] ); |
|
| 107 | 107 | $script .= 'if(null===document.getElementById(\'' . $style_id . '\')||\'undefined\'===typeof document.getElementById(\'' . $style_id . '\')){jQuery(\'head\').append(\'<style id="' . $style_id . '"></style>\');}'; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -115,48 +115,48 @@ discard block |
||
| 115 | 115 | ); |
| 116 | 116 | |
| 117 | 117 | // Loop through the js_vars and generate the script. |
| 118 | - foreach ( $args['js_vars'] as $key => $js_var ) { |
|
| 118 | + foreach ( $args[ 'js_vars' ] as $key => $js_var ) { |
|
| 119 | 119 | |
| 120 | 120 | // Skip styles if "exclude" is defined and value is excluded. |
| 121 | - if ( isset( $js_var['exclude'] ) ) { |
|
| 122 | - $js_var['exclude'] = (array) $js_var['exclude']; |
|
| 121 | + if ( isset( $js_var[ 'exclude' ] ) ) { |
|
| 122 | + $js_var[ 'exclude' ] = (array) $js_var[ 'exclude' ]; |
|
| 123 | 123 | $script .= 'exclude=false;'; |
| 124 | - foreach ( $js_var['exclude'] as $exclussion ) { |
|
| 124 | + foreach ( $js_var[ 'exclude' ] as $exclussion ) { |
|
| 125 | 125 | $script .= "if(newval=='{$exclussion}'||(''==='{$exclussion}'&&_.isObject(newval)&&_.isEmpty(newval))){exclude=true;}"; |
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | - if ( isset( $js_var['element'] ) ) { |
|
| 128 | + if ( isset( $js_var[ 'element' ] ) ) { |
|
| 129 | 129 | |
| 130 | 130 | // Array to string. |
| 131 | - if ( is_array( $js_var['element'] ) ) { |
|
| 132 | - $js_var['element'] = implode( ',', $js_var['element'] ); |
|
| 131 | + if ( is_array( $js_var[ 'element' ] ) ) { |
|
| 132 | + $js_var[ 'element' ] = implode( ',', $js_var[ 'element' ] ); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | // Replace single quotes with double quotes to avoid issues with the compiled JS. |
| 136 | - $js_var['element'] = str_replace( '\'', '"', $js_var['element'] ); |
|
| 136 | + $js_var[ 'element' ] = str_replace( '\'', '"', $js_var[ 'element' ] ); |
|
| 137 | 137 | } |
| 138 | - if ( isset( $js_var['function'] ) && 'html' === $js_var['function'] ) { |
|
| 138 | + if ( isset( $js_var[ 'function' ] ) && 'html' === $js_var[ 'function' ] ) { |
|
| 139 | 139 | $script .= $this->script_html_var( $js_var ); |
| 140 | 140 | continue; |
| 141 | 141 | } |
| 142 | - $js_var['index_key'] = $key; |
|
| 142 | + $js_var[ 'index_key' ] = $key; |
|
| 143 | 143 | $callback = $this->get_callback( $args ); |
| 144 | 144 | if ( is_callable( $callback ) ) { |
| 145 | - $field['scripts'][ $key ] = call_user_func_array( $callback, array( $js_var, $args ) ); |
|
| 145 | + $field[ 'scripts' ][ $key ] = call_user_func_array( $callback, array( $js_var, $args ) ); |
|
| 146 | 146 | continue; |
| 147 | 147 | } |
| 148 | - $field['scripts'][ $key ] = $this->script_var( $js_var ); |
|
| 148 | + $field[ 'scripts' ][ $key ] = $this->script_var( $js_var ); |
|
| 149 | 149 | } |
| 150 | 150 | $combo_extra_script = ''; |
| 151 | 151 | $combo_css_script = ''; |
| 152 | - foreach ( $field['scripts'] as $script_array ) { |
|
| 153 | - $combo_extra_script .= $script_array['script']; |
|
| 154 | - $combo_css_script .= ( 'css' !== $combo_css_script ) ? $script_array['css'] : ''; |
|
| 152 | + foreach ( $field[ 'scripts' ] as $script_array ) { |
|
| 153 | + $combo_extra_script .= $script_array[ 'script' ]; |
|
| 154 | + $combo_css_script .= ( 'css' !== $combo_css_script ) ? $script_array[ 'css' ] : ''; |
|
| 155 | 155 | } |
| 156 | 156 | $text = ( 'css' === $combo_css_script ) ? 'css' : '\'' . $combo_css_script . '\''; |
| 157 | 157 | |
| 158 | 158 | $script .= $combo_extra_script . "var cssContent={$text};"; |
| 159 | - if ( isset( $js_var['exclude'] ) ) { |
|
| 159 | + if ( isset( $js_var[ 'exclude' ] ) ) { |
|
| 160 | 160 | $script .= 'if(true===exclude){cssContent="";}'; |
| 161 | 161 | } |
| 162 | 162 | if ( $add_css ) { |
@@ -174,18 +174,18 @@ discard block |
||
| 174 | 174 | * @param array $args The arguments for this js_var. |
| 175 | 175 | */ |
| 176 | 176 | protected function script_html_var( $args ) { |
| 177 | - $script = ( isset( $args['choice'] ) ) ? "newval=newval['{$args['choice']}'];" : ''; |
|
| 177 | + $script = ( isset( $args[ 'choice' ] ) ) ? "newval=newval['{$args[ 'choice' ]}'];" : ''; |
|
| 178 | 178 | |
| 179 | 179 | // Apply the value_pattern. |
| 180 | - if ( isset( $args['value_pattern'] ) && '' !== $args['value_pattern'] ) { |
|
| 180 | + if ( isset( $args[ 'value_pattern' ] ) && '' !== $args[ 'value_pattern' ] ) { |
|
| 181 | 181 | $script .= $this->value_pattern_replacements( 'newval', $args ); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if ( isset( $args['attr'] ) ) { |
|
| 185 | - $script .= "jQuery('{$args['element']}').attr('{$args['attr']}',newval);"; |
|
| 184 | + if ( isset( $args[ 'attr' ] ) ) { |
|
| 185 | + $script .= "jQuery('{$args[ 'element' ]}').attr('{$args[ 'attr' ]}',newval);"; |
|
| 186 | 186 | return $script; |
| 187 | 187 | } |
| 188 | - $script .= "jQuery('{$args['element']}').html(newval);"; |
|
| 188 | + $script .= "jQuery('{$args[ 'element' ]}').html(newval);"; |
|
| 189 | 189 | return $script; |
| 190 | 190 | } |
| 191 | 191 | |
@@ -200,34 +200,34 @@ discard block |
||
| 200 | 200 | $script = ''; |
| 201 | 201 | $property_script = ''; |
| 202 | 202 | |
| 203 | - $value_key = 'newval' . $args['index_key']; |
|
| 203 | + $value_key = 'newval' . $args[ 'index_key' ]; |
|
| 204 | 204 | $property_script .= $value_key . '=newval;'; |
| 205 | 205 | |
| 206 | 206 | $args = $this->get_args( $args ); |
| 207 | 207 | |
| 208 | 208 | // Apply callback to the value if a callback is defined. |
| 209 | - if ( ! empty( $args['js_callback'] ) && is_array( $args['js_callback'] ) && isset( $args['js_callback'][0] ) && ! empty( $args['js_callback'][0] ) ) { |
|
| 210 | - $script .= $value_key . '=' . $args['js_callback'][0] . '(' . $value_key . ',' . $args['js_callback'][1] . ');'; |
|
| 209 | + if ( ! empty( $args[ 'js_callback' ] ) && is_array( $args[ 'js_callback' ] ) && isset( $args[ 'js_callback' ][ 0 ] ) && ! empty( $args[ 'js_callback' ][ 0 ] ) ) { |
|
| 210 | + $script .= $value_key . '=' . $args[ 'js_callback' ][ 0 ] . '(' . $value_key . ',' . $args[ 'js_callback' ][ 1 ] . ');'; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | // Apply the value_pattern. |
| 214 | - if ( '' !== $args['value_pattern'] ) { |
|
| 214 | + if ( '' !== $args[ 'value_pattern' ] ) { |
|
| 215 | 215 | $script .= $this->value_pattern_replacements( $value_key, $args ); |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // Tweak to add url() for background-images. |
| 219 | - if ( 'background-image' === $args['property'] && ( ! isset( $args['value_pattern'] ) || false === strpos( $args['value_pattern'], 'gradient' ) ) ) { |
|
| 219 | + if ( 'background-image' === $args[ 'property' ] && ( ! isset( $args[ 'value_pattern' ] ) || false === strpos( $args[ 'value_pattern' ], 'gradient' ) ) ) { |
|
| 220 | 220 | $script .= 'if(-1===' . $value_key . '.indexOf(\'url(\')){' . $value_key . '=\'url("\'+' . $value_key . '+\'")\';}'; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // Apply prefix. |
| 224 | 224 | $value = $value_key; |
| 225 | - if ( '' !== $args['prefix'] ) { |
|
| 226 | - $value = "'" . $args['prefix'] . "'+" . $value_key; |
|
| 225 | + if ( '' !== $args[ 'prefix' ] ) { |
|
| 226 | + $value = "'" . $args[ 'prefix' ] . "'+" . $value_key; |
|
| 227 | 227 | } |
| 228 | - $css = $args['element'] . '{' . $args['property'] . ':\'+' . $value . '+\'' . $args['units'] . $args['suffix'] . ';}'; |
|
| 229 | - if ( isset( $args['media_query'] ) ) { |
|
| 230 | - $css = $args['media_query'] . '{' . $css . '}'; |
|
| 228 | + $css = $args[ 'element' ] . '{' . $args[ 'property' ] . ':\'+' . $value . '+\'' . $args[ 'units' ] . $args[ 'suffix' ] . ';}'; |
|
| 229 | + if ( isset( $args[ 'media_query' ] ) ) { |
|
| 230 | + $css = $args[ 'media_query' ] . '{' . $css . '}'; |
|
| 231 | 231 | } |
| 232 | 232 | return array( |
| 233 | 233 | 'script' => $property_script . $script, |
@@ -243,42 +243,42 @@ discard block |
||
| 243 | 243 | * @param array $args The arguments for this js_var. |
| 244 | 244 | */ |
| 245 | 245 | protected function script_var_array( $args ) { |
| 246 | - $script = ( 0 === $args['index_key'] ) ? 'css=\'\';' : ''; |
|
| 246 | + $script = ( 0 === $args[ 'index_key' ] ) ? 'css=\'\';' : ''; |
|
| 247 | 247 | $property_script = ''; |
| 248 | 248 | |
| 249 | 249 | // Define choice. |
| 250 | - $choice = ( isset( $args['choice'] ) && '' !== $args['choice'] ) ? $args['choice'] : ''; |
|
| 250 | + $choice = ( isset( $args[ 'choice' ] ) && '' !== $args[ 'choice' ] ) ? $args[ 'choice' ] : ''; |
|
| 251 | 251 | |
| 252 | - $value_key = 'newval' . $args['index_key']; |
|
| 252 | + $value_key = 'newval' . $args[ 'index_key' ]; |
|
| 253 | 253 | $property_script .= $value_key . '=newval;'; |
| 254 | 254 | |
| 255 | 255 | $args = $this->get_args( $args ); |
| 256 | 256 | |
| 257 | 257 | // Apply callback to the value if a callback is defined. |
| 258 | - if ( ! empty( $args['js_callback'] ) && is_array( $args['js_callback'] ) && isset( $args['js_callback'][0] ) && ! empty( $args['js_callback'][0] ) ) { |
|
| 259 | - $script .= $value_key . '=' . $args['js_callback'][0] . '(' . $value_key . ',' . $args['js_callback'][1] . ');'; |
|
| 258 | + if ( ! empty( $args[ 'js_callback' ] ) && is_array( $args[ 'js_callback' ] ) && isset( $args[ 'js_callback' ][ 0 ] ) && ! empty( $args[ 'js_callback' ][ 0 ] ) ) { |
|
| 259 | + $script .= $value_key . '=' . $args[ 'js_callback' ][ 0 ] . '(' . $value_key . ',' . $args[ 'js_callback' ][ 1 ] . ');'; |
|
| 260 | 260 | } |
| 261 | 261 | $script .= '_.each(' . $value_key . ', function(subValue,subKey){'; |
| 262 | 262 | |
| 263 | 263 | // Apply the value_pattern. |
| 264 | - if ( '' !== $args['value_pattern'] ) { |
|
| 264 | + if ( '' !== $args[ 'value_pattern' ] ) { |
|
| 265 | 265 | $script .= $this->value_pattern_replacements( 'subValue', $args ); |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | // Tweak to add url() for background-images. |
| 269 | 269 | if ( '' === $choice || 'background-image' === $choice ) { |
| 270 | - $script .= 'if(\'background-image\'===\'' . $args['property'] . '\'||\'background-image\'===subKey){if(-1===subValue.indexOf(\'url(\')){subValue=\'url("\'+subValue+\'")\';}}'; |
|
| 270 | + $script .= 'if(\'background-image\'===\'' . $args[ 'property' ] . '\'||\'background-image\'===subKey){if(-1===subValue.indexOf(\'url(\')){subValue=\'url("\'+subValue+\'")\';}}'; |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | // Apply prefix. |
| 274 | 274 | $value = $value_key; |
| 275 | - if ( '' !== $args['prefix'] ) { |
|
| 276 | - $value = '\'' . $args['prefix'] . '\'+subValue'; |
|
| 275 | + if ( '' !== $args[ 'prefix' ] ) { |
|
| 276 | + $value = '\'' . $args[ 'prefix' ] . '\'+subValue'; |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | // Mostly used for padding, margin & position properties. |
| 280 | 280 | $direction_script = 'if(_.contains([\'top\',\'bottom\',\'left\',\'right\'],subKey)){'; |
| 281 | - $direction_script .= 'css+=\'' . $args['element'] . '{' . $args['property'] . '-\'+subKey+\':\'+subValue+\'' . $args['units'] . $args['suffix'] . ';}\';}'; |
|
| 281 | + $direction_script .= 'css+=\'' . $args[ 'element' ] . '{' . $args[ 'property' ] . '-\'+subKey+\':\'+subValue+\'' . $args[ 'units' ] . $args[ 'suffix' ] . ';}\';}'; |
|
| 282 | 282 | |
| 283 | 283 | // Allows us to apply this just for a specific choice in the array of the values. |
| 284 | 284 | if ( '' !== $choice ) { |
@@ -287,18 +287,18 @@ discard block |
||
| 287 | 287 | // The script. |
| 288 | 288 | $script .= 'if(\'' . $choice . '\'===subKey){'; |
| 289 | 289 | $script .= ( $choice_is_direction ) ? $direction_script . 'else{' : ''; |
| 290 | - $script .= 'css+=\'' . $args['element'] . '{' . $args['property'] . ':\'+subValue+\';}\';'; |
|
| 290 | + $script .= 'css+=\'' . $args[ 'element' ] . '{' . $args[ 'property' ] . ':\'+subValue+\';}\';'; |
|
| 291 | 291 | $script .= ( $choice_is_direction ) ? '}' : ''; |
| 292 | 292 | $script .= '}'; |
| 293 | 293 | } else { |
| 294 | 294 | |
| 295 | 295 | // This is where most object-based fields will go. |
| 296 | - $script .= $direction_script . 'else{css+=\'' . $args['element'] . '{\'+subKey+\':\'+subValue+\'' . $args['units'] . $args['suffix'] . ';}\';}'; |
|
| 296 | + $script .= $direction_script . 'else{css+=\'' . $args[ 'element' ] . '{\'+subKey+\':\'+subValue+\'' . $args[ 'units' ] . $args[ 'suffix' ] . ';}\';}'; |
|
| 297 | 297 | } |
| 298 | 298 | $script .= '});'; |
| 299 | 299 | |
| 300 | - if ( isset( $args['media_query'] ) ) { |
|
| 301 | - $script .= 'css=\'' . $args['media_query'] . '{\'+css+\'}\';'; |
|
| 300 | + if ( isset( $args[ 'media_query' ] ) ) { |
|
| 301 | + $script .= 'css=\'' . $args[ 'media_query' ] . '{\'+css+\'}\';'; |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | return array( |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | $webfont_loader = 'sc=\'a\';jQuery(\'head\').append(sc.replace(\'a\',\'<\')+\'script>if(!_.isUndefined(WebFont)&&fontFamily){WebFont.load({google:{families:["\'+fontFamily.replace( /\"/g, \'"\' )+\':\'+variant+\':cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai"]}});}\'+sc.replace(\'a\',\'<\')+\'/script>\');'; |
| 327 | 327 | |
| 328 | 328 | // Add the css. |
| 329 | - $css_build_array = array( |
|
| 329 | + $css_build_array = array( |
|
| 330 | 330 | 'font-family' => 'fontFamily', |
| 331 | 331 | 'font-size' => 'fontSize', |
| 332 | 332 | 'line-height' => 'lineHeight', |
@@ -339,41 +339,41 @@ discard block |
||
| 339 | 339 | 'font-weight' => 'fontWeight', |
| 340 | 340 | 'font-style' => 'fontStyle', |
| 341 | 341 | ); |
| 342 | - $choice_condition = ( isset( $args['choice'] ) && '' !== $args['choice'] && isset( $css_build_array[ $args['choice'] ] ) ); |
|
| 342 | + $choice_condition = ( isset( $args[ 'choice' ] ) && '' !== $args[ 'choice' ] && isset( $css_build_array[ $args[ 'choice' ] ] ) ); |
|
| 343 | 343 | $script .= ( ! $choice_condition ) ? $webfont_loader : ''; |
| 344 | 344 | foreach ( $css_build_array as $property => $var ) { |
| 345 | - if ( $choice_condition && $property !== $args['choice'] ) { |
|
| 345 | + if ( $choice_condition && $property !== $args[ 'choice' ] ) { |
|
| 346 | 346 | continue; |
| 347 | 347 | } |
| 348 | 348 | // Fixes https://github.com/aristath/kirki/issues/1436. |
| 349 | - if ( ! isset( $field['default'] ) || ( |
|
| 350 | - ( 'font-family' === $property && ! isset( $field['default']['font-family'] ) ) || |
|
| 351 | - ( 'font-size' === $property && ! isset( $field['default']['font-size'] ) ) || |
|
| 352 | - ( 'line-height' === $property && ! isset( $field['default']['line-height'] ) ) || |
|
| 353 | - ( 'letter-spacing' === $property && ! isset( $field['default']['letter-spacing'] ) ) || |
|
| 354 | - ( 'word-spacing' === $property && ! isset( $field['default']['word-spacing'] ) ) || |
|
| 355 | - ( 'text-align' === $property && ! isset( $field['default']['text-align'] ) ) || |
|
| 356 | - ( 'text-transform' === $property && ! isset( $field['default']['text-transform'] ) ) || |
|
| 357 | - ( 'text-decoration' === $property && ! isset( $field['default']['text-decoration'] ) ) || |
|
| 358 | - ( 'color' === $property && ! isset( $field['default']['color'] ) ) || |
|
| 359 | - ( 'font-weight' === $property && ! isset( $field['default']['variant'] ) && ! isset( $field['default']['font-weight'] ) ) || |
|
| 360 | - ( 'font-style' === $property && ! isset( $field['default']['variant'] ) && ! isset( $field['default']['font-style'] ) ) |
|
| 349 | + if ( ! isset( $field[ 'default' ] ) || ( |
|
| 350 | + ( 'font-family' === $property && ! isset( $field[ 'default' ][ 'font-family' ] ) ) || |
|
| 351 | + ( 'font-size' === $property && ! isset( $field[ 'default' ][ 'font-size' ] ) ) || |
|
| 352 | + ( 'line-height' === $property && ! isset( $field[ 'default' ][ 'line-height' ] ) ) || |
|
| 353 | + ( 'letter-spacing' === $property && ! isset( $field[ 'default' ][ 'letter-spacing' ] ) ) || |
|
| 354 | + ( 'word-spacing' === $property && ! isset( $field[ 'default' ][ 'word-spacing' ] ) ) || |
|
| 355 | + ( 'text-align' === $property && ! isset( $field[ 'default' ][ 'text-align' ] ) ) || |
|
| 356 | + ( 'text-transform' === $property && ! isset( $field[ 'default' ][ 'text-transform' ] ) ) || |
|
| 357 | + ( 'text-decoration' === $property && ! isset( $field[ 'default' ][ 'text-decoration' ] ) ) || |
|
| 358 | + ( 'color' === $property && ! isset( $field[ 'default' ][ 'color' ] ) ) || |
|
| 359 | + ( 'font-weight' === $property && ! isset( $field[ 'default' ][ 'variant' ] ) && ! isset( $field[ 'default' ][ 'font-weight' ] ) ) || |
|
| 360 | + ( 'font-style' === $property && ! isset( $field[ 'default' ][ 'variant' ] ) && ! isset( $field[ 'default' ][ 'font-style' ] ) ) |
|
| 361 | 361 | ) ) { |
| 362 | 362 | continue; |
| 363 | 363 | } |
| 364 | - $script .= ( $choice_condition && 'font-family' === $args['choice'] ) ? $webfont_loader : ''; |
|
| 364 | + $script .= ( $choice_condition && 'font-family' === $args[ 'choice' ] ) ? $webfont_loader : ''; |
|
| 365 | 365 | |
| 366 | - if ( 'font-family' === $property || ( isset( $args['choice'] ) && 'font-family' === $args['choice'] ) ) { |
|
| 366 | + if ( 'font-family' === $property || ( isset( $args[ 'choice' ] ) && 'font-family' === $args[ 'choice' ] ) ) { |
|
| 367 | 367 | $css .= 'fontFamilyCSS=fontFamily;if(0<fontFamily.indexOf(\' \')&&-1===fontFamily.indexOf(\'"\')){fontFamilyCSS=\'"\'+fontFamily+\'"\';}'; |
| 368 | 368 | $var = 'fontFamilyCSS'; |
| 369 | 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 . '+\';}\':\'\';'; |
|
| 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 | 372 | } |
| 373 | 373 | |
| 374 | 374 | $script .= $css; |
| 375 | - if ( isset( $args['media_query'] ) ) { |
|
| 376 | - $script .= 'css=\'' . $args['media_query'] . '{\'+css+\'}\';'; |
|
| 375 | + if ( isset( $args[ 'media_query' ] ) ) { |
|
| 376 | + $script .= 'css=\'' . $args[ 'media_query' ] . '{\'+css+\'}\';'; |
|
| 377 | 377 | } |
| 378 | 378 | return array( |
| 379 | 379 | 'script' => $script, |
@@ -391,8 +391,8 @@ discard block |
||
| 391 | 391 | protected function script_var_image( $args ) { |
| 392 | 392 | $return = $this->script_var( $args ); |
| 393 | 393 | return array( |
| 394 | - 'script' => 'newval=(!_.isUndefined(newval.url))?newval.url:newval;' . $return['script'], |
|
| 395 | - 'css' => $return['css'], |
|
| 394 | + 'script' => 'newval=(!_.isUndefined(newval.url))?newval.url:newval;' . $return[ 'script' ], |
|
| 395 | + 'css' => $return[ 'css' ], |
|
| 396 | 396 | ); |
| 397 | 397 | } |
| 398 | 398 | |
@@ -406,8 +406,8 @@ discard block |
||
| 406 | 406 | */ |
| 407 | 407 | private function before_script( $args ) { |
| 408 | 408 | $script = ''; |
| 409 | - if ( isset( $args['type'] ) ) { |
|
| 410 | - switch ( $args['type'] ) { |
|
| 409 | + if ( isset( $args[ 'type' ] ) ) { |
|
| 410 | + switch ( $args[ 'type' ] ) { |
|
| 411 | 411 | case 'kirki-typography': |
| 412 | 412 | $script .= 'fontFamily=(_.isUndefined(newval[\'font-family\']))?\'\':newval[\'font-family\'];variant=(_.isUndefined(newval.variant))?\'400\':newval.variant;fontSize=(_.isUndefined(newval[\'font-size\']))?\'\':newval[\'font-size\'];lineHeight=(_.isUndefined(newval[\'line-height\']))?\'\':newval[\'line-height\'];letterSpacing=(_.isUndefined(newval[\'letter-spacing\']))?\'\':newval[\'letter-spacing\'];wordSpacing=(_.isUndefined(newval[\'word-spacing\']))?\'\':newval[\'word-spacing\'];textAlign=(_.isUndefined(newval[\'text-align\']))?\'\':newval[\'text-align\'];textTransform=(_.isUndefined(newval[\'text-transform\']))?\'\':newval[\'text-transform\'];textDecoration=(_.isUndefined(newval[\'text-decoration\']))?\'\':newval[\'text-decoration\'];color=(_.isUndefined(newval.color))?\'\':newval.color;fw=(!_.isString(newval.variant))?\'400\':newval.variant.match(/\d/g);fontWeight=(!_.isObject(fw))?400:fw.join(\'\');fontStyle=(variant&&-1!==variant.indexOf(\'italic\'))?\'italic\':\'normal\';css=\'\';'; |
| 413 | 413 | break; |
@@ -440,17 +440,17 @@ discard block |
||
| 440 | 440 | ); |
| 441 | 441 | |
| 442 | 442 | // Element should be a string. |
| 443 | - if ( is_array( $args['element'] ) ) { |
|
| 444 | - $args['element'] = implode( ',', $args['element'] ); |
|
| 443 | + if ( is_array( $args[ 'element' ] ) ) { |
|
| 444 | + $args[ 'element' ] = implode( ',', $args[ 'element' ] ); |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | // Make sure arguments that are passed-on to callbacks are strings. |
| 448 | - if ( is_array( $args['js_callback'] ) && isset( $args['js_callback'][1] ) && is_array( $args['js_callback'][1] ) ) { |
|
| 449 | - $args['js_callback'][1] = wp_json_encode( $args['js_callback'][1] ); |
|
| 448 | + if ( is_array( $args[ 'js_callback' ] ) && isset( $args[ 'js_callback' ][ 1 ] ) && is_array( $args[ 'js_callback' ][ 1 ] ) ) { |
|
| 449 | + $args[ 'js_callback' ][ 1 ] = wp_json_encode( $args[ 'js_callback' ][ 1 ] ); |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | - if ( ! isset( $args['js_callback'][1] ) ) { |
|
| 453 | - $args['js_callback'][1] = ''; |
|
| 452 | + if ( ! isset( $args[ 'js_callback' ][ 1 ] ) ) { |
|
| 453 | + $args[ 'js_callback' ][ 1 ] = ''; |
|
| 454 | 454 | } |
| 455 | 455 | return $args; |
| 456 | 456 | } |
@@ -467,15 +467,15 @@ discard block |
||
| 467 | 467 | private function value_pattern_replacements( $value, $js_vars ) { |
| 468 | 468 | $script = ''; |
| 469 | 469 | $alias = $value; |
| 470 | - if ( ! isset( $js_vars['value_pattern'] ) ) { |
|
| 470 | + if ( ! isset( $js_vars[ 'value_pattern' ] ) ) { |
|
| 471 | 471 | return $value; |
| 472 | 472 | } |
| 473 | - $value = $js_vars['value_pattern']; |
|
| 474 | - if ( isset( $js_vars['pattern_replace'] ) ) { |
|
| 473 | + $value = $js_vars[ 'value_pattern' ]; |
|
| 474 | + if ( isset( $js_vars[ 'pattern_replace' ] ) ) { |
|
| 475 | 475 | $script .= 'settings=window.wp.customize.get();'; |
| 476 | - foreach ( $js_vars['pattern_replace'] as $search => $replace ) { |
|
| 476 | + foreach ( $js_vars[ 'pattern_replace' ] as $search => $replace ) { |
|
| 477 | 477 | $replace = '\'+settings["' . $replace . '"]+\''; |
| 478 | - $value = str_replace( $search, $replace, $js_vars['value_pattern'] ); |
|
| 478 | + $value = str_replace( $search, $replace, $js_vars[ 'value_pattern' ] ); |
|
| 479 | 479 | $value = trim( $value, '+' ); |
| 480 | 480 | } |
| 481 | 481 | } |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | * @return string|array A callable function or method. |
| 495 | 495 | */ |
| 496 | 496 | protected function get_callback( $args ) { |
| 497 | - switch ( $args['type'] ) { |
|
| 497 | + switch ( $args[ 'type' ] ) { |
|
| 498 | 498 | case 'kirki-background': |
| 499 | 499 | case 'kirki-dimensions': |
| 500 | 500 | case 'kirki-multicolor': |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | parent::to_json(); |
| 69 | 69 | |
| 70 | 70 | // Required. |
| 71 | - $this->json['required'] = $this->required; |
|
| 71 | + $this->json[ 'required' ] = $this->required; |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -89,25 +89,25 @@ discard block |
||
| 89 | 89 | $name_parts = explode( '_', str_replace( 'Kirki_', '', $class_name ) ); |
| 90 | 90 | |
| 91 | 91 | // Handle modules loading. |
| 92 | - if ( isset( $name_parts[0] ) && 'Modules' === $name_parts[0] ) { |
|
| 92 | + if ( isset( $name_parts[ 0 ] ) && 'Modules' === $name_parts[ 0 ] ) { |
|
| 93 | 93 | $path = dirname( __FILE__ ) . '/modules/'; |
| 94 | 94 | $path .= strtolower( str_replace( '_', '-', str_replace( 'Kirki_Modules_', '', $class_name ) ) ) . '/'; |
| 95 | - $paths[] = $path . $filename; |
|
| 95 | + $paths[ ] = $path . $filename; |
|
| 96 | 96 | } elseif ( 'Kirki_Fonts' === $class_name ) { |
| 97 | - $paths[] = dirname( __FILE__ ) . '/modules/webfonts/class-kirki-fonts.php'; |
|
| 97 | + $paths[ ] = dirname( __FILE__ ) . '/modules/webfonts/class-kirki-fonts.php'; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - if ( isset( $name_parts[0] ) ) { |
|
| 100 | + if ( isset( $name_parts[ 0 ] ) ) { |
|
| 101 | 101 | |
| 102 | 102 | // Handle controls loading. |
| 103 | - if ( 'Control' === $name_parts[0] || 'Settings' === $name_parts[0] ) { |
|
| 103 | + if ( 'Control' === $name_parts[ 0 ] || 'Settings' === $name_parts[ 0 ] ) { |
|
| 104 | 104 | $path = dirname( __FILE__ ) . '/controls/php/'; |
| 105 | - $paths[] = $path . $filename; |
|
| 105 | + $paths[ ] = $path . $filename; |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $paths[] = dirname( __FILE__ ) . '/core/' . $filename; |
|
| 110 | - $paths[] = dirname( __FILE__ ) . '/lib/' . $filename; |
|
| 109 | + $paths[ ] = dirname( __FILE__ ) . '/core/' . $filename; |
|
| 110 | + $paths[ ] = dirname( __FILE__ ) . '/lib/' . $filename; |
|
| 111 | 111 | |
| 112 | 112 | $substr = str_replace( 'Kirki_', '', $class_name ); |
| 113 | 113 | $exploded = explode( '_', $substr ); |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | $previous_path = ''; |
| 117 | 117 | for ( $i = 0; $i < $levels; $i++ ) { |
| 118 | - $paths[] = dirname( __FILE__ ) . '/' . $previous_path . strtolower( $exploded[ $i ] ) . '/' . $filename; |
|
| 118 | + $paths[ ] = dirname( __FILE__ ) . '/' . $previous_path . strtolower( $exploded[ $i ] ) . '/' . $filename; |
|
| 119 | 119 | $previous_path .= strtolower( $exploded[ $i ] ) . '/'; |
| 120 | 120 | } |
| 121 | 121 | return $paths; |