@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | $config = apply_filters( 'kirki_config', array() ); |
| 78 | 78 | |
| 79 | 79 | // If we have set $config['disable_google_fonts'] to true then do not proceed any further. |
| 80 | - if ( isset( $config['disable_google_fonts'] ) && true === $config['disable_google_fonts'] ) { |
|
| 80 | + if ( isset( $config[ 'disable_google_fonts' ] ) && true === $config[ 'disable_google_fonts' ] ) { |
|
| 81 | 81 | return; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -115,57 +115,57 @@ discard block |
||
| 115 | 115 | global $wp_customize; |
| 116 | 116 | |
| 117 | 117 | // Process typography fields. |
| 118 | - if ( isset( $args['type'] ) && 'kirki-typography' === $args['type'] ) { |
|
| 118 | + if ( isset( $args[ 'type' ] ) && 'kirki-typography' === $args[ 'type' ] ) { |
|
| 119 | 119 | |
| 120 | 120 | // Get the value. |
| 121 | 121 | $value = Kirki_Values::get_sanitized_field_value( $args ); |
| 122 | 122 | |
| 123 | - if ( isset( $value['downloadFont'] ) && $value['downloadFont'] ) { |
|
| 124 | - $this->hosted_fonts[] = $value['font-family']; |
|
| 123 | + if ( isset( $value[ 'downloadFont' ] ) && $value[ 'downloadFont' ] ) { |
|
| 124 | + $this->hosted_fonts[ ] = $value[ 'font-family' ]; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // If we don't have a font-family then we can skip this. |
| 128 | - if ( ! $wp_customize && ( ! isset( $value['font-family'] ) || in_array( $value['font-family'], $this->hosted_fonts, true ) ) ) { |
|
| 128 | + if ( ! $wp_customize && ( ! isset( $value[ 'font-family' ] ) || in_array( $value[ 'font-family' ], $this->hosted_fonts, true ) ) ) { |
|
| 129 | 129 | return; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | // If not a google-font, then we can skip this. |
| 133 | - if ( ! isset( $value['font-family'] ) || ! Kirki_Fonts::is_google_font( $value['font-family'] ) ) { |
|
| 133 | + if ( ! isset( $value[ 'font-family' ] ) || ! Kirki_Fonts::is_google_font( $value[ 'font-family' ] ) ) { |
|
| 134 | 134 | return; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // Set a default value for variants. |
| 138 | - if ( ! isset( $value['variant'] ) ) { |
|
| 139 | - $value['variant'] = 'regular'; |
|
| 138 | + if ( ! isset( $value[ 'variant' ] ) ) { |
|
| 139 | + $value[ 'variant' ] = 'regular'; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | // Add the requested google-font. |
| 143 | - if ( ! isset( $this->fonts[ $value['font-family'] ] ) ) { |
|
| 144 | - $this->fonts[ $value['font-family'] ] = array(); |
|
| 143 | + if ( ! isset( $this->fonts[ $value[ 'font-family' ] ] ) ) { |
|
| 144 | + $this->fonts[ $value[ 'font-family' ] ] = array(); |
|
| 145 | 145 | } |
| 146 | - if ( ! in_array( $value['variant'], $this->fonts[ $value['font-family'] ], true ) ) { |
|
| 147 | - $this->fonts[ $value['font-family'] ][] = $value['variant']; |
|
| 146 | + if ( ! in_array( $value[ 'variant' ], $this->fonts[ $value[ 'font-family' ] ], true ) ) { |
|
| 147 | + $this->fonts[ $value[ 'font-family' ] ][ ] = $value[ 'variant' ]; |
|
| 148 | 148 | } |
| 149 | 149 | // Are we force-loading all variants? |
| 150 | 150 | if ( true === self::$force_load_all_variants ) { |
| 151 | 151 | $all_variants = Kirki_Fonts::get_all_variants(); |
| 152 | - $args['choices']['variant'] = array_keys( $all_variants ); |
|
| 152 | + $args[ 'choices' ][ 'variant' ] = array_keys( $all_variants ); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - if ( ! empty( $args['choices']['variant'] ) && is_array( $args['choices']['variant'] ) ) { |
|
| 156 | - foreach ( $args['choices']['variant'] as $extra_variant ) { |
|
| 157 | - $this->fonts[ $value['font-family'] ][] = $extra_variant; |
|
| 155 | + if ( ! empty( $args[ 'choices' ][ 'variant' ] ) && is_array( $args[ 'choices' ][ 'variant' ] ) ) { |
|
| 156 | + foreach ( $args[ 'choices' ][ 'variant' ] as $extra_variant ) { |
|
| 157 | + $this->fonts[ $value[ 'font-family' ] ][ ] = $extra_variant; |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | return; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // Process non-typography fields. |
| 164 | - if ( isset( $args['output'] ) && is_array( $args['output'] ) ) { |
|
| 165 | - foreach ( $args['output'] as $output ) { |
|
| 164 | + if ( isset( $args[ 'output' ] ) && is_array( $args[ 'output' ] ) ) { |
|
| 165 | + foreach ( $args[ 'output' ] as $output ) { |
|
| 166 | 166 | |
| 167 | 167 | // If we don't have a typography-related output argument we can skip this. |
| 168 | - if ( ! isset( $output['property'] ) || ! in_array( $output['property'], array( 'font-family', 'font-weight' ), true ) ) { |
|
| 168 | + if ( ! isset( $output[ 'property' ] ) || ! in_array( $output[ 'property' ], array( 'font-family', 'font-weight' ), true ) ) { |
|
| 169 | 169 | continue; |
| 170 | 170 | } |
| 171 | 171 | |
@@ -173,14 +173,14 @@ discard block |
||
| 173 | 173 | $value = Kirki_Values::get_sanitized_field_value( $args ); |
| 174 | 174 | |
| 175 | 175 | if ( is_string( $value ) ) { |
| 176 | - if ( 'font-family' === $output['property'] ) { |
|
| 176 | + if ( 'font-family' === $output[ 'property' ] ) { |
|
| 177 | 177 | if ( ! array_key_exists( $value, $this->fonts ) ) { |
| 178 | 178 | $this->fonts[ $value ] = array(); |
| 179 | 179 | } |
| 180 | - } elseif ( 'font-weight' === $output['property'] ) { |
|
| 180 | + } elseif ( 'font-weight' === $output[ 'property' ] ) { |
|
| 181 | 181 | foreach ( $this->fonts as $font => $variants ) { |
| 182 | 182 | if ( ! in_array( $value, $variants, true ) ) { |
| 183 | - $this->fonts[ $font ][] = $value; |
|
| 183 | + $this->fonts[ $font ][ ] = $value; |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | } |
@@ -212,8 +212,8 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | // Get all valid font variants for this font. |
| 214 | 214 | $font_variants = array(); |
| 215 | - if ( isset( $this->google_fonts[ $font ]['variants'] ) ) { |
|
| 216 | - $font_variants = $this->google_fonts[ $font ]['variants']; |
|
| 215 | + if ( isset( $this->google_fonts[ $font ][ 'variants' ] ) ) { |
|
| 216 | + $font_variants = $this->google_fonts[ $font ][ 'variants' ]; |
|
| 217 | 217 | } |
| 218 | 218 | foreach ( $variants as $variant ) { |
| 219 | 219 | |
@@ -69,14 +69,14 @@ |
||
| 69 | 69 | |
| 70 | 70 | // Start parsing the fields. |
| 71 | 71 | foreach ( $fields as $field ) { |
| 72 | - if ( isset( $field['partial_refresh'] ) && ! empty( $field['partial_refresh'] ) ) { |
|
| 72 | + if ( isset( $field[ 'partial_refresh' ] ) && ! empty( $field[ 'partial_refresh' ] ) ) { |
|
| 73 | 73 | // Start going through each item in the array of partial refreshes. |
| 74 | - foreach ( $field['partial_refresh'] as $partial_refresh => $partial_refresh_args ) { |
|
| 74 | + foreach ( $field[ 'partial_refresh' ] as $partial_refresh => $partial_refresh_args ) { |
|
| 75 | 75 | // If we have all we need, create the selective refresh call. |
| 76 | - if ( isset( $partial_refresh_args['render_callback'] ) && isset( $partial_refresh_args['selector'] ) ) { |
|
| 76 | + if ( isset( $partial_refresh_args[ 'render_callback' ] ) && isset( $partial_refresh_args[ 'selector' ] ) ) { |
|
| 77 | 77 | $partial_refresh_args = wp_parse_args( |
| 78 | 78 | $partial_refresh_args, array( |
| 79 | - 'settings' => $field['settings'], |
|
| 79 | + 'settings' => $field[ 'settings' ], |
|
| 80 | 80 | ) |
| 81 | 81 | ); |
| 82 | 82 | $wp_customize->selective_refresh->add_partial( $partial_refresh, $partial_refresh_args ); |
@@ -66,10 +66,10 @@ discard block |
||
| 66 | 66 | public function custom_css() { |
| 67 | 67 | |
| 68 | 68 | $config = apply_filters( 'kirki_config', array() ); |
| 69 | - if ( ! isset( $config['color_accent'] ) && ! isset( $config['color_back'] ) ) { |
|
| 69 | + if ( ! isset( $config[ 'color_accent' ] ) && ! isset( $config[ 'color_back' ] ) ) { |
|
| 70 | 70 | return; |
| 71 | 71 | } |
| 72 | - $back = isset( $config['color_back'] ) ? $config['color_back'] : false; |
|
| 72 | + $back = isset( $config[ 'color_back' ] ) ? $config[ 'color_back' ] : false; |
|
| 73 | 73 | |
| 74 | 74 | $text_on_back = ''; |
| 75 | 75 | $border_on_back = ''; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $hover_on_back = ( 90 < $back_obj->lightness ) ? $back_obj->getNew( 'lightness', $back_obj->lightness - 3 )->toCSS( $back_obj->mode ) : $back_obj->getNew( 'lightness', $back_obj->lightness + 3 )->toCSS( $back_obj->mode ); |
| 92 | 92 | $arrows_on_back = ( 50 > $back_obj->lightness ) ? $back_obj->getNew( 'lightness', $back_obj->lightness + 30 )->toCSS( $back_obj->mode ) : $back_obj->getNew( 'lightness', $back_obj->lightness - 30 )->toCSS( $back_obj->mode ); |
| 93 | 93 | } |
| 94 | - $accent = ( isset( $config['color_accent'] ) ) ? $config['color_accent'] : false; |
|
| 94 | + $accent = ( isset( $config[ 'color_accent' ] ) ) ? $config[ 'color_accent' ] : false; |
|
| 95 | 95 | if ( $accent ) { |
| 96 | 96 | $accent_obj = ariColor::newColor( $accent ); |
| 97 | 97 | $text_on_accent = ( 60 > $accent_obj->lightness ) ? $accent_obj->getNew( 'lightness', $accent_obj->lightness + 60 )->toCSS( $accent_obj->mode ) : $accent_obj->getNew( 'lightness', $accent_obj->lightness - 60 )->toCSS( $accent_obj->mode ); |
@@ -403,18 +403,18 @@ discard block |
||
| 403 | 403 | color: #444 !important; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - <?php if ( isset( $config['width'] ) ) : ?> |
|
| 406 | + <?php if ( isset( $config[ 'width' ] ) ) : ?> |
|
| 407 | 407 | .wp-full-overlay-sidebar { |
| 408 | - width: <?php echo esc_attr( $config['width'] ); ?>; |
|
| 408 | + width: <?php echo esc_attr( $config[ 'width' ] ); ?>; |
|
| 409 | 409 | } |
| 410 | 410 | .expanded .wp-full-overlay-footer { |
| 411 | - width: <?php echo esc_attr( $config['width'] ); ?>; |
|
| 411 | + width: <?php echo esc_attr( $config[ 'width' ] ); ?>; |
|
| 412 | 412 | } |
| 413 | 413 | .wp-full-overlay.expanded { |
| 414 | - margin-left: <?php echo esc_attr( $config['width'] ); ?>; |
|
| 414 | + margin-left: <?php echo esc_attr( $config[ 'width' ] ); ?>; |
|
| 415 | 415 | } |
| 416 | 416 | .wp-full-overlay.collapsed .wp-full-overlay-sidebar { |
| 417 | - margin-left: -<?php echo esc_attr( $config['width'] ); ?>; |
|
| 417 | + margin-left: -<?php echo esc_attr( $config[ 'width' ] ); ?>; |
|
| 418 | 418 | } |
| 419 | 419 | <?php endif; ?> |
| 420 | 420 | </style> |
@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | protected function process_output( $output, $value ) { |
| 25 | 25 | |
| 26 | - $output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global'; |
|
| 27 | - $output['element'] = ( isset( $output['element'] ) ) ? $output['element'] : 'body'; |
|
| 28 | - $output['prefix'] = ( isset( $output['prefix'] ) ) ? $output['prefix'] : ''; |
|
| 29 | - $output['suffix'] = ( isset( $output['suffix'] ) ) ? $output['suffix'] : ''; |
|
| 26 | + $output[ 'media_query' ] = ( isset( $output[ 'media_query' ] ) ) ? $output[ 'media_query' ] : 'global'; |
|
| 27 | + $output[ 'element' ] = ( isset( $output[ 'element' ] ) ) ? $output[ 'element' ] : 'body'; |
|
| 28 | + $output[ 'prefix' ] = ( isset( $output[ 'prefix' ] ) ) ? $output[ 'prefix' ] : ''; |
|
| 29 | + $output[ 'suffix' ] = ( isset( $output[ 'suffix' ] ) ) ? $output[ 'suffix' ] : ''; |
|
| 30 | 30 | |
| 31 | 31 | $value = Kirki_Field_Typography::sanitize( $value ); |
| 32 | 32 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | foreach ( $properties as $property ) { |
| 49 | 49 | |
| 50 | 50 | // Early exit if the value is not in the defaults. |
| 51 | - if ( ! isset( $this->field['default'][ $property ] ) ) { |
|
| 51 | + if ( ! isset( $this->field[ 'default' ][ $property ] ) ) { |
|
| 52 | 52 | continue; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -58,39 +58,39 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // Early exit if we use "choice" but not for this property. |
| 61 | - if ( isset( $output['choice'] ) && $output['choice'] !== $property ) { |
|
| 61 | + if ( isset( $output[ 'choice' ] ) && $output[ 'choice' ] !== $property ) { |
|
| 62 | 62 | continue; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // Take care of variants. |
| 66 | - if ( 'variant' === $property && isset( $value['variant'] ) && ! empty( $value['variant'] ) ) { |
|
| 66 | + if ( 'variant' === $property && isset( $value[ 'variant' ] ) && ! empty( $value[ 'variant' ] ) ) { |
|
| 67 | 67 | |
| 68 | 68 | // Get the font_weight. |
| 69 | - $font_weight = str_replace( 'italic', '', $value['variant'] ); |
|
| 69 | + $font_weight = str_replace( 'italic', '', $value[ 'variant' ] ); |
|
| 70 | 70 | $font_weight = ( in_array( $font_weight, array( '', 'regular' ), true ) ) ? '400' : $font_weight; |
| 71 | 71 | |
| 72 | 72 | // Is this italic? |
| 73 | - $is_italic = ( false !== strpos( $value['variant'], 'italic' ) ); |
|
| 74 | - $this->styles[ $output['media_query'] ][ $output['element'] ]['font-weight'] = $font_weight; |
|
| 73 | + $is_italic = ( false !== strpos( $value[ 'variant' ], 'italic' ) ); |
|
| 74 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ 'font-weight' ] = $font_weight; |
|
| 75 | 75 | if ( $is_italic ) { |
| 76 | - $this->styles[ $output['media_query'] ][ $output['element'] ]['font-style'] = 'italic'; |
|
| 76 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ 'font-style' ] = 'italic'; |
|
| 77 | 77 | } |
| 78 | 78 | continue; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $property_value = $this->process_property_value( $property, $value[ $property ] ); |
| 82 | 82 | if ( 'font-family' === $property ) { |
| 83 | - $value['font-backup'] = ( isset( $value['font-backup'] ) ) ? $value['font-backup'] : ''; |
|
| 83 | + $value[ 'font-backup' ] = ( isset( $value[ 'font-backup' ] ) ) ? $value[ 'font-backup' ] : ''; |
|
| 84 | 84 | $property_value = $this->process_property_value( |
| 85 | 85 | $property, array( |
| 86 | - $value['font-family'], |
|
| 87 | - $value['font-backup'], |
|
| 86 | + $value[ 'font-family' ], |
|
| 87 | + $value[ 'font-backup' ], |
|
| 88 | 88 | ) |
| 89 | 89 | ); |
| 90 | 90 | } |
| 91 | - $property = ( isset( $output['choice'] ) && isset( $output['property'] ) ) ? $output['property'] : $property; |
|
| 92 | - $property_value = ( is_array( $property_value ) && isset( $property_value[0] ) ) ? $property_value[0] : $property_value; |
|
| 93 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $property_value . $output['suffix']; |
|
| 91 | + $property = ( isset( $output[ 'choice' ] ) && isset( $output[ 'property' ] ) ) ? $output[ 'property' ] : $property; |
|
| 92 | + $property_value = ( is_array( $property_value ) && isset( $property_value[ 0 ] ) ) ? $property_value[ 0 ] : $property_value; |
|
| 93 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $property ] = $output[ 'prefix' ] . $property_value . $output[ 'suffix' ]; |
|
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | protected function process_output( $output, $value ) { |
| 25 | 25 | |
| 26 | - if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { |
|
| 26 | + if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) { |
|
| 27 | 27 | return; |
| 28 | 28 | } |
| 29 | 29 | $output = wp_parse_args( |
@@ -35,16 +35,16 @@ discard block |
||
| 35 | 35 | ) |
| 36 | 36 | ); |
| 37 | 37 | if ( is_array( $value ) ) { |
| 38 | - if ( isset( $output['choice'] ) && $output['choice'] ) { |
|
| 39 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value[ $output['choice'] ] ) . $output['units'] . $output['suffix']; |
|
| 38 | + if ( isset( $output[ 'choice' ] ) && $output[ 'choice' ] ) { |
|
| 39 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value[ $output[ 'choice' ] ] ) . $output[ 'units' ] . $output[ 'suffix' ]; |
|
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | - if ( isset( $value['url'] ) ) { |
|
| 43 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value['url'] ) . $output['units'] . $output['suffix']; |
|
| 42 | + if ( isset( $value[ 'url' ] ) ) { |
|
| 43 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value[ 'url' ] ) . $output[ 'units' ] . $output[ 'suffix' ]; |
|
| 44 | 44 | return; |
| 45 | 45 | } |
| 46 | 46 | return; |
| 47 | 47 | } |
| 48 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $output['prefix'] . $this->process_property_value( $output['property'], $value ) . $output['units'] . $output['suffix']; |
|
| 48 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $output[ 'property' ] ] = $output[ 'prefix' ] . $this->process_property_value( $output[ 'property' ], $value ) . $output[ 'units' ] . $output[ 'suffix' ]; |
|
| 49 | 49 | } |
| 50 | 50 | } |
@@ -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 | } |
@@ -146,10 +146,10 @@ discard block |
||
| 146 | 146 | public static function css( $field ) { |
| 147 | 147 | |
| 148 | 148 | // Set class vars. |
| 149 | - self::$settings = $field['settings']; |
|
| 150 | - self::$callback = $field['sanitize_callback']; |
|
| 151 | - self::$field_type = $field['type']; |
|
| 152 | - self::$output = $field['output']; |
|
| 149 | + self::$settings = $field[ 'settings' ]; |
|
| 150 | + self::$callback = $field[ 'sanitize_callback' ]; |
|
| 151 | + self::$field_type = $field[ 'type' ]; |
|
| 152 | + self::$output = $field[ 'output' ]; |
|
| 153 | 153 | if ( ! is_array( self::$output ) ) { |
| 154 | 154 | self::$output = array( |
| 155 | 155 | array( |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | // Find the class that will handle the outpout for this field. |
| 166 | 166 | $classname = 'Kirki_Output'; |
| 167 | 167 | $field_output_classes = apply_filters( |
| 168 | - "kirki_{$field['kirki_config']}_output_control_classnames", array( |
|
| 168 | + "kirki_{$field[ 'kirki_config' ]}_output_control_classnames", array( |
|
| 169 | 169 | 'kirki-background' => 'Kirki_Output_Field_Background', |
| 170 | 170 | 'kirki-dimensions' => 'Kirki_Output_Field_Dimensions', |
| 171 | 171 | 'kirki-image' => 'Kirki_Output_Field_Image', |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | if ( array_key_exists( self::$field_type, $field_output_classes ) ) { |
| 177 | 177 | $classname = $field_output_classes[ self::$field_type ]; |
| 178 | 178 | } |
| 179 | - $obj = new $classname( $field['kirki_config'], self::$output, self::$value, $field ); |
|
| 179 | + $obj = new $classname( $field[ 'kirki_config' ], self::$output, self::$value, $field ); |
|
| 180 | 180 | return $obj->get_styles(); |
| 181 | 181 | |
| 182 | 182 | } |
@@ -73,14 +73,14 @@ |
||
| 73 | 73 | 'logoImage' => '', |
| 74 | 74 | 'description' => '', |
| 75 | 75 | ); |
| 76 | - if ( isset( $config['logo_image'] ) && '' !== $config['logo_image'] ) { |
|
| 77 | - $vars['logoImage'] = esc_url_raw( $config['logo_image'] ); |
|
| 76 | + if ( isset( $config[ 'logo_image' ] ) && '' !== $config[ 'logo_image' ] ) { |
|
| 77 | + $vars[ 'logoImage' ] = esc_url_raw( $config[ 'logo_image' ] ); |
|
| 78 | 78 | } |
| 79 | - if ( isset( $config['description'] ) && '' !== $config['description'] ) { |
|
| 80 | - $vars['description'] = esc_textarea( $config['description'] ); |
|
| 79 | + if ( isset( $config[ 'description' ] ) && '' !== $config[ 'description' ] ) { |
|
| 80 | + $vars[ 'description' ] = esc_textarea( $config[ 'description' ] ); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - if ( ! empty( $vars['logoImage'] ) || ! empty( $vars['description'] ) ) { |
|
| 83 | + if ( ! empty( $vars[ 'logoImage' ] ) || ! empty( $vars[ 'description' ] ) ) { |
|
| 84 | 84 | wp_register_script( 'kirki-branding', Kirki::$url . '/modules/customizer-branding/branding.js', array(), KIRKI_VERSION, false ); |
| 85 | 85 | wp_localize_script( 'kirki-branding', 'kirkiBranding', $vars ); |
| 86 | 86 | wp_enqueue_script( 'kirki-branding' ); |
@@ -51,10 +51,10 @@ |
||
| 51 | 51 | ) |
| 52 | 52 | ); |
| 53 | 53 | |
| 54 | - $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) ); |
|
| 55 | - $array['content'] = $this->get_content(); |
|
| 56 | - $array['active'] = $this->active(); |
|
| 57 | - $array['instanceNumber'] = $this->instance_number; |
|
| 54 | + $array[ 'title' ] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) ); |
|
| 55 | + $array[ 'content' ] = $this->get_content(); |
|
| 56 | + $array[ 'active' ] = $this->active(); |
|
| 57 | + $array[ 'instanceNumber' ] = $this->instance_number; |
|
| 58 | 58 | |
| 59 | 59 | return $array; |
| 60 | 60 | } |