@@ -35,23 +35,23 @@ discard block |
||
| 35 | 35 | public function to_json() { |
| 36 | 36 | parent::to_json(); |
| 37 | 37 | |
| 38 | - if ( is_array( $this->json['value'] ) ) { |
|
| 39 | - foreach ( array_keys( $this->json['value'] ) as $key ) { |
|
| 40 | - if ( ! in_array( $key, array( 'variant', 'font-weight', 'font-style' ), true ) && ! isset( $this->json['default'][ $key ] ) ) { |
|
| 41 | - unset( $this->json['value'][ $key ] ); |
|
| 38 | + if ( is_array( $this->json[ 'value' ] ) ) { |
|
| 39 | + foreach ( array_keys( $this->json[ 'value' ] ) as $key ) { |
|
| 40 | + if ( ! in_array( $key, array( 'variant', 'font-weight', 'font-style' ), true ) && ! isset( $this->json[ 'default' ][ $key ] ) ) { |
|
| 41 | + unset( $this->json[ 'value' ][ $key ] ); |
|
| 42 | 42 | } |
| 43 | 43 | // Fix for https://wordpress.org/support/topic/white-font-after-updateing-to-3-0-16. |
| 44 | - if ( ! isset( $this->json['default'][ $key ] ) ) { |
|
| 45 | - unset( $this->json['value'][ $key ] ); |
|
| 44 | + if ( ! isset( $this->json[ 'default' ][ $key ] ) ) { |
|
| 45 | + unset( $this->json[ 'value' ][ $key ] ); |
|
| 46 | 46 | } |
| 47 | 47 | // Fix for https://github.com/aristath/kirki/issues/1405. |
| 48 | - if ( isset( $this->json['default'][ $key ] ) && false === $this->json['default'][ $key ] ) { |
|
| 49 | - unset( $this->json['value'][ $key ] ); |
|
| 48 | + if ( isset( $this->json[ 'default' ][ $key ] ) && false === $this->json[ 'default' ][ $key ] ) { |
|
| 49 | + unset( $this->json[ 'value' ][ $key ] ); |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $this->json['show_variants'] = ( true === Kirki_Fonts_Google::$force_load_all_variants ) ? false : true; |
|
| 54 | + $this->json[ 'show_variants' ] = ( true === Kirki_Fonts_Google::$force_load_all_variants ) ? false : true; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -238,12 +238,12 @@ discard block |
||
| 238 | 238 | $final_variants = array(); |
| 239 | 239 | foreach ( $variants as $variant ) { |
| 240 | 240 | if ( is_string( $variant ) ) { |
| 241 | - $final_variants[] = array( |
|
| 241 | + $final_variants[ ] = array( |
|
| 242 | 242 | 'id' => $variant, |
| 243 | 243 | 'label' => isset( $all_variants[ $variant ] ) ? $all_variants[ $variant ] : $variant, |
| 244 | 244 | ); |
| 245 | - } elseif ( is_array( $variant ) && isset( $variant['id'] ) && isset( $variant['label'] ) ) { |
|
| 246 | - $final_variants[] = $variant; |
|
| 245 | + } elseif ( is_array( $variant ) && isset( $variant[ 'id' ] ) && isset( $variant[ 'label' ] ) ) { |
|
| 246 | + $final_variants[ ] = $variant; |
|
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | return $final_variants; |
@@ -137,11 +137,11 @@ |
||
| 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 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | $config = Kirki_Config::get_instance( $config_id, $args ); |
| 146 | 146 | $config_args = $config->get_config(); |
| 147 | - self::$config[ $config_args['id'] ] = $config_args; |
|
| 147 | + self::$config[ $config_args[ 'id' ] ] = $config_args; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -157,13 +157,13 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | public static function add_panel( $id = '', $args = array() ) { |
| 159 | 159 | |
| 160 | - $args['id'] = esc_attr( $id ); |
|
| 161 | - $args['description'] = ( isset( $args['description'] ) ) ? $args['description'] : ''; |
|
| 162 | - $args['priority'] = ( isset( $args['priority'] ) ) ? absint( $args['priority'] ) : 10; |
|
| 163 | - $args['type'] = ( isset( $args['type'] ) ) ? $args['type'] : 'default'; |
|
| 164 | - $args['type'] = 'kirki-' . $args['type']; |
|
| 160 | + $args[ 'id' ] = esc_attr( $id ); |
|
| 161 | + $args[ 'description' ] = ( isset( $args[ 'description' ] ) ) ? $args[ 'description' ] : ''; |
|
| 162 | + $args[ 'priority' ] = ( isset( $args[ 'priority' ] ) ) ? absint( $args[ 'priority' ] ) : 10; |
|
| 163 | + $args[ 'type' ] = ( isset( $args[ 'type' ] ) ) ? $args[ 'type' ] : 'default'; |
|
| 164 | + $args[ 'type' ] = 'kirki-' . $args[ 'type' ]; |
|
| 165 | 165 | |
| 166 | - self::$panels[ $args['id'] ] = $args; |
|
| 166 | + self::$panels[ $args[ 'id' ] ] = $args; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | */ |
| 177 | 177 | public static function remove_panel( $id = '' ) { |
| 178 | 178 | if ( ! in_array( $id, self::$panels_to_remove, true ) ) { |
| 179 | - self::$panels_to_remove[] = $id; |
|
| 179 | + self::$panels_to_remove[ ] = $id; |
|
| 180 | 180 | } |
| 181 | 181 | } |
| 182 | 182 | |
@@ -190,14 +190,14 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | public static function add_section( $id, $args ) { |
| 192 | 192 | |
| 193 | - $args['id'] = esc_attr( $id ); |
|
| 194 | - $args['panel'] = ( isset( $args['panel'] ) ) ? esc_attr( $args['panel'] ) : ''; |
|
| 195 | - $args['description'] = ( isset( $args['description'] ) ) ? $args['description'] : ''; |
|
| 196 | - $args['priority'] = ( isset( $args['priority'] ) ) ? absint( $args['priority'] ) : 10; |
|
| 197 | - $args['type'] = ( isset( $args['type'] ) ) ? $args['type'] : 'default'; |
|
| 198 | - $args['type'] = 'kirki-' . $args['type']; |
|
| 193 | + $args[ 'id' ] = esc_attr( $id ); |
|
| 194 | + $args[ 'panel' ] = ( isset( $args[ 'panel' ] ) ) ? esc_attr( $args[ 'panel' ] ) : ''; |
|
| 195 | + $args[ 'description' ] = ( isset( $args[ 'description' ] ) ) ? $args[ 'description' ] : ''; |
|
| 196 | + $args[ 'priority' ] = ( isset( $args[ 'priority' ] ) ) ? absint( $args[ 'priority' ] ) : 10; |
|
| 197 | + $args[ 'type' ] = ( isset( $args[ 'type' ] ) ) ? $args[ 'type' ] : 'default'; |
|
| 198 | + $args[ 'type' ] = 'kirki-' . $args[ 'type' ]; |
|
| 199 | 199 | |
| 200 | - self::$sections[ $args['id'] ] = $args; |
|
| 200 | + self::$sections[ $args[ 'id' ] ] = $args; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | */ |
| 211 | 211 | public static function remove_section( $id = '' ) { |
| 212 | 212 | if ( ! in_array( $id, self::$sections_to_remove, true ) ) { |
| 213 | - self::$sections_to_remove[] = $id; |
|
| 213 | + self::$sections_to_remove[ ] = $id; |
|
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | 216 | |
@@ -229,16 +229,16 @@ discard block |
||
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // Early exit if 'type' is not defined. |
| 232 | - if ( ! isset( $args['type'] ) ) { |
|
| 232 | + if ( ! isset( $args[ 'type' ] ) ) { |
|
| 233 | 233 | return; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | // If the field is font-awesome, enqueue the icons on the frontend. |
| 237 | - if ( class_exists( 'Kirki_Modules_CSS' ) && ( 'fontawesome' === $args['type'] || 'kirki-fontawesome' === $args['type'] ) ) { |
|
| 237 | + if ( class_exists( 'Kirki_Modules_CSS' ) && ( 'fontawesome' === $args[ 'type' ] || 'kirki-fontawesome' === $args[ 'type' ] ) ) { |
|
| 238 | 238 | Kirki_Modules_CSS::add_fontawesome_script(); |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - $str = str_replace( array( '-', '_' ), ' ', $args['type'] ); |
|
| 241 | + $str = str_replace( array( '-', '_' ), ' ', $args[ 'type' ] ); |
|
| 242 | 242 | $classname = 'Kirki_Field_' . str_replace( ' ', '_', ucwords( $str ) ); |
| 243 | 243 | if ( class_exists( $classname ) ) { |
| 244 | 244 | new $classname( $config_id, $args ); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | public static function remove_control( $id ) { |
| 268 | 268 | if ( ! in_array( $id, self::$controls_to_remove, true ) ) { |
| 269 | - self::$controls_to_remove[] = $id; |
|
| 269 | + self::$controls_to_remove[ ] = $id; |
|
| 270 | 270 | } |
| 271 | 271 | } |
| 272 | 272 | |
@@ -49,13 +49,13 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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'] = ''; |
|
| 179 | + $value[ 'text-align' ] = ''; |
|
| 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'] = ''; |
|
| 184 | + $value[ 'text-transform' ] = ''; |
|
| 185 | 185 | } |
| 186 | 186 | break; |
| 187 | 187 | case 'text-decoration': |
| 188 | - if ( ! in_array( $val, array( ''. 'none', 'underline', 'overline', 'line-through', 'initial', 'inherit' ), true ) ) { |
|
| 189 | - $value['text-transform'] = ''; |
|
| 188 | + if ( ! in_array( $val, array( '' . 'none', 'underline', 'overline', 'line-through', 'initial', 'inherit' ), true ) ) { |
|
| 189 | + $value[ 'text-transform' ] = ''; |
|
| 190 | 190 | } |
| 191 | 191 | break; |
| 192 | 192 | case 'color': |
| 193 | - $value['color'] = '' === $value['color'] ? '' : ariColor::newColor( $val )->toCSS( 'hex' ); |
|
| 193 | + $value[ 'color' ] = '' === $value[ 'color' ] ? '' : ariColor::newColor( $val )->toCSS( 'hex' ); |
|
| 194 | 194 | break; |
| 195 | 195 | } // End switch(). |
| 196 | 196 | } // End foreach(). |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $fonts_to_load = $this->googlefonts->fonts; |
| 88 | 88 | |
| 89 | 89 | if ( ! empty( $fonts_to_load ) && 'preconnect' === $relation_type ) { |
| 90 | - $urls[] = array( |
|
| 90 | + $urls[ ] = array( |
|
| 91 | 91 | 'href' => 'https://fonts.gstatic.com', |
| 92 | 92 | 'crossorigin', |
| 93 | 93 | ); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $weights[ $key ] = str_replace( array( 'regular', 'bold', 'italic' ), array( '400', '', 'i' ), $value ); |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | - $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'; |
|
| 123 | + $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'; |
|
| 124 | 124 | } |
| 125 | 125 | if ( ! empty( $this->fonts_to_load ) ) { |
| 126 | 126 | Kirki_Modules_Webfont_Loader::$load = true; |
@@ -39,18 +39,18 @@ |
||
| 39 | 39 | |
| 40 | 40 | foreach ( array_keys( $value ) as $key ) { |
| 41 | 41 | |
| 42 | - $property = ( empty( $output['property'] ) ) ? $key : $output['property'] . '-' . $key; |
|
| 43 | - if ( isset( $output['choice'] ) && $output['property'] ) { |
|
| 44 | - if ( $key === $output['choice'] ) { |
|
| 45 | - $property = $output['property']; |
|
| 42 | + $property = ( empty( $output[ 'property' ] ) ) ? $key : $output[ 'property' ] . '-' . $key; |
|
| 43 | + if ( isset( $output[ 'choice' ] ) && $output[ 'property' ] ) { |
|
| 44 | + if ( $key === $output[ 'choice' ] ) { |
|
| 45 | + $property = $output[ 'property' ]; |
|
| 46 | 46 | } else { |
| 47 | 47 | continue; |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | - if ( false !== strpos( $output['property'], '%%' ) ) { |
|
| 51 | - $property = str_replace( '%%', $key, $output['property'] ); |
|
| 50 | + if ( false !== strpos( $output[ 'property' ], '%%' ) ) { |
|
| 51 | + $property = str_replace( '%%', $key, $output[ 'property' ] ); |
|
| 52 | 52 | } |
| 53 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $this->process_property_value( $property, $value[ $key ] ) . $output['suffix']; |
|
| 53 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $property ] = $output[ 'prefix' ] . $this->process_property_value( $property, $value[ $key ] ) . $output[ 'suffix' ]; |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | // Apply the kirki_config filter. |
| 64 | 64 | $config = apply_filters( 'kirki_config', array() ); |
| 65 | - if ( isset( $config['url_path'] ) ) { |
|
| 66 | - Kirki::$url = $config['url_path']; |
|
| 65 | + if ( isset( $config[ 'url_path' ] ) ) { |
|
| 66 | + Kirki::$url = $config[ 'url_path' ]; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // Make sure the right protocol is used. |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | $this->control_types = $this->default_control_types(); |
| 145 | 145 | if ( ! class_exists( 'WP_Customize_Code_Editor_Control' ) ) { |
| 146 | - unset( $this->control_types['code_editor'] ); |
|
| 146 | + unset( $this->control_types[ 'code_editor' ] ); |
|
| 147 | 147 | } |
| 148 | 148 | foreach ( $this->control_types as $key => $classname ) { |
| 149 | 149 | if ( ! class_exists( $classname ) ) { |
@@ -174,10 +174,10 @@ discard block |
||
| 174 | 174 | if ( ! empty( Kirki::$panels ) ) { |
| 175 | 175 | foreach ( Kirki::$panels as $panel_args ) { |
| 176 | 176 | // Extra checks for nested panels. |
| 177 | - if ( isset( $panel_args['panel'] ) ) { |
|
| 178 | - if ( isset( Kirki::$panels[ $panel_args['panel'] ] ) ) { |
|
| 177 | + if ( isset( $panel_args[ 'panel' ] ) ) { |
|
| 178 | + if ( isset( Kirki::$panels[ $panel_args[ 'panel' ] ] ) ) { |
|
| 179 | 179 | // Set the type to nested. |
| 180 | - $panel_args['type'] = 'kirki-nested'; |
|
| 180 | + $panel_args[ 'type' ] = 'kirki-nested'; |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
@@ -195,14 +195,14 @@ discard block |
||
| 195 | 195 | if ( ! empty( Kirki::$sections ) ) { |
| 196 | 196 | foreach ( Kirki::$sections as $section_args ) { |
| 197 | 197 | // Extra checks for nested sections. |
| 198 | - if ( isset( $section_args['section'] ) ) { |
|
| 199 | - if ( isset( Kirki::$sections[ $section_args['section'] ] ) ) { |
|
| 198 | + if ( isset( $section_args[ 'section' ] ) ) { |
|
| 199 | + if ( isset( Kirki::$sections[ $section_args[ 'section' ] ] ) ) { |
|
| 200 | 200 | // Set the type to nested. |
| 201 | - $section_args['type'] = 'kirki-nested'; |
|
| 201 | + $section_args[ 'type' ] = 'kirki-nested'; |
|
| 202 | 202 | // We need to check if the parent section is nested inside a panel. |
| 203 | - $parent_section = Kirki::$sections[ $section_args['section'] ]; |
|
| 204 | - if ( isset( $parent_section['panel'] ) ) { |
|
| 205 | - $section_args['panel'] = $parent_section['panel']; |
|
| 203 | + $parent_section = Kirki::$sections[ $section_args[ 'section' ] ]; |
|
| 204 | + if ( isset( $parent_section[ 'panel' ] ) ) { |
|
| 205 | + $section_args[ 'panel' ] = $parent_section[ 'panel' ]; |
|
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | } |
@@ -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': |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // No need to proceed this if the current value is the same as in the "exclude" value. |
| 207 | - if ( isset( $output['exclude'] ) && is_array( $output['exclude'] ) ) { |
|
| 208 | - foreach ( $output['exclude'] as $exclude ) { |
|
| 207 | + if ( isset( $output[ 'exclude' ] ) && is_array( $output[ 'exclude' ] ) ) { |
|
| 208 | + foreach ( $output[ 'exclude' ] as $exclude ) { |
|
| 209 | 209 | if ( is_array( $value ) ) { |
| 210 | 210 | if ( is_array( $exclude ) ) { |
| 211 | 211 | $diff1 = array_diff( $value, $exclude ); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | // If 'choice' is defined check for sub-values too. |
| 219 | 219 | // Fixes https://github.com/aristath/kirki/issues/1416. |
| 220 | 220 | // @codingStandardsIgnoreLine WordPress.PHP.StrictComparisons.LooseComparison |
| 221 | - if ( isset( $output['choice'] ) && isset( $value[ $output['choice'] ] ) && $exclude == $value[ $output['choice'] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
| 221 | + if ( isset( $output[ 'choice' ] ) && isset( $value[ $output[ 'choice' ] ] ) && $exclude == $value[ $output[ 'choice' ] ] ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
| 222 | 222 | $skip = true; |
| 223 | 223 | } |
| 224 | 224 | } |
@@ -239,10 +239,10 @@ discard block |
||
| 239 | 239 | // Apply any value patterns defined. |
| 240 | 240 | $value = $this->apply_value_pattern( $output, $value ); |
| 241 | 241 | |
| 242 | - if ( isset( $output['element'] ) && is_array( $output['element'] ) ) { |
|
| 243 | - $output['element'] = array_unique( $output['element'] ); |
|
| 244 | - sort( $output['element'] ); |
|
| 245 | - $output['element'] = implode( ',', $output['element'] ); |
|
| 242 | + if ( isset( $output[ 'element' ] ) && is_array( $output[ 'element' ] ) ) { |
|
| 243 | + $output[ 'element' ] = array_unique( $output[ 'element' ] ); |
|
| 244 | + sort( $output[ 'element' ] ); |
|
| 245 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | $value = $this->process_value( $value, $output ); |
@@ -260,13 +260,13 @@ discard block |
||
| 260 | 260 | * @return null |
| 261 | 261 | */ |
| 262 | 262 | protected function process_output( $output, $value ) { |
| 263 | - if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { |
|
| 263 | + if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) { |
|
| 264 | 264 | return; |
| 265 | 265 | } |
| 266 | - $output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global'; |
|
| 267 | - $output['prefix'] = ( isset( $output['prefix'] ) ) ? $output['prefix'] : ''; |
|
| 268 | - $output['units'] = ( isset( $output['units'] ) ) ? $output['units'] : ''; |
|
| 269 | - $output['suffix'] = ( isset( $output['suffix'] ) ) ? $output['suffix'] : ''; |
|
| 266 | + $output[ 'media_query' ] = ( isset( $output[ 'media_query' ] ) ) ? $output[ 'media_query' ] : 'global'; |
|
| 267 | + $output[ 'prefix' ] = ( isset( $output[ 'prefix' ] ) ) ? $output[ 'prefix' ] : ''; |
|
| 268 | + $output[ 'units' ] = ( isset( $output[ 'units' ] ) ) ? $output[ 'units' ] : ''; |
|
| 269 | + $output[ 'suffix' ] = ( isset( $output[ 'suffix' ] ) ) ? $output[ 'suffix' ] : ''; |
|
| 270 | 270 | |
| 271 | 271 | // Properties that can accept multiple values. |
| 272 | 272 | // Useful for example for gradients where all browsers use the "background-image" property |
@@ -275,15 +275,15 @@ discard block |
||
| 275 | 275 | 'background-image', |
| 276 | 276 | 'background', |
| 277 | 277 | ); |
| 278 | - if ( in_array( $output['property'], $accepts_multiple, true ) ) { |
|
| 279 | - if ( isset( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) && ! is_array( $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] ) ) { |
|
| 280 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = (array) $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ]; |
|
| 278 | + if ( in_array( $output[ 'property' ], $accepts_multiple, true ) ) { |
|
| 279 | + if ( isset( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) && ! is_array( $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] ) ) { |
|
| 280 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = (array) $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ]; |
|
| 281 | 281 | } |
| 282 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ][] = $output['prefix'] . $value . $output['units'] . $output['suffix']; |
|
| 282 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ][ ] = $output[ 'prefix' ] . $value . $output[ 'units' ] . $output[ 'suffix' ]; |
|
| 283 | 283 | return; |
| 284 | 284 | } |
| 285 | 285 | if ( is_string( $value ) || is_numeric( $value ) ) { |
| 286 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value ) . $output['units'] . $output['suffix']; |
|
| 286 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value ) . $output[ 'units' ] . $output[ 'suffix' ]; |
|
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
@@ -322,8 +322,8 @@ discard block |
||
| 322 | 322 | * @return string|array |
| 323 | 323 | */ |
| 324 | 324 | protected function process_value( $value, $output ) { |
| 325 | - if ( isset( $output['property'] ) ) { |
|
| 326 | - return $this->process_property_value( $output['property'], $value ); |
|
| 325 | + if ( isset( $output[ 'property' ] ) ) { |
|
| 326 | + return $this->process_property_value( $output[ 'property' ], $value ); |
|
| 327 | 327 | } |
| 328 | 328 | return $value; |
| 329 | 329 | } |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | |
| 39 | 39 | // We're using a flat select. |
| 40 | 40 | foreach ( $this->choices as $key => $args ) { |
| 41 | - $this->choices[ $key ] = $args['label']; |
|
| 41 | + $this->choices[ $key ] = $args[ 'label' ]; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |