@@ -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,37 +58,37 @@ 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( $property, array( |
| 85 | - $value['font-family'], |
|
| 86 | - $value['font-backup'], |
|
| 85 | + $value[ 'font-family' ], |
|
| 86 | + $value[ 'font-backup' ], |
|
| 87 | 87 | ) ); |
| 88 | 88 | } |
| 89 | - $property = ( isset( $output['choice'] ) && isset( $output['property'] ) ) ? $output['property'] : $property; |
|
| 90 | - $property_value = ( is_array( $property_value ) && isset( $property_value[0] ) ) ? $property_value[0] : $property_value; |
|
| 91 | - $this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $property_value . $output['suffix']; |
|
| 89 | + $property = ( isset( $output[ 'choice' ] ) && isset( $output[ 'property' ] ) ) ? $output[ 'property' ] : $property; |
|
| 90 | + $property_value = ( is_array( $property_value ) && isset( $property_value[ 0 ] ) ) ? $property_value[ 0 ] : $property_value; |
|
| 91 | + $this->styles[ $output[ 'media_query' ] ][ $output[ 'element' ] ][ $property ] = $output[ 'prefix' ] . $property_value . $output[ 'suffix' ]; |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -92,7 +92,7 @@ |
||
| 92 | 92 | |
| 93 | 93 | if ( is_array( $value ) ) { |
| 94 | 94 | foreach ( $value as $key => $subvalue ) { |
| 95 | - if ( '' !== $subvalue || isset( $this->choices[''] ) ) { |
|
| 95 | + if ( '' !== $subvalue || isset( $this->choices[ '' ] ) ) { |
|
| 96 | 96 | $key = sanitize_key( $key ); |
| 97 | 97 | $value[ $key ] = esc_attr( $subvalue ); |
| 98 | 98 | } |
@@ -68,10 +68,10 @@ |
||
| 68 | 68 | |
| 69 | 69 | $default_args = array( |
| 70 | 70 | 'controls' => array( |
| 71 | - 'top' => ( isset( $this->default['top'] ) ), |
|
| 72 | - 'bottom' => ( isset( $this->default['top'] ) ), |
|
| 73 | - 'left' => ( isset( $this->default['top'] ) ), |
|
| 74 | - 'right' => ( isset( $this->default['top'] ) ), |
|
| 71 | + 'top' => ( isset( $this->default[ 'top' ] ) ), |
|
| 72 | + 'bottom' => ( isset( $this->default[ 'top' ] ) ), |
|
| 73 | + 'left' => ( isset( $this->default[ 'top' ] ) ), |
|
| 74 | + 'right' => ( isset( $this->default[ 'top' ] ) ), |
|
| 75 | 75 | ), |
| 76 | 76 | 'labels' => array( |
| 77 | 77 | 'top' => esc_attr__( 'Top', 'kirki' ), |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 44 | 44 | } |
| 45 | 45 | $data = get_plugin_data( KIRKI_PLUGIN_FILE ); |
| 46 | - $version = ( isset( $data['Version'] ) ) ? $data['Version'] : false; |
|
| 46 | + $version = ( isset( $data[ 'Version' ] ) ) ? $data[ 'Version' ] : false; |
|
| 47 | 47 | define( 'KIRKI_VERSION', $version ); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -227,28 +227,28 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | public function __construct( $config_id = 'global', $args = array() ) { |
| 229 | 229 | |
| 230 | - if ( isset( $args['setting'] ) && ! empty( $args['setting'] ) && ( ! isset( $args['settings'] ) || empty( $args['settings'] ) ) ) { |
|
| 230 | + if ( isset( $args[ 'setting' ] ) && ! empty( $args[ 'setting' ] ) && ( ! isset( $args[ 'settings' ] ) || empty( $args[ 'settings' ] ) ) ) { |
|
| 231 | 231 | /* translators: %s represents the field ID where the error occurs. */ |
| 232 | - _doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Typo found in field %s - setting instead of settings.', 'kirki' ), esc_attr( $args['settings'] ) ), '3.0.10' ); |
|
| 233 | - $args['settings'] = $args['setting']; |
|
| 234 | - unset( $args['setting'] ); |
|
| 232 | + _doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Typo found in field %s - setting instead of settings.', 'kirki' ), esc_attr( $args[ 'settings' ] ) ), '3.0.10' ); |
|
| 233 | + $args[ 'settings' ] = $args[ 'setting' ]; |
|
| 234 | + unset( $args[ 'setting' ] ); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | // In case the user only provides 1 argument, |
| 238 | 238 | // assume that the provided argument is $args and set $config_id = 'global'. |
| 239 | 239 | if ( is_array( $config_id ) && empty( $args ) ) { |
| 240 | 240 | /* translators: %1$s represents the field ID where the error occurs. %2$s is the URL in the documentation site. */ |
| 241 | - _doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args['settings'] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' ); |
|
| 241 | + _doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args[ 'settings' ] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' ); |
|
| 242 | 242 | $args = $config_id; |
| 243 | 243 | $config_id = 'global'; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - $args['kirki_config'] = $config_id; |
|
| 246 | + $args[ 'kirki_config' ] = $config_id; |
|
| 247 | 247 | |
| 248 | 248 | $this->kirki_config = trim( esc_attr( $config_id ) ); |
| 249 | 249 | if ( '' === $config_id ) { |
| 250 | 250 | /* translators: %1$s represents the field ID where the error occurs. %2$s is the URL in the documentation site. */ |
| 251 | - _doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args['settings'] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' ); |
|
| 251 | + _doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Config not defined for field %1$s - See %2$s for details on how to properly add fields.', 'kirki' ), esc_attr( $args[ 'settings' ] ), 'https://aristath.github.io/kirki/docs/getting-started/fields.html' ), '3.0.10' ); |
|
| 252 | 252 | $this->kirki_config = 'global'; |
| 253 | 253 | } |
| 254 | 254 | |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | $defaults = get_class_vars( __CLASS__ ); |
| 257 | 257 | |
| 258 | 258 | // Get the config arguments, and merge them with the defaults. |
| 259 | - $config_defaults = ( isset( Kirki::$config['global'] ) ) ? Kirki::$config['global'] : array(); |
|
| 259 | + $config_defaults = ( isset( Kirki::$config[ 'global' ] ) ) ? Kirki::$config[ 'global' ] : array(); |
|
| 260 | 260 | if ( 'global' !== $this->kirki_config && isset( Kirki::$config[ $this->kirki_config ] ) ) { |
| 261 | 261 | $config_defaults = Kirki::$config[ $this->kirki_config ]; |
| 262 | 262 | } |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | $this->partial_refresh = array(); |
| 405 | 405 | } |
| 406 | 406 | foreach ( $this->partial_refresh as $id => $args ) { |
| 407 | - if ( ! is_array( $args ) || ! isset( $args['selector'] ) || ! isset( $args['render_callback'] ) || ! is_callable( $args['render_callback'] ) ) { |
|
| 407 | + if ( ! is_array( $args ) || ! isset( $args[ 'selector' ] ) || ! isset( $args[ 'render_callback' ] ) || ! is_callable( $args[ 'render_callback' ] ) ) { |
|
| 408 | 408 | /* translators: %1$s represents the field ID where the error occurs. */ |
| 409 | 409 | _doing_it_wrong( __METHOD__, sprintf( esc_attr__( '"partial_refresh" invalid entry in field %s', 'kirki' ), esc_attr( $this->settings ) ), '3.0.10' ); |
| 410 | 410 | unset( $this->partial_refresh[ $id ] ); |
@@ -442,8 +442,8 @@ discard block |
||
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | $this->settings = $settings; |
| 445 | - if ( isset( $this->settings['kirki_placeholder_setting'] ) ) { |
|
| 446 | - $this->settings = $this->settings['kirki_placeholder_setting']; |
|
| 445 | + if ( isset( $this->settings[ 'kirki_placeholder_setting' ] ) ) { |
|
| 446 | + $this->settings = $this->settings[ 'kirki_placeholder_setting' ]; |
|
| 447 | 447 | } |
| 448 | 448 | } |
| 449 | 449 | |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | protected function set_active_callback() { |
| 458 | 458 | |
| 459 | 459 | if ( is_array( $this->active_callback ) && ! is_callable( $this->active_callback ) ) { |
| 460 | - if ( isset( $this->active_callback[0] ) ) { |
|
| 460 | + if ( isset( $this->active_callback[ 0 ] ) ) { |
|
| 461 | 461 | $this->required = $this->active_callback; |
| 462 | 462 | } |
| 463 | 463 | } |
@@ -543,34 +543,34 @@ discard block |
||
| 543 | 543 | ); |
| 544 | 544 | } |
| 545 | 545 | // Convert to array of arrays if needed. |
| 546 | - if ( isset( $this->output['element'] ) ) { |
|
| 546 | + if ( isset( $this->output[ 'element' ] ) ) { |
|
| 547 | 547 | /* translators: The field ID where the error occurs. */ |
| 548 | 548 | _doing_it_wrong( __METHOD__, sprintf( esc_attr__( '"output" invalid format in field %s. The "output" argument should be defined as an array of arrays.', 'kirki' ), esc_attr( $this->settings ) ), '3.0.10' ); |
| 549 | 549 | $this->output = array( $this->output ); |
| 550 | 550 | } |
| 551 | 551 | foreach ( $this->output as $key => $output ) { |
| 552 | - if ( empty( $output ) || ! isset( $output['element'] ) ) { |
|
| 552 | + if ( empty( $output ) || ! isset( $output[ 'element' ] ) ) { |
|
| 553 | 553 | unset( $this->output[ $key ] ); |
| 554 | 554 | continue; |
| 555 | 555 | } |
| 556 | - if ( ! isset( $output['sanitize_callback'] ) && isset( $output['callback'] ) ) { |
|
| 557 | - $this->output[ $key ]['sanitize_callback'] = $output['callback']; |
|
| 556 | + if ( ! isset( $output[ 'sanitize_callback' ] ) && isset( $output[ 'callback' ] ) ) { |
|
| 557 | + $this->output[ $key ][ 'sanitize_callback' ] = $output[ 'callback' ]; |
|
| 558 | 558 | } |
| 559 | 559 | // Convert element arrays to strings. |
| 560 | - if ( isset( $output['element'] ) && is_array( $output['element'] ) ) { |
|
| 561 | - $this->output[ $key ]['element'] = array_unique( $this->output[ $key ]['element'] ); |
|
| 562 | - sort( $this->output[ $key ]['element'] ); |
|
| 560 | + if ( isset( $output[ 'element' ] ) && is_array( $output[ 'element' ] ) ) { |
|
| 561 | + $this->output[ $key ][ 'element' ] = array_unique( $this->output[ $key ][ 'element' ] ); |
|
| 562 | + sort( $this->output[ $key ][ 'element' ] ); |
|
| 563 | 563 | |
| 564 | 564 | // Trim each element in the array. |
| 565 | - foreach ( $this->output[ $key ]['element'] as $index => $element ) { |
|
| 566 | - $this->output[ $key ]['element'][ $index ] = trim( $element ); |
|
| 565 | + foreach ( $this->output[ $key ][ 'element' ] as $index => $element ) { |
|
| 566 | + $this->output[ $key ][ 'element' ][ $index ] = trim( $element ); |
|
| 567 | 567 | } |
| 568 | - $this->output[ $key ]['element'] = implode( ',', $this->output[ $key ]['element'] ); |
|
| 568 | + $this->output[ $key ][ 'element' ] = implode( ',', $this->output[ $key ][ 'element' ] ); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | // Fix for https://github.com/aristath/kirki/issues/1659#issuecomment-346229751. |
| 572 | - $this->output[ $key ]['element'] = str_replace( array( "\t", "\n", "\r", "\0", "\x0B" ), ' ', $this->output[ $key ]['element'] ); |
|
| 573 | - $this->output[ $key ]['element'] = trim( preg_replace( '/\s+/', ' ', $this->output[ $key ]['element'] ) ); |
|
| 572 | + $this->output[ $key ][ 'element' ] = str_replace( array( "\t", "\n", "\r", "\0", "\x0B" ), ' ', $this->output[ $key ][ 'element' ] ); |
|
| 573 | + $this->output[ $key ][ 'element' ] = trim( preg_replace( '/\s+/', ' ', $this->output[ $key ][ 'element' ] ) ); |
|
| 574 | 574 | } |
| 575 | 575 | } |
| 576 | 576 | |
@@ -603,23 +603,23 @@ discard block |
||
| 603 | 603 | |
| 604 | 604 | // Start going through each item in the $output array. |
| 605 | 605 | foreach ( $this->output as $output ) { |
| 606 | - $output['function'] = ( isset( $output['function'] ) ) ? $output['function'] : 'style'; |
|
| 606 | + $output[ 'function' ] = ( isset( $output[ 'function' ] ) ) ? $output[ 'function' ] : 'style'; |
|
| 607 | 607 | |
| 608 | 608 | // If 'element' or 'property' are not defined, skip this. |
| 609 | - if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { |
|
| 609 | + if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) { |
|
| 610 | 610 | continue; |
| 611 | 611 | } |
| 612 | - if ( is_array( $output['element'] ) ) { |
|
| 613 | - $output['element'] = implode( ',', $output['element'] ); |
|
| 612 | + if ( is_array( $output[ 'element' ] ) ) { |
|
| 613 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | // If there's a sanitize_callback defined skip this, unless we also have a js_callback defined. |
| 617 | - if ( isset( $output['sanitize_callback'] ) && ! empty( $output['sanitize_callback'] ) && ! isset( $output['js_callback'] ) ) { |
|
| 617 | + if ( isset( $output[ 'sanitize_callback' ] ) && ! empty( $output[ 'sanitize_callback' ] ) && ! isset( $output[ 'js_callback' ] ) ) { |
|
| 618 | 618 | continue; |
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | // If we got this far, it's safe to add this. |
| 622 | - $js_vars[] = $output; |
|
| 622 | + $js_vars[ ] = $output; |
|
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | // Did we manage to get all the items from 'output'? |
@@ -644,7 +644,7 @@ discard block |
||
| 644 | 644 | $variable = ( is_string( $this->variables ) && ! empty( $this->variables ) ) ? $this->variables : false; |
| 645 | 645 | $this->variables = array(); |
| 646 | 646 | if ( $variable && empty( $this->variables ) ) { |
| 647 | - $this->variables[0]['name'] = $variable; |
|
| 647 | + $this->variables[ 0 ][ 'name' ] = $variable; |
|
| 648 | 648 | } |
| 649 | 649 | } |
| 650 | 650 | } |
@@ -49,16 +49,16 @@ |
||
| 49 | 49 | // The default class to be used when creating a section. |
| 50 | 50 | $section_classname = 'WP_Customize_Section'; |
| 51 | 51 | |
| 52 | - if ( isset( $args['type'] ) && array_key_exists( $args['type'], $this->section_types ) ) { |
|
| 53 | - $section_classname = $this->section_types[ $args['type'] ]; |
|
| 52 | + if ( isset( $args[ 'type' ] ) && array_key_exists( $args[ 'type' ], $this->section_types ) ) { |
|
| 53 | + $section_classname = $this->section_types[ $args[ 'type' ] ]; |
|
| 54 | 54 | } |
| 55 | - if ( isset( $args['type'] ) && 'kirki-outer' === $args['type'] ) { |
|
| 56 | - $args['type'] = 'outer'; |
|
| 55 | + if ( isset( $args[ 'type' ] ) && 'kirki-outer' === $args[ 'type' ] ) { |
|
| 56 | + $args[ 'type' ] = 'outer'; |
|
| 57 | 57 | $section_classname = 'WP_Customize_Section'; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // Add the section. |
| 61 | - $wp_customize->add_section( new $section_classname( $wp_customize, sanitize_key( $args['id'] ), $args ) ); |
|
| 61 | + $wp_customize->add_section( new $section_classname( $wp_customize, sanitize_key( $args[ 'id' ] ), $args ) ); |
|
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -67,28 +67,28 @@ |
||
| 67 | 67 | |
| 68 | 68 | // Get the classname we'll be using to create our setting(s). |
| 69 | 69 | $classname = false; |
| 70 | - if ( isset( $args['option_type'] ) && array_key_exists( $args['option_type'], $this->setting_types ) ) { |
|
| 71 | - $classname = $this->setting_types[ $args['option_type'] ]; |
|
| 70 | + if ( isset( $args[ 'option_type' ] ) && array_key_exists( $args[ 'option_type' ], $this->setting_types ) ) { |
|
| 71 | + $classname = $this->setting_types[ $args[ 'option_type' ] ]; |
|
| 72 | 72 | } |
| 73 | - if ( ! isset( $args['type'] ) || ! array_key_exists( $args['type'], $this->setting_types ) ) { |
|
| 74 | - $args['type'] = 'default'; |
|
| 73 | + if ( ! isset( $args[ 'type' ] ) || ! array_key_exists( $args[ 'type' ], $this->setting_types ) ) { |
|
| 74 | + $args[ 'type' ] = 'default'; |
|
| 75 | 75 | } |
| 76 | - $classname = ! $classname ? $this->setting_types[ $args['type'] ] : $classname; |
|
| 76 | + $classname = ! $classname ? $this->setting_types[ $args[ 'type' ] ] : $classname; |
|
| 77 | 77 | |
| 78 | 78 | // If settings are defined as an array, then we need to go through them |
| 79 | 79 | // and call add_setting for each one of them separately. |
| 80 | - if ( isset( $args['settings'] ) && is_array( $args['settings'] ) ) { |
|
| 80 | + if ( isset( $args[ 'settings' ] ) && is_array( $args[ 'settings' ] ) ) { |
|
| 81 | 81 | |
| 82 | 82 | // Make sure defaults have been defined. |
| 83 | - if ( ! isset( $args['default'] ) || ! is_array( $args['default'] ) ) { |
|
| 84 | - $args['default'] = array(); |
|
| 83 | + if ( ! isset( $args[ 'default' ] ) || ! is_array( $args[ 'default' ] ) ) { |
|
| 84 | + $args[ 'default' ] = array(); |
|
| 85 | 85 | } |
| 86 | - foreach ( $args['settings'] as $key => $value ) { |
|
| 86 | + foreach ( $args[ 'settings' ] as $key => $value ) { |
|
| 87 | 87 | $default = ( isset( $defaults[ $key ] ) ) ? $defaults[ $key ] : ''; |
| 88 | - $this->add_setting( $classname, $value, $default, $args['option_type'], $args['capability'], $args['transport'], $args['sanitize_callback'] ); |
|
| 88 | + $this->add_setting( $classname, $value, $default, $args[ 'option_type' ], $args[ 'capability' ], $args[ 'transport' ], $args[ 'sanitize_callback' ] ); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | - $this->add_setting( $classname, $args['settings'], $args['default'], $args['option_type'], $args['capability'], $args['transport'], $args['sanitize_callback'] ); |
|
| 91 | + $this->add_setting( $classname, $args[ 'settings' ], $args[ 'default' ], $args[ 'option_type' ], $args[ 'capability' ], $args[ 'transport' ], $args[ 'sanitize_callback' ] ); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -89,23 +89,23 @@ discard block |
||
| 89 | 89 | $name_parts = explode( '_', str_replace( 'Kirki_', '', $class_name ) ); |
| 90 | 90 | |
| 91 | 91 | // Handle modules loading. |
| 92 | - if ( isset( $name_parts[0] ) && 'Modules' === $name_parts[0] ) { |
|
| 92 | + if ( isset( $name_parts[ 0 ] ) && 'Modules' === $name_parts[ 0 ] ) { |
|
| 93 | 93 | $path = dirname( __FILE__ ) . '/modules/'; |
| 94 | 94 | $path .= strtolower( str_replace( '_', '-', str_replace( 'Kirki_Modules_', '', $class_name ) ) ) . '/'; |
| 95 | - $paths[] = $path . $filename; |
|
| 95 | + $paths[ ] = $path . $filename; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if ( isset( $name_parts[0] ) ) { |
|
| 98 | + if ( isset( $name_parts[ 0 ] ) ) { |
|
| 99 | 99 | |
| 100 | 100 | // Handle controls loading. |
| 101 | - if ( 'Control' === $name_parts[0] || 'Settings' === $name_parts[0] ) { |
|
| 101 | + if ( 'Control' === $name_parts[ 0 ] || 'Settings' === $name_parts[ 0 ] ) { |
|
| 102 | 102 | $path = dirname( __FILE__ ) . '/controls/php/'; |
| 103 | - $paths[] = $path . $filename; |
|
| 103 | + $paths[ ] = $path . $filename; |
|
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - $paths[] = dirname( __FILE__ ) . '/core/' . $filename; |
|
| 108 | - $paths[] = dirname( __FILE__ ) . '/lib/' . $filename; |
|
| 107 | + $paths[ ] = dirname( __FILE__ ) . '/core/' . $filename; |
|
| 108 | + $paths[ ] = dirname( __FILE__ ) . '/lib/' . $filename; |
|
| 109 | 109 | |
| 110 | 110 | $substr = str_replace( 'Kirki_', '', $class_name ); |
| 111 | 111 | $exploded = explode( '_', $substr ); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $previous_path = ''; |
| 115 | 115 | for ( $i = 0; $i < $levels; $i++ ) { |
| 116 | - $paths[] = dirname( __FILE__ ) . '/' . $previous_path . strtolower( $exploded[ $i ] ) . '/' . $filename; |
|
| 116 | + $paths[ ] = dirname( __FILE__ ) . '/' . $previous_path . strtolower( $exploded[ $i ] ) . '/' . $filename; |
|
| 117 | 117 | $previous_path .= strtolower( $exploded[ $i ] ) . '/'; |
| 118 | 118 | } |
| 119 | 119 | return $paths; |
@@ -218,7 +218,8 @@ |
||
| 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'] ] ) { |
|
| 222 | +// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
| 222 | 223 | $skip = true; |
| 223 | 224 | } |
| 224 | 225 | } |
@@ -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 | } |