@@ -48,7 +48,7 @@ |
||
| 48 | 48 | $sanitized_value = array(); |
| 49 | 49 | foreach ( $value as $sub_value ) { |
| 50 | 50 | if ( isset( $this->choices[ $sub_value ] ) ) { |
| 51 | - $sanitized_value[] = sanitize_text_field( $sub_value ); |
|
| 51 | + $sanitized_value[ ] = sanitize_text_field( $sub_value ); |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | return $sanitized_value; |
@@ -47,13 +47,13 @@ discard block |
||
| 47 | 47 | protected function set_default() { |
| 48 | 48 | |
| 49 | 49 | // Accomodate the use of font-weight and convert to variant. |
| 50 | - if ( isset( $this->default['font-weight'] ) ) { |
|
| 51 | - $this->default['variant'] = ( 'regular' === $this->default['font-weight'] ) ? 400 : (string) intval( $this->default['font-weight'] ); |
|
| 50 | + if ( isset( $this->default[ 'font-weight' ] ) ) { |
|
| 51 | + $this->default[ 'variant' ] = ( 'regular' === $this->default[ 'font-weight' ] ) ? 400 : (string) intval( $this->default[ 'font-weight' ] ); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // Make sure letter-spacing has units. |
| 55 | - if ( isset( $this->default['letter-spacing'] ) && is_numeric( $this->default['letter-spacing'] ) && $this->default['letter-spacing'] ) { |
|
| 56 | - $this->default['letter-spacing'] .= 'px'; |
|
| 55 | + if ( isset( $this->default[ 'letter-spacing' ] ) && is_numeric( $this->default[ 'letter-spacing' ] ) && $this->default[ 'letter-spacing' ] ) { |
|
| 56 | + $this->default[ 'letter-spacing' ] .= 'px'; |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
@@ -102,15 +102,15 @@ discard block |
||
| 102 | 102 | foreach ( $this->output as $output ) { |
| 103 | 103 | |
| 104 | 104 | // If 'element' or 'property' are not defined, skip this. |
| 105 | - if ( ! isset( $output['element'] ) ) { |
|
| 105 | + if ( ! isset( $output[ 'element' ] ) ) { |
|
| 106 | 106 | continue; |
| 107 | 107 | } |
| 108 | - if ( is_array( $output['element'] ) ) { |
|
| 109 | - $output['element'] = implode( ',', $output['element'] ); |
|
| 108 | + if ( is_array( $output[ 'element' ] ) ) { |
|
| 109 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | // If we got this far, it's safe to add this. |
| 113 | - $js_vars[] = $output; |
|
| 113 | + $js_vars[ ] = $output; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | // Did we manage to get all the items from 'output'? |
@@ -139,29 +139,29 @@ discard block |
||
| 139 | 139 | foreach ( $value as $key => $val ) { |
| 140 | 140 | switch ( $key ) { |
| 141 | 141 | case 'font-family': |
| 142 | - $value['font-family'] = sanitize_text_field( $val ); |
|
| 142 | + $value[ 'font-family' ] = sanitize_text_field( $val ); |
|
| 143 | 143 | break; |
| 144 | 144 | case 'font-weight': |
| 145 | - if ( isset( $value['variant'] ) ) { |
|
| 145 | + if ( isset( $value[ 'variant' ] ) ) { |
|
| 146 | 146 | break; |
| 147 | 147 | } |
| 148 | - $value['variant'] = $val; |
|
| 149 | - if ( isset( $value['font-style'] ) && 'italic' === $value['font-style'] ) { |
|
| 150 | - $value['variant'] = ( '400' !== $val || 400 !== $val ) ? $value['variant'] . 'italic' : 'italic'; |
|
| 148 | + $value[ 'variant' ] = $val; |
|
| 149 | + if ( isset( $value[ 'font-style' ] ) && 'italic' === $value[ 'font-style' ] ) { |
|
| 150 | + $value[ 'variant' ] = ( '400' !== $val || 400 !== $val ) ? $value[ 'variant' ] . 'italic' : 'italic'; |
|
| 151 | 151 | } |
| 152 | 152 | break; |
| 153 | 153 | case 'variant': |
| 154 | 154 | |
| 155 | 155 | // Use 'regular' instead of 400 for font-variant. |
| 156 | - $value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; |
|
| 156 | + $value[ 'variant' ] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; |
|
| 157 | 157 | |
| 158 | 158 | // Get font-weight from variant. |
| 159 | - $value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
| 160 | - $value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? 400 : absint( $value['font-weight'] ); |
|
| 159 | + $value[ 'font-weight' ] = filter_var( $value[ 'variant' ], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
| 160 | + $value[ 'font-weight' ] = ( 'regular' === $value[ 'variant' ] || 'italic' === $value[ 'variant' ] ) ? 400 : absint( $value[ 'font-weight' ] ); |
|
| 161 | 161 | |
| 162 | 162 | // Get font-style from variant. |
| 163 | - if ( ! isset( $value['font-style'] ) ) { |
|
| 164 | - $value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic'; |
|
| 163 | + if ( ! isset( $value[ 'font-style' ] ) ) { |
|
| 164 | + $value[ 'font-style' ] = ( false === strpos( $value[ 'variant' ], 'italic' ) ) ? 'normal' : 'italic'; |
|
| 165 | 165 | } |
| 166 | 166 | break; |
| 167 | 167 | case 'font-size': |
@@ -172,21 +172,21 @@ discard block |
||
| 172 | 172 | break; |
| 173 | 173 | case 'text-align': |
| 174 | 174 | if ( ! in_array( $val, array( '', 'inherit', 'left', 'center', 'right', 'justify' ), true ) ) { |
| 175 | - $value['text-align'] = ''; |
|
| 175 | + $value[ 'text-align' ] = ''; |
|
| 176 | 176 | } |
| 177 | 177 | break; |
| 178 | 178 | case 'text-transform': |
| 179 | 179 | if ( ! in_array( $val, array( '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ), true ) ) { |
| 180 | - $value['text-transform'] = ''; |
|
| 180 | + $value[ 'text-transform' ] = ''; |
|
| 181 | 181 | } |
| 182 | 182 | break; |
| 183 | 183 | case 'text-decoration': |
| 184 | 184 | if ( ! in_array( $val, array( '', 'none', 'underline', 'overline', 'line-through', 'initial', 'inherit' ), true ) ) { |
| 185 | - $value['text-transform'] = ''; |
|
| 185 | + $value[ 'text-transform' ] = ''; |
|
| 186 | 186 | } |
| 187 | 187 | break; |
| 188 | 188 | case 'color': |
| 189 | - $value['color'] = '' === $value['color'] ? '' : ariColor::newColor( $val )->toCSS( 'hex' ); |
|
| 189 | + $value[ 'color' ] = '' === $value[ 'color' ] ? '' : ariColor::newColor( $val )->toCSS( 'hex' ); |
|
| 190 | 190 | break; |
| 191 | 191 | } |
| 192 | 192 | } |
@@ -44,11 +44,11 @@ |
||
| 44 | 44 | public function add_panel( $args ) { |
| 45 | 45 | global $wp_customize; |
| 46 | 46 | |
| 47 | - if ( ! isset( $args['type'] ) || ! array_key_exists( $args['type'], $this->panel_types ) ) { |
|
| 48 | - $args['type'] = 'default'; |
|
| 47 | + if ( ! isset( $args[ 'type' ] ) || ! array_key_exists( $args[ 'type' ], $this->panel_types ) ) { |
|
| 48 | + $args[ 'type' ] = 'default'; |
|
| 49 | 49 | } |
| 50 | - $panel_classname = $this->panel_types[ $args['type'] ]; |
|
| 50 | + $panel_classname = $this->panel_types[ $args[ 'type' ] ]; |
|
| 51 | 51 | |
| 52 | - $wp_customize->add_panel( new $panel_classname( $wp_customize, $args['id'], $args ) ); |
|
| 52 | + $wp_customize->add_panel( new $panel_classname( $wp_customize, $args[ 'id' ], $args ) ); |
|
| 53 | 53 | } |
| 54 | 54 | } |
@@ -37,8 +37,8 @@ |
||
| 37 | 37 | $css = ''; |
| 38 | 38 | if ( ! empty( Kirki::$sections ) ) { |
| 39 | 39 | foreach ( Kirki::$sections as $section_args ) { |
| 40 | - if ( isset( $section_args['id'] ) && isset( $section_args['type'] ) && 'outer' === $section_args['type'] || 'kirki-outer' === $section_args['type'] ) { |
|
| 41 | - echo '#customize-theme-controls li#accordion-section-' . esc_html( $section_args['id'] ) . '{display:list-item!important;}'; |
|
| 40 | + if ( isset( $section_args[ 'id' ] ) && isset( $section_args[ 'type' ] ) && 'outer' === $section_args[ 'type' ] || 'kirki-outer' === $section_args[ 'type' ] ) { |
|
| 41 | + echo '#customize-theme-controls li#accordion-section-' . esc_html( $section_args[ 'id' ] ) . '{display:list-item!important;}'; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
@@ -46,15 +46,15 @@ |
||
| 46 | 46 | // The default class to be used when creating a section. |
| 47 | 47 | $section_classname = 'WP_Customize_Section'; |
| 48 | 48 | |
| 49 | - if ( isset( $args['type'] ) && array_key_exists( $args['type'], $this->section_types ) ) { |
|
| 50 | - $section_classname = $this->section_types[ $args['type'] ]; |
|
| 49 | + if ( isset( $args[ 'type' ] ) && array_key_exists( $args[ 'type' ], $this->section_types ) ) { |
|
| 50 | + $section_classname = $this->section_types[ $args[ 'type' ] ]; |
|
| 51 | 51 | } |
| 52 | - if ( isset( $args['type'] ) && 'kirki-outer' === $args['type'] ) { |
|
| 53 | - $args['type'] = 'outer'; |
|
| 52 | + if ( isset( $args[ 'type' ] ) && 'kirki-outer' === $args[ 'type' ] ) { |
|
| 53 | + $args[ 'type' ] = 'outer'; |
|
| 54 | 54 | $section_classname = 'WP_Customize_Section'; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // Add the section. |
| 58 | - $wp_customize->add_section( new $section_classname( $wp_customize, $args['id'], $args ) ); |
|
| 58 | + $wp_customize->add_section( new $section_classname( $wp_customize, $args[ 'id' ], $args ) ); |
|
| 59 | 59 | } |
| 60 | 60 | } |
@@ -38,17 +38,17 @@ discard block |
||
| 38 | 38 | * @return array |
| 39 | 39 | */ |
| 40 | 40 | public function typography_field_tweaks( $value, $field_id ) { |
| 41 | - if ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ]['type'] ) ) { |
|
| 42 | - if ( 'kirki-typography' === Kirki::$fields[ $field_id ]['type'] ) { |
|
| 41 | + if ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ][ 'type' ] ) ) { |
|
| 42 | + if ( 'kirki-typography' === Kirki::$fields[ $field_id ][ 'type' ] ) { |
|
| 43 | 43 | |
| 44 | 44 | // Sanitize the value. |
| 45 | 45 | // This also adds font-weight if it doesn't already exist. |
| 46 | 46 | $value = Kirki_Field_Typography::sanitize( $value ); |
| 47 | 47 | |
| 48 | 48 | // Combine font-family and font-backup. |
| 49 | - if ( isset( $value['font-family'] ) && isset( $value['font-backup'] ) ) { |
|
| 50 | - $value['font-family'] .= ', ' . $value['font-backup']; |
|
| 51 | - unset( $value['font-backup'] ); |
|
| 49 | + if ( isset( $value[ 'font-family' ] ) && isset( $value[ 'font-backup' ] ) ) { |
|
| 50 | + $value[ 'font-family' ] .= ', ' . $value[ 'font-backup' ]; |
|
| 51 | + unset( $value[ 'font-backup' ] ); |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -85,39 +85,39 @@ discard block |
||
| 85 | 85 | $config_id = 'global'; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if ( 'theme_mod' === Kirki::$config[ $config_id ]['option_type'] ) { |
|
| 88 | + if ( 'theme_mod' === Kirki::$config[ $config_id ][ 'option_type' ] ) { |
|
| 89 | 89 | |
| 90 | 90 | // We're using theme_mods so just get the value using get_theme_mod. |
| 91 | 91 | $default_value = null; |
| 92 | - if ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ]['default'] ) ) { |
|
| 93 | - $default_value = Kirki::$fields[ $field_id ]['default']; |
|
| 92 | + if ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ][ 'default' ] ) ) { |
|
| 93 | + $default_value = Kirki::$fields[ $field_id ][ 'default' ]; |
|
| 94 | 94 | } |
| 95 | 95 | $value = get_theme_mod( $field_id, $default_value ); |
| 96 | 96 | return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if ( 'option' === Kirki::$config[ $config_id ]['option_type'] ) { |
|
| 99 | + if ( 'option' === Kirki::$config[ $config_id ][ 'option_type' ] ) { |
|
| 100 | 100 | |
| 101 | 101 | // We're using options. |
| 102 | - if ( '' !== Kirki::$config[ $config_id ]['option_name'] ) { |
|
| 102 | + if ( '' !== Kirki::$config[ $config_id ][ 'option_name' ] ) { |
|
| 103 | 103 | |
| 104 | 104 | // Options are serialized as a single option in the db. |
| 105 | 105 | // We'll have to get the option and then get the item from the array. |
| 106 | - $options = get_option( Kirki::$config[ $config_id ]['option_name'] ); |
|
| 106 | + $options = get_option( Kirki::$config[ $config_id ][ 'option_name' ] ); |
|
| 107 | 107 | |
| 108 | - if ( ! isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']' ] ) ) { |
|
| 109 | - $field_id = Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']'; |
|
| 108 | + if ( ! isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ Kirki::$config[ $config_id ][ 'option_name' ] . '[' . $field_id . ']' ] ) ) { |
|
| 109 | + $field_id = Kirki::$config[ $config_id ][ 'option_name' ] . '[' . $field_id . ']'; |
|
| 110 | 110 | } |
| 111 | - $setting_modified = str_replace( ']', '', str_replace( Kirki::$config[ $config_id ]['option_name'] . '[', '', $field_id ) ); |
|
| 111 | + $setting_modified = str_replace( ']', '', str_replace( Kirki::$config[ $config_id ][ 'option_name' ] . '[', '', $field_id ) ); |
|
| 112 | 112 | |
| 113 | - $default_value = ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ]['default'] ) ) ? Kirki::$fields[ $field_id ]['default'] : ''; |
|
| 113 | + $default_value = ( isset( Kirki::$fields[ $field_id ] ) && isset( Kirki::$fields[ $field_id ][ 'default' ] ) ) ? Kirki::$fields[ $field_id ][ 'default' ] : ''; |
|
| 114 | 114 | $value = ( isset( $options[ $setting_modified ] ) ) ? $options[ $setting_modified ] : $default_value; |
| 115 | 115 | $value = maybe_unserialize( $value ); |
| 116 | 116 | return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Each option separately saved in the db. |
| 120 | - $value = get_option( $field_id, Kirki::$fields[ $field_id ]['default'] ); |
|
| 120 | + $value = get_option( $field_id, Kirki::$fields[ $field_id ][ 'default' ] ); |
|
| 121 | 121 | return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
| 122 | 122 | |
| 123 | 123 | } |
@@ -133,18 +133,18 @@ discard block |
||
| 133 | 133 | * @return string|array |
| 134 | 134 | */ |
| 135 | 135 | public static function get_sanitized_field_value( $field ) { |
| 136 | - $value = $field['default']; |
|
| 137 | - if ( isset( $field['option_type'] ) && 'theme_mod' === $field['option_type'] ) { |
|
| 138 | - $value = get_theme_mod( $field['settings'], $field['default'] ); |
|
| 139 | - } elseif ( isset( $field['option_type'] ) && 'option' === $field['option_type'] ) { |
|
| 140 | - if ( isset( $field['option_name'] ) && '' !== $field['option_name'] ) { |
|
| 141 | - $all_values = get_option( $field['option_name'], array() ); |
|
| 142 | - $sub_setting_id = str_replace( array( ']', $field['option_name'] . '[' ), '', $field['settings'] ); |
|
| 136 | + $value = $field[ 'default' ]; |
|
| 137 | + if ( isset( $field[ 'option_type' ] ) && 'theme_mod' === $field[ 'option_type' ] ) { |
|
| 138 | + $value = get_theme_mod( $field[ 'settings' ], $field[ 'default' ] ); |
|
| 139 | + } elseif ( isset( $field[ 'option_type' ] ) && 'option' === $field[ 'option_type' ] ) { |
|
| 140 | + if ( isset( $field[ 'option_name' ] ) && '' !== $field[ 'option_name' ] ) { |
|
| 141 | + $all_values = get_option( $field[ 'option_name' ], array() ); |
|
| 142 | + $sub_setting_id = str_replace( array( ']', $field[ 'option_name' ] . '[' ), '', $field[ 'settings' ] ); |
|
| 143 | 143 | if ( isset( $all_values[ $sub_setting_id ] ) ) { |
| 144 | 144 | $value = $all_values[ $sub_setting_id ]; |
| 145 | 145 | } |
| 146 | 146 | } else { |
| 147 | - $value = get_option( $field['settings'], $field['default'] ); |
|
| 147 | + $value = get_option( $field[ 'settings' ], $field[ 'default' ] ); |
|
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | return $value; |
@@ -243,28 +243,28 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | public function __construct( $config_id = 'global', $args = array() ) { |
| 245 | 245 | |
| 246 | - if ( isset( $args['setting'] ) && ! empty( $args['setting'] ) && ( ! isset( $args['settings'] ) || empty( $args['settings'] ) ) ) { |
|
| 246 | + if ( isset( $args[ 'setting' ] ) && ! empty( $args[ 'setting' ] ) && ( ! isset( $args[ 'settings' ] ) || empty( $args[ 'settings' ] ) ) ) { |
|
| 247 | 247 | /* translators: %s represents the field ID where the error occurs. */ |
| 248 | - _doing_it_wrong( __METHOD__, sprintf( esc_html__( 'Typo found in field %s - setting instead of settings.', 'kirki' ), esc_html( $args['settings'] ) ), '3.0.10' ); |
|
| 249 | - $args['settings'] = $args['setting']; |
|
| 250 | - unset( $args['setting'] ); |
|
| 248 | + _doing_it_wrong( __METHOD__, sprintf( esc_html__( 'Typo found in field %s - setting instead of settings.', 'kirki' ), esc_html( $args[ 'settings' ] ) ), '3.0.10' ); |
|
| 249 | + $args[ 'settings' ] = $args[ 'setting' ]; |
|
| 250 | + unset( $args[ 'setting' ] ); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | // In case the user only provides 1 argument, |
| 254 | 254 | // assume that the provided argument is $args and set $config_id = 'global'. |
| 255 | 255 | if ( is_array( $config_id ) && empty( $args ) ) { |
| 256 | 256 | /* translators: %1$s represents the field ID where the error occurs. %2$s is the URL in the documentation site. */ |
| 257 | - _doing_it_wrong( __METHOD__, sprintf( esc_html__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_html( $args['settings'] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' ); |
|
| 257 | + _doing_it_wrong( __METHOD__, sprintf( esc_html__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_html( $args[ 'settings' ] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' ); |
|
| 258 | 258 | $args = $config_id; |
| 259 | 259 | $config_id = 'global'; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - $args['kirki_config'] = $config_id; |
|
| 262 | + $args[ 'kirki_config' ] = $config_id; |
|
| 263 | 263 | |
| 264 | 264 | $this->kirki_config = $config_id; |
| 265 | 265 | if ( '' === $config_id ) { |
| 266 | 266 | /* translators: %1$s represents the field ID where the error occurs. %2$s is the URL in the documentation site. */ |
| 267 | - _doing_it_wrong( __METHOD__, sprintf( esc_html__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_html( $args['settings'] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' ); |
|
| 267 | + _doing_it_wrong( __METHOD__, sprintf( esc_html__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_html( $args[ 'settings' ] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' ); |
|
| 268 | 268 | $this->kirki_config = 'global'; |
| 269 | 269 | } |
| 270 | 270 | |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | $defaults = get_class_vars( __CLASS__ ); |
| 273 | 273 | |
| 274 | 274 | // Get the config arguments, and merge them with the defaults. |
| 275 | - $config_defaults = ( isset( Kirki::$config['global'] ) ) ? Kirki::$config['global'] : array(); |
|
| 275 | + $config_defaults = ( isset( Kirki::$config[ 'global' ] ) ) ? Kirki::$config[ 'global' ] : array(); |
|
| 276 | 276 | if ( 'global' !== $this->kirki_config && isset( Kirki::$config[ $this->kirki_config ] ) ) { |
| 277 | 277 | $config_defaults = Kirki::$config[ $this->kirki_config ]; |
| 278 | 278 | } |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | $this->partial_refresh = array(); |
| 372 | 372 | } |
| 373 | 373 | foreach ( $this->partial_refresh as $id => $args ) { |
| 374 | - if ( ! is_array( $args ) || ! isset( $args['selector'] ) || ! isset( $args['render_callback'] ) || ! is_callable( $args['render_callback'] ) ) { |
|
| 374 | + if ( ! is_array( $args ) || ! isset( $args[ 'selector' ] ) || ! isset( $args[ 'render_callback' ] ) || ! is_callable( $args[ 'render_callback' ] ) ) { |
|
| 375 | 375 | /* translators: %1$s represents the field ID where the error occurs. */ |
| 376 | 376 | _doing_it_wrong( __METHOD__, sprintf( esc_html__( '"partial_refresh" invalid entry in field %s', 'kirki' ), esc_html( $this->settings ) ), '3.0.10' ); |
| 377 | 377 | unset( $this->partial_refresh[ $id ] ); |
@@ -410,8 +410,8 @@ discard block |
||
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | 412 | $this->settings = $settings; |
| 413 | - if ( isset( $this->settings['kirki_placeholder_setting'] ) ) { |
|
| 414 | - $this->settings = $this->settings['kirki_placeholder_setting']; |
|
| 413 | + if ( isset( $this->settings[ 'kirki_placeholder_setting' ] ) ) { |
|
| 414 | + $this->settings = $this->settings[ 'kirki_placeholder_setting' ]; |
|
| 415 | 415 | } |
| 416 | 416 | } |
| 417 | 417 | |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | unset( $this->active_callback[ $key ] ); |
| 434 | 434 | } |
| 435 | 435 | } |
| 436 | - if ( isset( $this->active_callback[0] ) ) { |
|
| 436 | + if ( isset( $this->active_callback[ 0 ] ) ) { |
|
| 437 | 437 | $this->required = $this->active_callback; |
| 438 | 438 | } |
| 439 | 439 | } |
@@ -506,36 +506,36 @@ discard block |
||
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | // Convert to array of arrays if needed. |
| 509 | - if ( isset( $this->output['element'] ) ) { |
|
| 509 | + if ( isset( $this->output[ 'element' ] ) ) { |
|
| 510 | 510 | /* translators: The field ID where the error occurs. */ |
| 511 | 511 | _doing_it_wrong( __METHOD__, sprintf( esc_html__( '"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki' ), esc_html( $this->settings ) ), '3.0.10' ); |
| 512 | 512 | $this->output = array( $this->output ); |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | foreach ( $this->output as $key => $output ) { |
| 516 | - if ( empty( $output ) || ! isset( $output['element'] ) ) { |
|
| 516 | + if ( empty( $output ) || ! isset( $output[ 'element' ] ) ) { |
|
| 517 | 517 | unset( $this->output[ $key ] ); |
| 518 | 518 | continue; |
| 519 | 519 | } |
| 520 | - if ( ! isset( $output['sanitize_callback'] ) && isset( $output['callback'] ) ) { |
|
| 521 | - $this->output[ $key ]['sanitize_callback'] = $output['callback']; |
|
| 520 | + if ( ! isset( $output[ 'sanitize_callback' ] ) && isset( $output[ 'callback' ] ) ) { |
|
| 521 | + $this->output[ $key ][ 'sanitize_callback' ] = $output[ 'callback' ]; |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | // Convert element arrays to strings. |
| 525 | - if ( isset( $output['element'] ) && is_array( $output['element'] ) ) { |
|
| 526 | - $this->output[ $key ]['element'] = array_unique( $this->output[ $key ]['element'] ); |
|
| 527 | - sort( $this->output[ $key ]['element'] ); |
|
| 525 | + if ( isset( $output[ 'element' ] ) && is_array( $output[ 'element' ] ) ) { |
|
| 526 | + $this->output[ $key ][ 'element' ] = array_unique( $this->output[ $key ][ 'element' ] ); |
|
| 527 | + sort( $this->output[ $key ][ 'element' ] ); |
|
| 528 | 528 | |
| 529 | 529 | // Trim each element in the array. |
| 530 | - foreach ( $this->output[ $key ]['element'] as $index => $element ) { |
|
| 531 | - $this->output[ $key ]['element'][ $index ] = trim( $element ); |
|
| 530 | + foreach ( $this->output[ $key ][ 'element' ] as $index => $element ) { |
|
| 531 | + $this->output[ $key ][ 'element' ][ $index ] = trim( $element ); |
|
| 532 | 532 | } |
| 533 | - $this->output[ $key ]['element'] = implode( ',', $this->output[ $key ]['element'] ); |
|
| 533 | + $this->output[ $key ][ 'element' ] = implode( ',', $this->output[ $key ][ 'element' ] ); |
|
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | // Fix for https://github.com/aristath/kirki/issues/1659#issuecomment-346229751. |
| 537 | - $this->output[ $key ]['element'] = str_replace( array( "\t", "\n", "\r", "\0", "\x0B" ), ' ', $this->output[ $key ]['element'] ); |
|
| 538 | - $this->output[ $key ]['element'] = trim( preg_replace( '/\s+/', ' ', $this->output[ $key ]['element'] ) ); |
|
| 537 | + $this->output[ $key ][ 'element' ] = str_replace( array( "\t", "\n", "\r", "\0", "\x0B" ), ' ', $this->output[ $key ][ 'element' ] ); |
|
| 538 | + $this->output[ $key ][ 'element' ] = trim( preg_replace( '/\s+/', ' ', $this->output[ $key ][ 'element' ] ) ); |
|
| 539 | 539 | } |
| 540 | 540 | } |
| 541 | 541 | |
@@ -567,23 +567,23 @@ discard block |
||
| 567 | 567 | |
| 568 | 568 | // Start going through each item in the $output array. |
| 569 | 569 | foreach ( $this->output as $output ) { |
| 570 | - $output['function'] = ( isset( $output['function'] ) ) ? $output['function'] : 'style'; |
|
| 570 | + $output[ 'function' ] = ( isset( $output[ 'function' ] ) ) ? $output[ 'function' ] : 'style'; |
|
| 571 | 571 | |
| 572 | 572 | // If 'element' or 'property' are not defined, skip this. |
| 573 | - if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { |
|
| 573 | + if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) { |
|
| 574 | 574 | continue; |
| 575 | 575 | } |
| 576 | - if ( is_array( $output['element'] ) ) { |
|
| 577 | - $output['element'] = implode( ',', $output['element'] ); |
|
| 576 | + if ( is_array( $output[ 'element' ] ) ) { |
|
| 577 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | // If there's a sanitize_callback defined skip this, unless we also have a js_callback defined. |
| 581 | - if ( isset( $output['sanitize_callback'] ) && ! empty( $output['sanitize_callback'] ) && ! isset( $output['js_callback'] ) ) { |
|
| 581 | + if ( isset( $output[ 'sanitize_callback' ] ) && ! empty( $output[ 'sanitize_callback' ] ) && ! isset( $output[ 'js_callback' ] ) ) { |
|
| 582 | 582 | continue; |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | // If we got this far, it's safe to add this. |
| 586 | - $js_vars[] = $output; |
|
| 586 | + $js_vars[ ] = $output; |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | // Did we manage to get all the items from 'output'? |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | $variable = ( is_string( $this->variables ) && ! empty( $this->variables ) ) ? $this->variables : false; |
| 607 | 607 | $this->variables = array(); |
| 608 | 608 | if ( $variable && empty( $this->variables ) ) { |
| 609 | - $this->variables[0]['name'] = $variable; |
|
| 609 | + $this->variables[ 0 ][ 'name' ] = $variable; |
|
| 610 | 610 | } |
| 611 | 611 | } |
| 612 | 612 | } |
@@ -651,12 +651,12 @@ discard block |
||
| 651 | 651 | if ( is_string( $this->css_vars ) ) { |
| 652 | 652 | $this->css_vars = array( $this->css_vars ); |
| 653 | 653 | } |
| 654 | - if ( isset( $this->css_vars[0] ) && is_string( $this->css_vars[0] ) ) { |
|
| 654 | + if ( isset( $this->css_vars[ 0 ] ) && is_string( $this->css_vars[ 0 ] ) ) { |
|
| 655 | 655 | $this->css_vars = array( $this->css_vars ); |
| 656 | 656 | } |
| 657 | 657 | foreach ( $this->css_vars as $key => $val ) { |
| 658 | - if ( ! isset( $val[1] ) ) { |
|
| 659 | - $this->css_vars[ $key ][1] = '$'; |
|
| 658 | + if ( ! isset( $val[ 1 ] ) ) { |
|
| 659 | + $this->css_vars[ $key ][ 1 ] = '$'; |
|
| 660 | 660 | } |
| 661 | 661 | } |
| 662 | 662 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | public static function add_config( $config_id, $args = array() ) { |
| 143 | 143 | $config = Kirki_Config::get_instance( $config_id, $args ); |
| 144 | 144 | $config_args = $config->get_config(); |
| 145 | - self::$config[ $config_args['id'] ] = $config_args; |
|
| 145 | + self::$config[ $config_args[ 'id' ] ] = $config_args; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -154,18 +154,18 @@ discard block |
||
| 154 | 154 | * @param array $args The panel arguments. |
| 155 | 155 | */ |
| 156 | 156 | public static function add_panel( $id = '', $args = array() ) { |
| 157 | - $args['id'] = $id; |
|
| 158 | - if ( ! isset( $args['description'] ) ) { |
|
| 159 | - $args['description'] = ''; |
|
| 157 | + $args[ 'id' ] = $id; |
|
| 158 | + if ( ! isset( $args[ 'description' ] ) ) { |
|
| 159 | + $args[ 'description' ] = ''; |
|
| 160 | 160 | } |
| 161 | - if ( ! isset( $args['priority'] ) ) { |
|
| 162 | - $args['priority'] = 10; |
|
| 161 | + if ( ! isset( $args[ 'priority' ] ) ) { |
|
| 162 | + $args[ 'priority' ] = 10; |
|
| 163 | 163 | } |
| 164 | - if ( ! isset( $args['type'] ) ) { |
|
| 165 | - $args['type'] = 'default'; |
|
| 164 | + if ( ! isset( $args[ 'type' ] ) ) { |
|
| 165 | + $args[ 'type' ] = 'default'; |
|
| 166 | 166 | } |
| 167 | - if ( false === strpos( $args['type'], 'kirki-' ) ) { |
|
| 168 | - $args['type'] = 'kirki-' . $args['type']; |
|
| 167 | + if ( false === strpos( $args[ 'type' ], 'kirki-' ) ) { |
|
| 168 | + $args[ 'type' ] = 'kirki-' . $args[ 'type' ]; |
|
| 169 | 169 | } |
| 170 | 170 | self::$panels[ $id ] = $args; |
| 171 | 171 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public static function remove_panel( $id = '' ) { |
| 182 | 182 | if ( ! in_array( $id, self::$panels_to_remove, true ) ) { |
| 183 | - self::$panels_to_remove[] = $id; |
|
| 183 | + self::$panels_to_remove[ ] = $id; |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | |
@@ -193,18 +193,18 @@ discard block |
||
| 193 | 193 | * @param array $args The section arguments. |
| 194 | 194 | */ |
| 195 | 195 | public static function add_section( $id, $args ) { |
| 196 | - $args['id'] = $id; |
|
| 197 | - if ( ! isset( $args['description'] ) ) { |
|
| 198 | - $args['description'] = ''; |
|
| 196 | + $args[ 'id' ] = $id; |
|
| 197 | + if ( ! isset( $args[ 'description' ] ) ) { |
|
| 198 | + $args[ 'description' ] = ''; |
|
| 199 | 199 | } |
| 200 | - if ( ! isset( $args['priority'] ) ) { |
|
| 201 | - $args['priority'] = 10; |
|
| 200 | + if ( ! isset( $args[ 'priority' ] ) ) { |
|
| 201 | + $args[ 'priority' ] = 10; |
|
| 202 | 202 | } |
| 203 | - if ( ! isset( $args['type'] ) ) { |
|
| 204 | - $args['type'] = 'default'; |
|
| 203 | + if ( ! isset( $args[ 'type' ] ) ) { |
|
| 204 | + $args[ 'type' ] = 'default'; |
|
| 205 | 205 | } |
| 206 | - if ( false === strpos( $args['type'], 'kirki-' ) ) { |
|
| 207 | - $args['type'] = 'kirki-' . $args['type']; |
|
| 206 | + if ( false === strpos( $args[ 'type' ], 'kirki-' ) ) { |
|
| 207 | + $args[ 'type' ] = 'kirki-' . $args[ 'type' ]; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | self::$sections[ $id ] = $args; |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | public static function remove_section( $id = '' ) { |
| 222 | 222 | if ( ! in_array( $id, self::$sections_to_remove, true ) ) { |
| 223 | - self::$sections_to_remove[] = $id; |
|
| 223 | + self::$sections_to_remove[ ] = $id; |
|
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | |
@@ -238,16 +238,16 @@ discard block |
||
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | // Early exit if 'type' is not defined. |
| 241 | - if ( ! isset( $args['type'] ) ) { |
|
| 241 | + if ( ! isset( $args[ 'type' ] ) ) { |
|
| 242 | 242 | return; |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | // If the field is font-awesome, enqueue the icons on the frontend. |
| 246 | - if ( class_exists( 'Kirki_Modules_CSS' ) && ( 'fontawesome' === $args['type'] || 'kirki-fontawesome' === $args['type'] ) ) { |
|
| 246 | + if ( class_exists( 'Kirki_Modules_CSS' ) && ( 'fontawesome' === $args[ 'type' ] || 'kirki-fontawesome' === $args[ 'type' ] ) ) { |
|
| 247 | 247 | Kirki_Modules_CSS::add_fontawesome_script(); |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - $str = str_replace( array( '-', '_' ), ' ', $args['type'] ); |
|
| 250 | + $str = str_replace( array( '-', '_' ), ' ', $args[ 'type' ] ); |
|
| 251 | 251 | $classname = 'Kirki_Field_' . str_replace( ' ', '_', ucwords( $str ) ); |
| 252 | 252 | if ( class_exists( $classname ) ) { |
| 253 | 253 | new $classname( $config_id, $args ); |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | */ |
| 274 | 274 | public static function remove_control( $id ) { |
| 275 | 275 | if ( ! in_array( $id, self::$controls_to_remove, true ) ) { |
| 276 | - self::$controls_to_remove[] = $id; |
|
| 276 | + self::$controls_to_remove[ ] = $id; |
|
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | |
@@ -110,7 +110,7 @@ |
||
| 110 | 110 | public function override_load_textdomain( $override, $domain, $mofile ) { |
| 111 | 111 | global $l10n; |
| 112 | 112 | if ( isset( $l10n[ $this->get_theme_textdomain() ] ) ) { |
| 113 | - $l10n['kirki'] = $l10n[ $this->get_theme_textdomain() ]; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited |
|
| 113 | + $l10n[ 'kirki' ] = $l10n[ $this->get_theme_textdomain() ]; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.OverrideProhibited |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | // Check if the domain is "kirki". |