@@ -53,7 +53,7 @@ |
||
| 53 | 53 | public function to_json() { |
| 54 | 54 | parent::to_json(); |
| 55 | 55 | |
| 56 | - $this->json['multiple'] = $this->multiple; |
|
| 57 | - $this->json['placeholder'] = $this->placeholder; |
|
| 56 | + $this->json[ 'multiple' ] = $this->multiple; |
|
| 57 | + $this->json[ 'placeholder' ] = $this->placeholder; |
|
| 58 | 58 | } |
| 59 | 59 | } |
@@ -217,7 +217,8 @@ |
||
| 217 | 217 | } |
| 218 | 218 | // If 'choice' is defined check for sub-values too. |
| 219 | 219 | // Fixes https://github.com/aristath/kirki/issues/1416. |
| 220 | - if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
| 220 | + if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { |
|
| 221 | +// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
| 221 | 222 | $skip = true; |
| 222 | 223 | } |
| 223 | 224 | } |
@@ -83,13 +83,13 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | protected function apply_sanitize_callback( $output, $value ) { |
| 85 | 85 | |
| 86 | - if ( isset( $output['sanitize_callback'] ) && null !== $output['sanitize_callback'] ) { |
|
| 86 | + if ( isset( $output[ 'sanitize_callback' ] ) && null !== $output[ 'sanitize_callback' ] ) { |
|
| 87 | 87 | |
| 88 | 88 | // If the sanitize_callback is invalid, return the value. |
| 89 | - if ( ! is_callable( $output['sanitize_callback'] ) ) { |
|
| 89 | + if ( ! is_callable( $output[ 'sanitize_callback' ] ) ) { |
|
| 90 | 90 | return $value; |
| 91 | 91 | } |
| 92 | - return call_user_func( $output['sanitize_callback'], $this->value ); |
|
| 92 | + return call_user_func( $output[ 'sanitize_callback' ], $this->value ); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | return $value; |
@@ -105,22 +105,22 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | protected function apply_value_pattern( $output, $value ) { |
| 107 | 107 | |
| 108 | - if ( isset( $output['value_pattern'] ) && ! empty( $output['value_pattern'] ) && is_string( $output['value_pattern'] ) ) { |
|
| 108 | + if ( isset( $output[ 'value_pattern' ] ) && ! empty( $output[ 'value_pattern' ] ) && is_string( $output[ 'value_pattern' ] ) ) { |
|
| 109 | 109 | if ( ! is_array( $value ) ) { |
| 110 | - $value = str_replace( '$', $value, $output['value_pattern'] ); |
|
| 110 | + $value = str_replace( '$', $value, $output[ 'value_pattern' ] ); |
|
| 111 | 111 | } |
| 112 | 112 | if ( is_array( $value ) ) { |
| 113 | 113 | foreach ( array_keys( $value ) as $value_k ) { |
| 114 | 114 | if ( ! is_string( $value[ $value_k ] ) ) { |
| 115 | 115 | continue; |
| 116 | 116 | } |
| 117 | - if ( isset( $output['choice'] ) ) { |
|
| 118 | - if ( $output['choice'] === $value_k ) { |
|
| 119 | - $value[ $output['choice'] ] = str_replace( '$', $value[ $output['choice'] ], $output['value_pattern'] ); |
|
| 117 | + if ( isset( $output[ 'choice' ] ) ) { |
|
| 118 | + if ( $output[ 'choice' ] === $value_k ) { |
|
| 119 | + $value[ $output[ 'choice' ] ] = str_replace( '$', $value[ $output[ 'choice' ] ], $output[ 'value_pattern' ] ); |
|
| 120 | 120 | } |
| 121 | 121 | continue; |
| 122 | 122 | } |
| 123 | - $value[ $value_k ] = str_replace( '$', $value[ $value_k ], $output['value_pattern'] ); |
|
| 123 | + $value[ $value_k ] = str_replace( '$', $value[ $value_k ], $output[ 'value_pattern' ] ); |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | $value = $this->apply_pattern_replace( $output, $value ); |
@@ -136,14 +136,14 @@ discard block |
||
| 136 | 136 | * @return string|array |
| 137 | 137 | */ |
| 138 | 138 | protected function apply_pattern_replace( $output, $value ) { |
| 139 | - if ( isset( $output['pattern_replace'] ) && is_array( $output['pattern_replace'] ) ) { |
|
| 139 | + if ( isset( $output[ 'pattern_replace' ] ) && is_array( $output[ 'pattern_replace' ] ) ) { |
|
| 140 | 140 | $option_type = ( '' !== Kirki::get_config_param( $this->config_id, 'option_type' ) ) ? Kirki::get_config_param( $this->config_id, 'option_type' ) : 'theme_mod'; |
| 141 | 141 | $option_name = Kirki::get_config_param( $this->config_id, 'option_name' ); |
| 142 | 142 | $options = array(); |
| 143 | 143 | if ( $option_name ) { |
| 144 | 144 | $options = ( 'site_option' === $option_type ) ? get_site_option( $option_name ) : get_option( $option_name ); |
| 145 | 145 | } |
| 146 | - foreach ( $output['pattern_replace'] as $search => $replace ) { |
|
| 146 | + foreach ( $output[ 'pattern_replace' ] as $search => $replace ) { |
|
| 147 | 147 | $replacement = ''; |
| 148 | 148 | switch ( $option_type ) { |
| 149 | 149 | case 'option': |
@@ -203,8 +203,8 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | // No need to proceed this if the current value is the same as in the "exclude" value. |
| 206 | - if ( isset( $output['exclude'] ) && is_array( $output['exclude'] ) ) { |
|
| 207 | - foreach ( $output['exclude'] as $exclude ) { |
|
| 206 | + if ( isset( $output[ 'exclude' ] ) && is_array( $output[ 'exclude' ] ) ) { |
|
| 207 | + foreach ( $output[ 'exclude' ] as $exclude ) { |
|
| 208 | 208 | if ( is_array( $value ) ) { |
| 209 | 209 | if ( is_array( $exclude ) ) { |
| 210 | 210 | $diff1 = array_diff( $value, $exclude ); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | } |
| 217 | 217 | // If 'choice' is defined check for sub-values too. |
| 218 | 218 | // Fixes https://github.com/aristath/kirki/issues/1416. |
| 219 | - if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
| 219 | + if ( isset( $output[ 'choice' ] ) && isset( $value[ $output[ 'choice' ] ] ) && $exclude == $value[ $output[ 'choice' ] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
| 220 | 220 | $skip = true; |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -237,10 +237,10 @@ discard block |
||
| 237 | 237 | // Apply any value patterns defined. |
| 238 | 238 | $value = $this->apply_value_pattern( $output, $value ); |
| 239 | 239 | |
| 240 | - if ( isset( $output['element'] ) && is_array( $output['element'] ) ) { |
|
| 241 | - $output['element'] = array_unique( $output['element'] ); |
|
| 242 | - sort( $output['element'] ); |
|
| 243 | - $output['element'] = implode( ',', $output['element'] ); |
|
| 240 | + if ( isset( $output[ 'element' ] ) && is_array( $output[ 'element' ] ) ) { |
|
| 241 | + $output[ 'element' ] = array_unique( $output[ 'element' ] ); |
|
| 242 | + sort( $output[ 'element' ] ); |
|
| 243 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | $value = $this->process_value( $value, $output ); |
@@ -258,13 +258,13 @@ discard block |
||
| 258 | 258 | * @return null |
| 259 | 259 | */ |
| 260 | 260 | protected function process_output( $output, $value ) { |
| 261 | - if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { |
|
| 261 | + if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) { |
|
| 262 | 262 | return; |
| 263 | 263 | } |
| 264 | - $output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global'; |
|
| 265 | - $output['prefix'] = ( isset( $output['prefix'] ) ) ? $output['prefix'] : ''; |
|
| 266 | - $output['units'] = ( isset( $output['units'] ) ) ? $output['units'] : ''; |
|
| 267 | - $output['suffix'] = ( isset( $output['suffix'] ) ) ? $output['suffix'] : ''; |
|
| 264 | + $output[ 'media_query' ] = ( isset( $output[ 'media_query' ] ) ) ? $output[ 'media_query' ] : 'global'; |
|
| 265 | + $output[ 'prefix' ] = ( isset( $output[ 'prefix' ] ) ) ? $output[ 'prefix' ] : ''; |
|
| 266 | + $output[ 'units' ] = ( isset( $output[ 'units' ] ) ) ? $output[ 'units' ] : ''; |
|
| 267 | + $output[ 'suffix' ] = ( isset( $output[ 'suffix' ] ) ) ? $output[ 'suffix' ] : ''; |
|
| 268 | 268 | |
| 269 | 269 | // Properties that can accept multiple values. |
| 270 | 270 | // Useful for example for gradients where all browsers use the "background-image" property |
@@ -273,15 +273,15 @@ discard block |
||
| 273 | 273 | 'background-image', |
| 274 | 274 | 'background', |
| 275 | 275 | ); |
| 276 | - if ( in_array( $output['property'], $accepts_multiple, true ) ) { |
|
| 277 | - if ( isset( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) && ! is_array( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) ) { |
|
| 278 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = (array) $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ]; |
|
| 276 | + if ( in_array( $output[ 'property' ], $accepts_multiple, true ) ) { |
|
| 277 | + if ( isset( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) && ! is_array( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) ) { |
|
| 278 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = (array) $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ]; |
|
| 279 | 279 | } |
| 280 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ][] = $output['prefix'] . $value . $output['units'] . $output['suffix']; |
|
| 280 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ][ ] = $output[ 'prefix' ] . $value . $output[ 'units' ] . $output[ 'suffix' ]; |
|
| 281 | 281 | return; |
| 282 | 282 | } |
| 283 | 283 | if ( is_string( $value ) || is_numeric( $value ) ) { |
| 284 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value ) . $output['units'] . $output['suffix']; |
|
| 284 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value ) . $output[ 'units' ] . $output[ 'suffix' ]; |
|
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | |
@@ -320,8 +320,8 @@ discard block |
||
| 320 | 320 | * @return string|array |
| 321 | 321 | */ |
| 322 | 322 | protected function process_value( $value, $output ) { |
| 323 | - if ( isset( $output['property'] ) ) { |
|
| 324 | - return $this->process_property_value( $output['property'], $value ); |
|
| 323 | + if ( isset( $output[ 'property' ] ) ) { |
|
| 324 | + return $this->process_property_value( $output[ 'property' ], $value ); |
|
| 325 | 325 | } |
| 326 | 326 | return $value; |
| 327 | 327 | } |
@@ -92,7 +92,7 @@ |
||
| 92 | 92 | |
| 93 | 93 | if ( is_array( $value ) ) { |
| 94 | 94 | foreach ( $value as $key => $subvalue ) { |
| 95 | - if ( '' !== $subvalue || isset( $this->choices[''] ) ) { |
|
| 95 | + if ( '' !== $subvalue || isset( $this->choices[ '' ] ) ) { |
|
| 96 | 96 | $key = sanitize_key( $key ); |
| 97 | 97 | $value[ $key ] = esc_attr( $subvalue ); |
| 98 | 98 | } |
@@ -68,10 +68,10 @@ |
||
| 68 | 68 | |
| 69 | 69 | $default_args = array( |
| 70 | 70 | 'controls' => array( |
| 71 | - 'top' => ( isset( $this->default['top'] ) ), |
|
| 72 | - 'bottom' => ( isset( $this->default['top'] ) ), |
|
| 73 | - 'left' => ( isset( $this->default['top'] ) ), |
|
| 74 | - 'right' => ( isset( $this->default['top'] ) ), |
|
| 71 | + 'top' => ( isset( $this->default[ 'top' ] ) ), |
|
| 72 | + 'bottom' => ( isset( $this->default[ 'top' ] ) ), |
|
| 73 | + 'left' => ( isset( $this->default[ 'top' ] ) ), |
|
| 74 | + 'right' => ( isset( $this->default[ 'top' ] ) ), |
|
| 75 | 75 | ), |
| 76 | 76 | 'labels' => array( |
| 77 | 77 | 'top' => esc_attr__( 'Top', 'kirki' ), |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 44 | 44 | } |
| 45 | 45 | $data = get_plugin_data( KIRKI_PLUGIN_FILE ); |
| 46 | - $version = ( isset( $data['Version'] ) ) ? $data['Version'] : false; |
|
| 46 | + $version = ( isset( $data[ 'Version' ] ) ) ? $data[ 'Version' ] : false; |
|
| 47 | 47 | define( 'KIRKI_VERSION', $version ); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -49,16 +49,16 @@ |
||
| 49 | 49 | // The default class to be used when creating a section. |
| 50 | 50 | $section_classname = 'WP_Customize_Section'; |
| 51 | 51 | |
| 52 | - if ( isset( $args['type'] ) && array_key_exists( $args['type'], $this->section_types ) ) { |
|
| 53 | - $section_classname = $this->section_types[ $args['type'] ]; |
|
| 52 | + if ( isset( $args[ 'type' ] ) && array_key_exists( $args[ 'type' ], $this->section_types ) ) { |
|
| 53 | + $section_classname = $this->section_types[ $args[ 'type' ] ]; |
|
| 54 | 54 | } |
| 55 | - if ( isset( $args['type'] ) && 'kirki-outer' === $args['type'] ) { |
|
| 56 | - $args['type'] = 'outer'; |
|
| 55 | + if ( isset( $args[ 'type' ] ) && 'kirki-outer' === $args[ 'type' ] ) { |
|
| 56 | + $args[ 'type' ] = 'outer'; |
|
| 57 | 57 | $section_classname = 'WP_Customize_Section'; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // Add the section. |
| 61 | - $wp_customize->add_section( new $section_classname( $wp_customize, sanitize_key( $args['id'] ), $args ) ); |
|
| 61 | + $wp_customize->add_section( new $section_classname( $wp_customize, sanitize_key( $args[ 'id' ] ), $args ) ); |
|
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -67,28 +67,28 @@ |
||
| 67 | 67 | |
| 68 | 68 | // Get the classname we'll be using to create our setting(s). |
| 69 | 69 | $classname = false; |
| 70 | - if ( isset( $args['option_type'] ) && array_key_exists( $args['option_type'], $this->setting_types ) ) { |
|
| 71 | - $classname = $this->setting_types[ $args['option_type'] ]; |
|
| 70 | + if ( isset( $args[ 'option_type' ] ) && array_key_exists( $args[ 'option_type' ], $this->setting_types ) ) { |
|
| 71 | + $classname = $this->setting_types[ $args[ 'option_type' ] ]; |
|
| 72 | 72 | } |
| 73 | - if ( ! isset( $args['type'] ) || ! array_key_exists( $args['type'], $this->setting_types ) ) { |
|
| 74 | - $args['type'] = 'default'; |
|
| 73 | + if ( ! isset( $args[ 'type' ] ) || ! array_key_exists( $args[ 'type' ], $this->setting_types ) ) { |
|
| 74 | + $args[ 'type' ] = 'default'; |
|
| 75 | 75 | } |
| 76 | - $classname = ! $classname ? $this->setting_types[ $args['type'] ] : $classname; |
|
| 76 | + $classname = ! $classname ? $this->setting_types[ $args[ 'type' ] ] : $classname; |
|
| 77 | 77 | |
| 78 | 78 | // If settings are defined as an array, then we need to go through them |
| 79 | 79 | // and call add_setting for each one of them separately. |
| 80 | - if ( isset( $args['settings'] ) && is_array( $args['settings'] ) ) { |
|
| 80 | + if ( isset( $args[ 'settings' ] ) && is_array( $args[ 'settings' ] ) ) { |
|
| 81 | 81 | |
| 82 | 82 | // Make sure defaults have been defined. |
| 83 | - if ( ! isset( $args['default'] ) || ! is_array( $args['default'] ) ) { |
|
| 84 | - $args['default'] = array(); |
|
| 83 | + if ( ! isset( $args[ 'default' ] ) || ! is_array( $args[ 'default' ] ) ) { |
|
| 84 | + $args[ 'default' ] = array(); |
|
| 85 | 85 | } |
| 86 | - foreach ( $args['settings'] as $key => $value ) { |
|
| 86 | + foreach ( $args[ 'settings' ] as $key => $value ) { |
|
| 87 | 87 | $default = ( isset( $defaults[ $key ] ) ) ? $defaults[ $key ] : ''; |
| 88 | - $this->add_setting( $classname, $value, $default, $args['option_type'], $args['capability'], $args['transport'], $args['sanitize_callback'] ); |
|
| 88 | + $this->add_setting( $classname, $value, $default, $args[ 'option_type' ], $args[ 'capability' ], $args[ 'transport' ], $args[ 'sanitize_callback' ] ); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | - $this->add_setting( $classname, $args['settings'], $args['default'], $args['option_type'], $args['capability'], $args['transport'], $args['sanitize_callback'] ); |
|
| 91 | + $this->add_setting( $classname, $args[ 'settings' ], $args[ 'default' ], $args[ 'option_type' ], $args[ 'capability' ], $args[ 'transport' ], $args[ 'sanitize_callback' ] ); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -89,23 +89,23 @@ 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 | } |
| 97 | 97 | |
| 98 | - if ( isset( $name_parts[0] ) ) { |
|
| 98 | + if ( isset( $name_parts[ 0 ] ) ) { |
|
| 99 | 99 | |
| 100 | 100 | // Handle controls loading. |
| 101 | - if ( 'Control' === $name_parts[0] || 'Settings' === $name_parts[0] ) { |
|
| 101 | + if ( 'Control' === $name_parts[ 0 ] || 'Settings' === $name_parts[ 0 ] ) { |
|
| 102 | 102 | $path = dirname( __FILE__ ) . '/controls/php/'; |
| 103 | - $paths[] = $path . $filename; |
|
| 103 | + $paths[ ] = $path . $filename; |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - $paths[] = dirname( __FILE__ ) . '/core/' . $filename; |
|
| 108 | - $paths[] = dirname( __FILE__ ) . '/lib/' . $filename; |
|
| 107 | + $paths[ ] = dirname( __FILE__ ) . '/core/' . $filename; |
|
| 108 | + $paths[ ] = dirname( __FILE__ ) . '/lib/' . $filename; |
|
| 109 | 109 | |
| 110 | 110 | $substr = str_replace( 'Kirki_', '', $class_name ); |
| 111 | 111 | $exploded = explode( '_', $substr ); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $previous_path = ''; |
| 115 | 115 | for ( $i = 0; $i < $levels; $i++ ) { |
| 116 | - $paths[] = dirname( __FILE__ ) . '/' . $previous_path . strtolower( $exploded[ $i ] ) . '/' . $filename; |
|
| 116 | + $paths[ ] = dirname( __FILE__ ) . '/' . $previous_path . strtolower( $exploded[ $i ] ) . '/' . $filename; |
|
| 117 | 117 | $previous_path .= strtolower( $exploded[ $i ] ) . '/'; |
| 118 | 118 | } |
| 119 | 119 | return $paths; |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | // Get defaults from the class. |
| 93 | 93 | $defaults = get_class_vars( __CLASS__ ); |
| 94 | 94 | // Skip what we don't need in this context. |
| 95 | - unset( $defaults['config_final'] ); |
|
| 96 | - unset( $defaults['instances'] ); |
|
| 95 | + unset( $defaults[ 'config_final' ] ); |
|
| 96 | + unset( $defaults[ 'instances' ] ); |
|
| 97 | 97 | // Apply any kirki_config global filters. |
| 98 | 98 | $defaults = apply_filters( 'kirki_config', $defaults ); |
| 99 | 99 | // Merge our args with the defaults. |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | public static function get_config_ids() { |
| 162 | 162 | $configs = array(); |
| 163 | 163 | foreach ( self::$instances as $instance ) { |
| 164 | - $configs[] = $instance->id; |
|
| 164 | + $configs[ ] = $instance->id; |
|
| 165 | 165 | } |
| 166 | 166 | return array_unique( $configs ); |
| 167 | 167 | } |