@@ -38,7 +38,7 @@ |
||
| 38 | 38 | |
| 39 | 39 | // We're using a flat select. |
| 40 | 40 | foreach ( $this->choices as $key => $args ) { |
| 41 | - $this->choices[ $key ] = $args['label']; |
|
| 41 | + $this->choices[ $key ] = $args[ 'label' ]; |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | } |
@@ -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_attr__( 'Typo found in field %s - setting instead of settings.', 'kirki' ), esc_attr( $args['settings'] ) ), '3.0.10' ); |
|
| 249 | - $args['settings'] = $args['setting']; |
|
| 250 | - unset( $args['setting'] ); |
|
| 248 | + _doing_it_wrong( __METHOD__, sprintf( esc_attr__( 'Typo found in field %s - setting instead of settings.', 'kirki' ), esc_attr( $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_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' ); |
|
| 257 | + _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' ); |
|
| 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 = trim( esc_attr( $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_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' ); |
|
| 267 | + _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' ); |
|
| 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 | } |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | $this->partial_refresh = array(); |
| 421 | 421 | } |
| 422 | 422 | foreach ( $this->partial_refresh as $id => $args ) { |
| 423 | - if ( ! is_array( $args ) || ! isset( $args['selector'] ) || ! isset( $args['render_callback'] ) || ! is_callable( $args['render_callback'] ) ) { |
|
| 423 | + if ( ! is_array( $args ) || ! isset( $args[ 'selector' ] ) || ! isset( $args[ 'render_callback' ] ) || ! is_callable( $args[ 'render_callback' ] ) ) { |
|
| 424 | 424 | /* translators: %1$s represents the field ID where the error occurs. */ |
| 425 | 425 | _doing_it_wrong( __METHOD__, sprintf( esc_attr__( '"partial_refresh" invalid entry in field %s', 'kirki' ), esc_attr( $this->settings ) ), '3.0.10' ); |
| 426 | 426 | unset( $this->partial_refresh[ $id ] ); |
@@ -458,8 +458,8 @@ discard block |
||
| 458 | 458 | } |
| 459 | 459 | } |
| 460 | 460 | $this->settings = $settings; |
| 461 | - if ( isset( $this->settings['kirki_placeholder_setting'] ) ) { |
|
| 462 | - $this->settings = $this->settings['kirki_placeholder_setting']; |
|
| 461 | + if ( isset( $this->settings[ 'kirki_placeholder_setting' ] ) ) { |
|
| 462 | + $this->settings = $this->settings[ 'kirki_placeholder_setting' ]; |
|
| 463 | 463 | } |
| 464 | 464 | } |
| 465 | 465 | |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | protected function set_active_callback() { |
| 474 | 474 | |
| 475 | 475 | if ( is_array( $this->active_callback ) && ! is_callable( $this->active_callback ) ) { |
| 476 | - if ( isset( $this->active_callback[0] ) ) { |
|
| 476 | + if ( isset( $this->active_callback[ 0 ] ) ) { |
|
| 477 | 477 | $this->required = $this->active_callback; |
| 478 | 478 | } |
| 479 | 479 | } |
@@ -559,34 +559,34 @@ discard block |
||
| 559 | 559 | ); |
| 560 | 560 | } |
| 561 | 561 | // Convert to array of arrays if needed. |
| 562 | - if ( isset( $this->output['element'] ) ) { |
|
| 562 | + if ( isset( $this->output[ 'element' ] ) ) { |
|
| 563 | 563 | /* translators: The field ID where the error occurs. */ |
| 564 | 564 | _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' ); |
| 565 | 565 | $this->output = array( $this->output ); |
| 566 | 566 | } |
| 567 | 567 | foreach ( $this->output as $key => $output ) { |
| 568 | - if ( empty( $output ) || ! isset( $output['element'] ) ) { |
|
| 568 | + if ( empty( $output ) || ! isset( $output[ 'element' ] ) ) { |
|
| 569 | 569 | unset( $this->output[ $key ] ); |
| 570 | 570 | continue; |
| 571 | 571 | } |
| 572 | - if ( ! isset( $output['sanitize_callback'] ) && isset( $output['callback'] ) ) { |
|
| 573 | - $this->output[ $key ]['sanitize_callback'] = $output['callback']; |
|
| 572 | + if ( ! isset( $output[ 'sanitize_callback' ] ) && isset( $output[ 'callback' ] ) ) { |
|
| 573 | + $this->output[ $key ][ 'sanitize_callback' ] = $output[ 'callback' ]; |
|
| 574 | 574 | } |
| 575 | 575 | // Convert element arrays to strings. |
| 576 | - if ( isset( $output['element'] ) && is_array( $output['element'] ) ) { |
|
| 577 | - $this->output[ $key ]['element'] = array_unique( $this->output[ $key ]['element'] ); |
|
| 578 | - sort( $this->output[ $key ]['element'] ); |
|
| 576 | + if ( isset( $output[ 'element' ] ) && is_array( $output[ 'element' ] ) ) { |
|
| 577 | + $this->output[ $key ][ 'element' ] = array_unique( $this->output[ $key ][ 'element' ] ); |
|
| 578 | + sort( $this->output[ $key ][ 'element' ] ); |
|
| 579 | 579 | |
| 580 | 580 | // Trim each element in the array. |
| 581 | - foreach ( $this->output[ $key ]['element'] as $index => $element ) { |
|
| 582 | - $this->output[ $key ]['element'][ $index ] = trim( $element ); |
|
| 581 | + foreach ( $this->output[ $key ][ 'element' ] as $index => $element ) { |
|
| 582 | + $this->output[ $key ][ 'element' ][ $index ] = trim( $element ); |
|
| 583 | 583 | } |
| 584 | - $this->output[ $key ]['element'] = implode( ',', $this->output[ $key ]['element'] ); |
|
| 584 | + $this->output[ $key ][ 'element' ] = implode( ',', $this->output[ $key ][ 'element' ] ); |
|
| 585 | 585 | } |
| 586 | 586 | |
| 587 | 587 | // Fix for https://github.com/aristath/kirki/issues/1659#issuecomment-346229751. |
| 588 | - $this->output[ $key ]['element'] = str_replace( array( "\t", "\n", "\r", "\0", "\x0B" ), ' ', $this->output[ $key ]['element'] ); |
|
| 589 | - $this->output[ $key ]['element'] = trim( preg_replace( '/\s+/', ' ', $this->output[ $key ]['element'] ) ); |
|
| 588 | + $this->output[ $key ][ 'element' ] = str_replace( array( "\t", "\n", "\r", "\0", "\x0B" ), ' ', $this->output[ $key ][ 'element' ] ); |
|
| 589 | + $this->output[ $key ][ 'element' ] = trim( preg_replace( '/\s+/', ' ', $this->output[ $key ][ 'element' ] ) ); |
|
| 590 | 590 | } |
| 591 | 591 | } |
| 592 | 592 | |
@@ -619,23 +619,23 @@ discard block |
||
| 619 | 619 | |
| 620 | 620 | // Start going through each item in the $output array. |
| 621 | 621 | foreach ( $this->output as $output ) { |
| 622 | - $output['function'] = ( isset( $output['function'] ) ) ? $output['function'] : 'style'; |
|
| 622 | + $output[ 'function' ] = ( isset( $output[ 'function' ] ) ) ? $output[ 'function' ] : 'style'; |
|
| 623 | 623 | |
| 624 | 624 | // If 'element' or 'property' are not defined, skip this. |
| 625 | - if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) { |
|
| 625 | + if ( ! isset( $output[ 'element' ] ) || ! isset( $output[ 'property' ] ) ) { |
|
| 626 | 626 | continue; |
| 627 | 627 | } |
| 628 | - if ( is_array( $output['element'] ) ) { |
|
| 629 | - $output['element'] = implode( ',', $output['element'] ); |
|
| 628 | + if ( is_array( $output[ 'element' ] ) ) { |
|
| 629 | + $output[ 'element' ] = implode( ',', $output[ 'element' ] ); |
|
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | // If there's a sanitize_callback defined skip this, unless we also have a js_callback defined. |
| 633 | - if ( isset( $output['sanitize_callback'] ) && ! empty( $output['sanitize_callback'] ) && ! isset( $output['js_callback'] ) ) { |
|
| 633 | + if ( isset( $output[ 'sanitize_callback' ] ) && ! empty( $output[ 'sanitize_callback' ] ) && ! isset( $output[ 'js_callback' ] ) ) { |
|
| 634 | 634 | continue; |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | // If we got this far, it's safe to add this. |
| 638 | - $js_vars[] = $output; |
|
| 638 | + $js_vars[ ] = $output; |
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | // Did we manage to get all the items from 'output'? |
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | $variable = ( is_string( $this->variables ) && ! empty( $this->variables ) ) ? $this->variables : false; |
| 661 | 661 | $this->variables = array(); |
| 662 | 662 | if ( $variable && empty( $this->variables ) ) { |
| 663 | - $this->variables[0]['name'] = $variable; |
|
| 663 | + $this->variables[ 0 ][ 'name' ] = $variable; |
|
| 664 | 664 | } |
| 665 | 665 | } |
| 666 | 666 | } |
@@ -708,12 +708,12 @@ discard block |
||
| 708 | 708 | if ( is_string( $this->css_vars ) ) { |
| 709 | 709 | $this->css_vars = array( $this->css_vars ); |
| 710 | 710 | } |
| 711 | - if ( isset( $this->css_vars[0] ) && is_string( $this->css_vars[0] ) ) { |
|
| 711 | + if ( isset( $this->css_vars[ 0 ] ) && is_string( $this->css_vars[ 0 ] ) ) { |
|
| 712 | 712 | $this->css_vars = array( $this->css_vars ); |
| 713 | 713 | } |
| 714 | 714 | foreach ( $this->css_vars as $key => $val ) { |
| 715 | - if ( ! isset( $val[1] ) ) { |
|
| 716 | - $this->css_vars[ $key ][1] = '$'; |
|
| 715 | + if ( ! isset( $val[ 1 ] ) ) { |
|
| 716 | + $this->css_vars[ $key ][ 1 ] = '$'; |
|
| 717 | 717 | } |
| 718 | 718 | } |
| 719 | 719 | } |
@@ -76,15 +76,15 @@ discard block |
||
| 76 | 76 | echo '<style id="kirki-css-vars">'; |
| 77 | 77 | echo ':root{'; |
| 78 | 78 | foreach ( $fields as $id => $args ) { |
| 79 | - if ( ! isset( $args['css_vars'] ) || empty( $args['css_vars'] ) ) { |
|
| 79 | + if ( ! isset( $args[ 'css_vars' ] ) || empty( $args[ 'css_vars' ] ) ) { |
|
| 80 | 80 | continue; |
| 81 | 81 | } |
| 82 | - $val = Kirki_Values::get_value( $args['kirki_config'], $id ); |
|
| 83 | - foreach ( $args['css_vars'] as $css_var ) { |
|
| 84 | - if ( isset( $css_var[2] ) && is_array( $val ) && isset( $val[ $css_var[2] ] ) ) { |
|
| 85 | - $val = $val[ $css_var[2] ]; |
|
| 82 | + $val = Kirki_Values::get_value( $args[ 'kirki_config' ], $id ); |
|
| 83 | + foreach ( $args[ 'css_vars' ] as $css_var ) { |
|
| 84 | + if ( isset( $css_var[ 2 ] ) && is_array( $val ) && isset( $val[ $css_var[ 2 ] ] ) ) { |
|
| 85 | + $val = $val[ $css_var[ 2 ] ]; |
|
| 86 | 86 | } |
| 87 | - echo esc_attr( $css_var[0] ) . ':' . esc_attr( str_replace( '$', $val, $css_var[1] ) ) . ';'; |
|
| 87 | + echo esc_attr( $css_var[ 0 ] ) . ':' . esc_attr( str_replace( '$', $val, $css_var[ 1 ] ) ) . ';'; |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | echo '}'; |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | $fields = Kirki::$fields; |
| 106 | 106 | $data = array(); |
| 107 | 107 | foreach ( $fields as $field ) { |
| 108 | - if ( isset( $field['transport'] ) && 'postMessage' === $field['transport'] && isset( $field['css_vars'] ) && ! empty( $field['css_vars'] ) ) { |
|
| 109 | - $data[] = $field; |
|
| 108 | + if ( isset( $field[ 'transport' ] ) && 'postMessage' === $field[ 'transport' ] && isset( $field[ 'css_vars' ] ) && ! empty( $field[ 'css_vars' ] ) ) { |
|
| 109 | + $data[ ] = $field; |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | wp_localize_script( 'kirki_auto_css_vars', 'kirkiCssVarFields', $data ); |
@@ -158,41 +158,41 @@ |
||
| 158 | 158 | // Get the basics from the parent class. |
| 159 | 159 | parent::to_json(); |
| 160 | 160 | // Default. |
| 161 | - $this->json['default'] = $this->setting->default; |
|
| 161 | + $this->json[ 'default' ] = $this->setting->default; |
|
| 162 | 162 | if ( isset( $this->default ) ) { |
| 163 | - $this->json['default'] = $this->default; |
|
| 163 | + $this->json[ 'default' ] = $this->default; |
|
| 164 | 164 | } |
| 165 | 165 | // Required. |
| 166 | - $this->json['required'] = $this->required; |
|
| 166 | + $this->json[ 'required' ] = $this->required; |
|
| 167 | 167 | // Output. |
| 168 | - $this->json['output'] = $this->output; |
|
| 168 | + $this->json[ 'output' ] = $this->output; |
|
| 169 | 169 | // Value. |
| 170 | - $this->json['value'] = $this->value(); |
|
| 170 | + $this->json[ 'value' ] = $this->value(); |
|
| 171 | 171 | // Choices. |
| 172 | - $this->json['choices'] = $this->choices; |
|
| 172 | + $this->json[ 'choices' ] = $this->choices; |
|
| 173 | 173 | // The link. |
| 174 | - $this->json['link'] = $this->get_link(); |
|
| 174 | + $this->json[ 'link' ] = $this->get_link(); |
|
| 175 | 175 | // The ID. |
| 176 | - $this->json['id'] = $this->id; |
|
| 176 | + $this->json[ 'id' ] = $this->id; |
|
| 177 | 177 | // Translation strings. |
| 178 | - $this->json['l10n'] = $this->l10n(); |
|
| 178 | + $this->json[ 'l10n' ] = $this->l10n(); |
|
| 179 | 179 | // The ajaxurl in case we need it. |
| 180 | - $this->json['ajaxurl'] = admin_url( 'admin-ajax.php' ); |
|
| 180 | + $this->json[ 'ajaxurl' ] = admin_url( 'admin-ajax.php' ); |
|
| 181 | 181 | // Input attributes. |
| 182 | - $this->json['inputAttrs'] = ''; |
|
| 182 | + $this->json[ 'inputAttrs' ] = ''; |
|
| 183 | 183 | foreach ( $this->input_attrs as $attr => $value ) { |
| 184 | - $this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
| 184 | + $this->json[ 'inputAttrs' ] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
| 185 | 185 | } |
| 186 | 186 | // The kirki-config. |
| 187 | - $this->json['kirkiConfig'] = $this->kirki_config; |
|
| 187 | + $this->json[ 'kirkiConfig' ] = $this->kirki_config; |
|
| 188 | 188 | // The option-type. |
| 189 | - $this->json['kirkiOptionType'] = $this->option_type; |
|
| 189 | + $this->json[ 'kirkiOptionType' ] = $this->option_type; |
|
| 190 | 190 | // The option-name. |
| 191 | - $this->json['kirkiOptionName'] = $this->option_name; |
|
| 191 | + $this->json[ 'kirkiOptionName' ] = $this->option_name; |
|
| 192 | 192 | // The preset. |
| 193 | - $this->json['preset'] = $this->preset; |
|
| 193 | + $this->json[ 'preset' ] = $this->preset; |
|
| 194 | 194 | // The CSS-Variables. |
| 195 | - $this->json['css-var'] = $this->css_vars; |
|
| 195 | + $this->json[ 'css-var' ] = $this->css_vars; |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | // Handle the arguments, merge one by one. |
| 39 | 39 | $args = func_get_args(); |
| 40 | - $array = $args[0]; |
|
| 40 | + $array = $args[ 0 ]; |
|
| 41 | 41 | if ( ! is_array( $array ) ) { |
| 42 | 42 | return $array; |
| 43 | 43 | } |
@@ -93,27 +93,27 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | if ( 'ftpext' === $method ) { |
| 95 | 95 | // If defined, set it to that, Else, set to NULL. |
| 96 | - $credentials['hostname'] = defined( 'FTP_HOST' ) ? preg_replace( '|\w+://|', '', FTP_HOST ) : null; |
|
| 97 | - $credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : null; |
|
| 98 | - $credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : null; |
|
| 96 | + $credentials[ 'hostname' ] = defined( 'FTP_HOST' ) ? preg_replace( '|\w+://|', '', FTP_HOST ) : null; |
|
| 97 | + $credentials[ 'username' ] = defined( 'FTP_USER' ) ? FTP_USER : null; |
|
| 98 | + $credentials[ 'password' ] = defined( 'FTP_PASS' ) ? FTP_PASS : null; |
|
| 99 | 99 | |
| 100 | 100 | // Set FTP port. |
| 101 | - if ( strpos( $credentials['hostname'], ':' ) && null !== $credentials['hostname'] ) { |
|
| 102 | - list( $credentials['hostname'], $credentials['port'] ) = explode( ':', $credentials['hostname'], 2 ); |
|
| 103 | - if ( ! is_numeric( $credentials['port'] ) ) { |
|
| 104 | - unset( $credentials['port'] ); |
|
| 101 | + if ( strpos( $credentials[ 'hostname' ], ':' ) && null !== $credentials[ 'hostname' ] ) { |
|
| 102 | + list( $credentials[ 'hostname' ], $credentials[ 'port' ] ) = explode( ':', $credentials[ 'hostname' ], 2 ); |
|
| 103 | + if ( ! is_numeric( $credentials[ 'port' ] ) ) { |
|
| 104 | + unset( $credentials[ 'port' ] ); |
|
| 105 | 105 | } |
| 106 | 106 | } else { |
| 107 | - unset( $credentials['port'] ); |
|
| 107 | + unset( $credentials[ 'port' ] ); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | // Set connection type. |
| 111 | 111 | if ( ( defined( 'FTP_SSL' ) && FTP_SSL ) && 'ftpext' === $method ) { |
| 112 | - $credentials['connection_type'] = 'ftps'; |
|
| 112 | + $credentials[ 'connection_type' ] = 'ftps'; |
|
| 113 | 113 | } elseif ( ! array_filter( $credentials ) ) { |
| 114 | - $credentials['connection_type'] = null; |
|
| 114 | + $credentials[ 'connection_type' ] = null; |
|
| 115 | 115 | } else { |
| 116 | - $credentials['connection_type'] = 'ftp'; |
|
| 116 | + $credentials[ 'connection_type' ] = 'ftp'; |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | if ( ! empty( $attachment ) ) { |
| 154 | - return $attachment[0]; |
|
| 154 | + return $attachment[ 0 ]; |
|
| 155 | 155 | } |
| 156 | 156 | return 0; |
| 157 | 157 | } |
@@ -168,10 +168,10 @@ discard block |
||
| 168 | 168 | $image = wp_get_attachment_image_src( $image_id, 'full' ); |
| 169 | 169 | |
| 170 | 170 | return array( |
| 171 | - 'url' => $image[0], |
|
| 172 | - 'width' => $image[1], |
|
| 173 | - 'height' => $image[2], |
|
| 174 | - 'thumbnail' => $image[3], |
|
| 171 | + 'url' => $image[ 0 ], |
|
| 172 | + 'width' => $image[ 1 ], |
|
| 173 | + 'height' => $image[ 2 ], |
|
| 174 | + 'thumbnail' => $image[ 3 ], |
|
| 175 | 175 | ); |
| 176 | 176 | |
| 177 | 177 | } |
@@ -192,8 +192,8 @@ discard block |
||
| 192 | 192 | 'suppress_filters' => false, |
| 193 | 193 | ) |
| 194 | 194 | ); |
| 195 | - } elseif ( is_array( $args ) && ! isset( $args['suppress_filters'] ) ) { |
|
| 196 | - $args['suppress_filters'] = false; |
|
| 195 | + } elseif ( is_array( $args ) && ! isset( $args[ 'suppress_filters' ] ) ) { |
|
| 196 | + $args[ 'suppress_filters' ] = false; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // Get the posts. |
@@ -343,41 +343,41 @@ discard block |
||
| 343 | 343 | $key = absint( $context ) / 100; |
| 344 | 344 | if ( 'A100' === $context ) { |
| 345 | 345 | $key = 10; |
| 346 | - unset( $colors['grey'] ); |
|
| 346 | + unset( $colors[ 'grey' ] ); |
|
| 347 | 347 | } elseif ( 'A200' === $context ) { |
| 348 | 348 | $key = 11; |
| 349 | - unset( $colors['grey'] ); |
|
| 349 | + unset( $colors[ 'grey' ] ); |
|
| 350 | 350 | } elseif ( 'A400' === $context ) { |
| 351 | 351 | $key = 12; |
| 352 | - unset( $colors['grey'] ); |
|
| 352 | + unset( $colors[ 'grey' ] ); |
|
| 353 | 353 | } elseif ( 'A700' === $context ) { |
| 354 | 354 | $key = 13; |
| 355 | - unset( $colors['grey'] ); |
|
| 355 | + unset( $colors[ 'grey' ] ); |
|
| 356 | 356 | } |
| 357 | - unset( $colors['primary'] ); |
|
| 357 | + unset( $colors[ 'primary' ] ); |
|
| 358 | 358 | $position_colors = array(); |
| 359 | 359 | foreach ( $colors as $color_family ) { |
| 360 | 360 | if ( isset( $color_family[ $key ] ) ) { |
| 361 | - $position_colors[] = $color_family[ $key ]; |
|
| 361 | + $position_colors[ ] = $color_family[ $key ]; |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | return $position_colors; |
| 365 | 365 | case 'all': |
| 366 | - unset( $colors['primary'] ); |
|
| 366 | + unset( $colors[ 'primary' ] ); |
|
| 367 | 367 | $all_colors = array(); |
| 368 | 368 | foreach ( $colors as $color_family ) { |
| 369 | 369 | foreach ( $color_family as $color ) { |
| 370 | - $all_colors[] = $color; |
|
| 370 | + $all_colors[ ] = $color; |
|
| 371 | 371 | } |
| 372 | 372 | } |
| 373 | 373 | return $all_colors; |
| 374 | 374 | case 'primary': |
| 375 | - return $colors['primary']; |
|
| 375 | + return $colors[ 'primary' ]; |
|
| 376 | 376 | default: |
| 377 | 377 | if ( isset( $colors[ $context ] ) ) { |
| 378 | 378 | return $colors[ $context ]; |
| 379 | 379 | } |
| 380 | - return $colors['primary']; |
|
| 380 | + return $colors[ 'primary' ]; |
|
| 381 | 381 | } // End switch(). |
| 382 | 382 | } |
| 383 | 383 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $key = sanitize_key( $this->family ); |
| 101 | 101 | $this->folder_path = $this->get_root_path() . "/$key"; |
| 102 | 102 | $this->folder_url = $this->get_root_url() . "/$key"; |
| 103 | - $this->files = $this->get_font_family(); |
|
| 103 | + $this->files = $this->get_font_family(); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -193,13 +193,13 @@ discard block |
||
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | // Return regular if the one we want could not be found. |
| 196 | - if ( isset( $local_urls['regular'] ) ) { |
|
| 197 | - return $local_urls['regular']; |
|
| 196 | + if ( isset( $local_urls[ 'regular' ] ) ) { |
|
| 197 | + return $local_urls[ 'regular' ]; |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | // Return the first available if all else failed. |
| 201 | 201 | $vals = array_values( $local_urls ); |
| 202 | - return $vals[0]; |
|
| 202 | + return $vals[ 0 ]; |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | public function get_root_path() { |
| 392 | 392 | // Get the upload directory for this site. |
| 393 | 393 | $upload_dir = wp_upload_dir(); |
| 394 | - $path = untrailingslashit( wp_normalize_path( $upload_dir['basedir'] ) ) . '/webfonts'; |
|
| 394 | + $path = untrailingslashit( wp_normalize_path( $upload_dir[ 'basedir' ] ) ) . '/webfonts'; |
|
| 395 | 395 | |
| 396 | 396 | // If the folder doesn't exist, create it. |
| 397 | 397 | if ( ! file_exists( $path ) ) { |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | $upload_dir = wp_upload_dir(); |
| 417 | 417 | |
| 418 | 418 | // The URL. |
| 419 | - $url = trailingslashit( $upload_dir['baseurl'] ); |
|
| 419 | + $url = trailingslashit( $upload_dir[ 'baseurl' ] ); |
|
| 420 | 420 | // Take care of domain mapping. |
| 421 | 421 | // When using domain mapping we have to make sure that the URL to the file |
| 422 | 422 | // does not include the original domain but instead the mapped domain. |
@@ -80,8 +80,10 @@ |
||
| 80 | 80 | * @param string $family The font-family name. |
| 81 | 81 | * @return Kirki_Fonts_Google_Local |
| 82 | 82 | */ |
| 83 | - public static function do( $family ) { |
|
| 83 | + public static function do { |
|
| 84 | + ( $family ) { |
|
| 84 | 85 | $key = sanitize_key( $family ); |
| 86 | + } |
|
| 85 | 87 | if ( ! isset( self::$instances[ $key ] ) ) { |
| 86 | 88 | self::$instances[ $key ] = new self( $family ); |
| 87 | 89 | } |
@@ -91,7 +91,9 @@ |
||
| 91 | 91 | $fonts = array_keys( $this->googlefonts->fonts ); |
| 92 | 92 | $fonts = array_unique( $fonts ); |
| 93 | 93 | foreach ( $fonts as $family ) { |
| 94 | - $css .= Kirki_Fonts_Google_Local::do( $family )->get_css(); |
|
| 94 | + $css .= Kirki_Fonts_Google_Local::do { |
|
| 95 | + ( $family )->get_css(); |
|
| 96 | + } |
|
| 95 | 97 | } |
| 96 | 98 | if ( $css ) { |
| 97 | 99 | echo '<style id="kirki-local-webfonts-' . esc_attr( sanitize_key( $this->config_id ) ) . '">' . $css . '</style>'; // WPCS: XSS ok. |