@@ -76,28 +76,28 @@ discard block |
||
76 | 76 | |
77 | 77 | if ( empty( $this->button_label ) ) { |
78 | 78 | /* translators: %s represents the label of the row. */ |
79 | - $this->button_label = sprintf( esc_attr__( 'Add new %s', 'kirki' ), $this->row_label['value'] ); |
|
79 | + $this->button_label = sprintf( esc_attr__( 'Add new %s', 'kirki' ), $this->row_label[ 'value' ] ); |
|
80 | 80 | } |
81 | 81 | |
82 | - if ( empty( $args['fields'] ) || ! is_array( $args['fields'] ) ) { |
|
83 | - $args['fields'] = array(); |
|
82 | + if ( empty( $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) { |
|
83 | + $args[ 'fields' ] = array(); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | // An array to store keys of fields that need to be filtered. |
87 | 87 | $media_fields_to_filter = array(); |
88 | 88 | |
89 | - foreach ( $args['fields'] as $key => $value ) { |
|
90 | - if ( ! isset( $value['default'] ) ) { |
|
91 | - $args['fields'][ $key ]['default'] = ''; |
|
89 | + foreach ( $args[ 'fields' ] as $key => $value ) { |
|
90 | + if ( ! isset( $value[ 'default' ] ) ) { |
|
91 | + $args[ 'fields' ][ $key ][ 'default' ] = ''; |
|
92 | 92 | } |
93 | - if ( ! isset( $value['label'] ) ) { |
|
94 | - $args['fields'][ $key ]['label'] = ''; |
|
93 | + if ( ! isset( $value[ 'label' ] ) ) { |
|
94 | + $args[ 'fields' ][ $key ][ 'label' ] = ''; |
|
95 | 95 | } |
96 | - $args['fields'][ $key ]['id'] = $key; |
|
96 | + $args[ 'fields' ][ $key ][ 'id' ] = $key; |
|
97 | 97 | |
98 | 98 | // We check if the filed is an uploaded media ( image , file, video, etc.. ). |
99 | - if ( isset( $value['type'] ) ) { |
|
100 | - switch ( $value['type'] ) { |
|
99 | + if ( isset( $value[ 'type' ] ) ) { |
|
100 | + switch ( $value[ 'type' ] ) { |
|
101 | 101 | case 'image': |
102 | 102 | case 'cropped_image': |
103 | 103 | case 'upload': |
@@ -117,14 +117,14 @@ discard block |
||
117 | 117 | ) |
118 | 118 | ); |
119 | 119 | // Hackily add in the data link parameter. |
120 | - $dropdown = str_replace( '<select', '<select data-field="' . esc_attr( $args['fields'][ $key ]['id'] ) . '"' . $this->get_link(), $dropdown ); // phpcs:ignore Generic.Formatting.MultipleStatementAlignment.NotSameWarning |
|
121 | - $args['fields'][ $key ]['dropdown'] = $dropdown; |
|
120 | + $dropdown = str_replace( '<select', '<select data-field="' . esc_attr( $args[ 'fields' ][ $key ][ 'id' ] ) . '"' . $this->get_link(), $dropdown ); // phpcs:ignore Generic.Formatting.MultipleStatementAlignment.NotSameWarning |
|
121 | + $args[ 'fields' ][ $key ][ 'dropdown' ] = $dropdown; |
|
122 | 122 | break; |
123 | 123 | } |
124 | 124 | } |
125 | 125 | } // End foreach(). |
126 | 126 | |
127 | - $this->fields = $args['fields']; |
|
127 | + $this->fields = $args[ 'fields' ]; |
|
128 | 128 | |
129 | 129 | // Now we are going to filter the fields. |
130 | 130 | // First we create a copy of the value that would be used otherwise. |
@@ -184,14 +184,14 @@ discard block |
||
184 | 184 | |
185 | 185 | $fields = $this->fields; |
186 | 186 | |
187 | - $this->json['fields'] = $fields; |
|
188 | - $this->json['row_label'] = $this->row_label; |
|
187 | + $this->json[ 'fields' ] = $fields; |
|
188 | + $this->json[ 'row_label' ] = $this->row_label; |
|
189 | 189 | |
190 | 190 | // If filtered_value has been set and is not empty we use it instead of the actual value. |
191 | 191 | if ( is_array( $this->filtered_value ) && ! empty( $this->filtered_value ) ) { |
192 | - $this->json['value'] = $this->filtered_value; |
|
192 | + $this->json[ 'value' ] = $this->filtered_value; |
|
193 | 193 | } |
194 | - $this->json['value'] = apply_filters( "kirki_controls_repeater_value_{$this->id}", $this->json['value'] ); |
|
194 | + $this->json[ 'value' ] = apply_filters( "kirki_controls_repeater_value_{$this->id}", $this->json[ 'value' ] ); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -214,10 +214,10 @@ discard block |
||
214 | 214 | |
215 | 215 | <ul class="repeater-fields"></ul> |
216 | 216 | |
217 | - <?php if ( isset( $this->choices['limit'] ) ) : ?> |
|
217 | + <?php if ( isset( $this->choices[ 'limit' ] ) ) : ?> |
|
218 | 218 | <?php // @codingStandardsIgnoreLine ?> |
219 | 219 | <?php /* translators: %s represents the number of rows we're limiting the repeater to allow. */ ?> |
220 | - <p class="limit"><?php printf( esc_attr__( 'Limit: %s rows', 'kirki' ), esc_html( $this->choices['limit'] ) ); ?></p> |
|
220 | + <p class="limit"><?php printf( esc_attr__( 'Limit: %s rows', 'kirki' ), esc_html( $this->choices[ 'limit' ] ) ); ?></p> |
|
221 | 221 | <?php endif; ?> |
222 | 222 | <button class="button-secondary repeater-add"><?php echo esc_html( $this->button_label ); ?></button> |
223 | 223 | |
@@ -447,24 +447,24 @@ discard block |
||
447 | 447 | protected function row_label( $args ) { |
448 | 448 | |
449 | 449 | // Validating args for row labels. |
450 | - if ( isset( $args['row_label'] ) && is_array( $args['row_label'] ) && ! empty( $args['row_label'] ) ) { |
|
450 | + if ( isset( $args[ 'row_label' ] ) && is_array( $args[ 'row_label' ] ) && ! empty( $args[ 'row_label' ] ) ) { |
|
451 | 451 | |
452 | 452 | // Validating row label type. |
453 | - if ( isset( $args['row_label']['type'] ) && ( 'text' === $args['row_label']['type'] || 'field' === $args['row_label']['type'] ) ) { |
|
454 | - $this->row_label['type'] = $args['row_label']['type']; |
|
453 | + if ( isset( $args[ 'row_label' ][ 'type' ] ) && ( 'text' === $args[ 'row_label' ][ 'type' ] || 'field' === $args[ 'row_label' ][ 'type' ] ) ) { |
|
454 | + $this->row_label[ 'type' ] = $args[ 'row_label' ][ 'type' ]; |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | // Validating row label type. |
458 | - if ( isset( $args['row_label']['value'] ) && ! empty( $args['row_label']['value'] ) ) { |
|
459 | - $this->row_label['value'] = esc_attr( $args['row_label']['value'] ); |
|
458 | + if ( isset( $args[ 'row_label' ][ 'value' ] ) && ! empty( $args[ 'row_label' ][ 'value' ] ) ) { |
|
459 | + $this->row_label[ 'value' ] = esc_attr( $args[ 'row_label' ][ 'value' ] ); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | // Validating row label field. |
463 | - if ( isset( $args['row_label']['field'] ) && ! empty( $args['row_label']['field'] ) && isset( $args['fields'][ esc_attr( $args['row_label']['field'] ) ] ) ) { |
|
464 | - $this->row_label['field'] = esc_attr( $args['row_label']['field'] ); |
|
463 | + if ( isset( $args[ 'row_label' ][ 'field' ] ) && ! empty( $args[ 'row_label' ][ 'field' ] ) && isset( $args[ 'fields' ][ esc_attr( $args[ 'row_label' ][ 'field' ] ) ] ) ) { |
|
464 | + $this->row_label[ 'field' ] = esc_attr( $args[ 'row_label' ][ 'field' ] ); |
|
465 | 465 | } else { |
466 | 466 | // If from field is not set correctly, making sure standard is set as the type. |
467 | - $this->row_label['type'] = 'text'; |
|
467 | + $this->row_label[ 'type' ] = 'text'; |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $config_ids = Kirki_Config::get_config_ids(); |
54 | 54 | global $kirki_deprecated_filters_iteration; |
55 | 55 | foreach ( $config_ids as $config_id ) { |
56 | - foreach( array( |
|
56 | + foreach ( array( |
|
57 | 57 | '/dynamic_css', |
58 | 58 | '/output/control-classnames', |
59 | 59 | '/css/skip_hidden', |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | $kirki_deprecated_filters_iteration = array( $config_id, $filter_suffix ); |
65 | 65 | add_filter( "kirki_{$config_id}_{$filter_suffix}", function( $args ) { |
66 | 66 | global $kirki_deprecated_filters_iteration; |
67 | - $kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] ); |
|
68 | - return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[0]}/{$kirki_deprecated_filters_iteration[1]}", $args ); |
|
67 | + $kirki_deprecated_filters_iteration[ 1 ] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[ 1 ] ); |
|
68 | + return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[ 0 ]}/{$kirki_deprecated_filters_iteration[ 1 ]}", $args ); |
|
69 | 69 | }, 99 ); |
70 | - if ( false !== strpos( $kirki_deprecated_filters_iteration[1], '-' ) ) { |
|
71 | - $kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] ); |
|
70 | + if ( false !== strpos( $kirki_deprecated_filters_iteration[ 1 ], '-' ) ) { |
|
71 | + $kirki_deprecated_filters_iteration[ 1 ] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[ 1 ] ); |
|
72 | 72 | add_filter( "kirki_{$config_id}_{$filter_suffix}", function( $args ) { |
73 | 73 | global $kirki_deprecated_filters_iteration; |
74 | - $kirki_deprecated_filters_iteration[1] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[1] ); |
|
75 | - return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[0]}/{$kirki_deprecated_filters_iteration[1]}", $args ); |
|
74 | + $kirki_deprecated_filters_iteration[ 1 ] = str_replace( '-', '_', $kirki_deprecated_filters_iteration[ 1 ] ); |
|
75 | + return apply_filters( "kirki/{$kirki_deprecated_filters_iteration[ 0 ]}/{$kirki_deprecated_filters_iteration[ 1 ]}", $args ); |
|
76 | 76 | }, 99 ); |
77 | 77 | } |
78 | 78 | } |