@@ -83,28 +83,28 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | if ( empty( $this->button_label ) ) { |
| 85 | 85 | /* translators: %s represents the label of the row. */ |
| 86 | - $this->button_label = sprintf( esc_html__( 'Add new %s', 'kirki' ), $this->row_label['value'] ); |
|
| 86 | + $this->button_label = sprintf( esc_html__( 'Add new %s', 'kirki' ), $this->row_label[ 'value' ] ); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if ( empty( $args['fields'] ) || ! is_array( $args['fields'] ) ) { |
|
| 90 | - $args['fields'] = array(); |
|
| 89 | + if ( empty( $args[ 'fields' ] ) || ! is_array( $args[ 'fields' ] ) ) { |
|
| 90 | + $args[ 'fields' ] = array(); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // An array to store keys of fields that need to be filtered. |
| 94 | 94 | $media_fields_to_filter = array(); |
| 95 | 95 | |
| 96 | - foreach ( $args['fields'] as $key => $value ) { |
|
| 97 | - if ( ! isset( $value['default'] ) ) { |
|
| 98 | - $args['fields'][ $key ]['default'] = ''; |
|
| 96 | + foreach ( $args[ 'fields' ] as $key => $value ) { |
|
| 97 | + if ( ! isset( $value[ 'default' ] ) ) { |
|
| 98 | + $args[ 'fields' ][ $key ][ 'default' ] = ''; |
|
| 99 | 99 | } |
| 100 | - if ( ! isset( $value['label'] ) ) { |
|
| 101 | - $args['fields'][ $key ]['label'] = ''; |
|
| 100 | + if ( ! isset( $value[ 'label' ] ) ) { |
|
| 101 | + $args[ 'fields' ][ $key ][ 'label' ] = ''; |
|
| 102 | 102 | } |
| 103 | - $args['fields'][ $key ]['id'] = $key; |
|
| 103 | + $args[ 'fields' ][ $key ][ 'id' ] = $key; |
|
| 104 | 104 | |
| 105 | 105 | // We check if the filed is an uploaded media ( image , file, video, etc.. ). |
| 106 | - if ( isset( $value['type'] ) ) { |
|
| 107 | - switch ( $value['type'] ) { |
|
| 106 | + if ( isset( $value[ 'type' ] ) ) { |
|
| 107 | + switch ( $value[ 'type' ] ) { |
|
| 108 | 108 | case 'image': |
| 109 | 109 | case 'cropped_image': |
| 110 | 110 | case 'upload': |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | ); |
| 128 | 128 | |
| 129 | 129 | // Hackily add in the data link parameter. |
| 130 | - $dropdown = str_replace( '<select', '<select data-field="' . esc_attr( $args['fields'][ $key ]['id'] ) . '"' . $this->get_link(), $dropdown ); // phpcs:ignore Generic.Formatting.MultipleStatementAlignment.NotSameWarning |
|
| 131 | - $args['fields'][ $key ]['dropdown'] = $dropdown; |
|
| 130 | + $dropdown = str_replace( '<select', '<select data-field="' . esc_attr( $args[ 'fields' ][ $key ][ 'id' ] ) . '"' . $this->get_link(), $dropdown ); // phpcs:ignore Generic.Formatting.MultipleStatementAlignment.NotSameWarning |
|
| 131 | + $args[ 'fields' ][ $key ][ 'dropdown' ] = $dropdown; |
|
| 132 | 132 | break; |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $this->fields = $args['fields']; |
|
| 137 | + $this->fields = $args[ 'fields' ]; |
|
| 138 | 138 | |
| 139 | 139 | // Now we are going to filter the fields. |
| 140 | 140 | // First we create a copy of the value that would be used otherwise. |
@@ -194,14 +194,14 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | $fields = $this->fields; |
| 196 | 196 | |
| 197 | - $this->json['fields'] = $fields; |
|
| 198 | - $this->json['row_label'] = $this->row_label; |
|
| 197 | + $this->json[ 'fields' ] = $fields; |
|
| 198 | + $this->json[ 'row_label' ] = $this->row_label; |
|
| 199 | 199 | |
| 200 | 200 | // If filtered_value has been set and is not empty we use it instead of the actual value. |
| 201 | 201 | if ( is_array( $this->filtered_value ) && ! empty( $this->filtered_value ) ) { |
| 202 | - $this->json['value'] = $this->filtered_value; |
|
| 202 | + $this->json[ 'value' ] = $this->filtered_value; |
|
| 203 | 203 | } |
| 204 | - $this->json['value'] = apply_filters( "kirki_controls_repeater_value_{$this->id}", $this->json['value'] ); |
|
| 204 | + $this->json[ 'value' ] = apply_filters( "kirki_controls_repeater_value_{$this->id}", $this->json[ 'value' ] ); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -224,9 +224,9 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | <ul class="repeater-fields"></ul> |
| 226 | 226 | |
| 227 | - <?php if ( isset( $this->choices['limit'] ) ) : ?> |
|
| 227 | + <?php if ( isset( $this->choices[ 'limit' ] ) ) : ?> |
|
| 228 | 228 | <?php /* translators: %s represents the number of rows we're limiting the repeater to allow. */ ?> |
| 229 | - <p class="limit"><?php printf( esc_html__( 'Limit: %s rows', 'kirki' ), esc_html( $this->choices['limit'] ) ); ?></p> |
|
| 229 | + <p class="limit"><?php printf( esc_html__( 'Limit: %s rows', 'kirki' ), esc_html( $this->choices[ 'limit' ] ) ); ?></p> |
|
| 230 | 230 | <?php endif; ?> |
| 231 | 231 | <button class="button-secondary repeater-add"><?php echo esc_html( $this->button_label ); ?></button> |
| 232 | 232 | |
@@ -459,24 +459,24 @@ discard block |
||
| 459 | 459 | protected function row_label( $args ) { |
| 460 | 460 | |
| 461 | 461 | // Validating args for row labels. |
| 462 | - if ( isset( $args['row_label'] ) && is_array( $args['row_label'] ) && ! empty( $args['row_label'] ) ) { |
|
| 462 | + if ( isset( $args[ 'row_label' ] ) && is_array( $args[ 'row_label' ] ) && ! empty( $args[ 'row_label' ] ) ) { |
|
| 463 | 463 | |
| 464 | 464 | // Validating row label type. |
| 465 | - if ( isset( $args['row_label']['type'] ) && ( 'text' === $args['row_label']['type'] || 'field' === $args['row_label']['type'] ) ) { |
|
| 466 | - $this->row_label['type'] = $args['row_label']['type']; |
|
| 465 | + if ( isset( $args[ 'row_label' ][ 'type' ] ) && ( 'text' === $args[ 'row_label' ][ 'type' ] || 'field' === $args[ 'row_label' ][ 'type' ] ) ) { |
|
| 466 | + $this->row_label[ 'type' ] = $args[ 'row_label' ][ 'type' ]; |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | // Validating row label type. |
| 470 | - if ( isset( $args['row_label']['value'] ) && ! empty( $args['row_label']['value'] ) ) { |
|
| 471 | - $this->row_label['value'] = esc_html( $args['row_label']['value'] ); |
|
| 470 | + if ( isset( $args[ 'row_label' ][ 'value' ] ) && ! empty( $args[ 'row_label' ][ 'value' ] ) ) { |
|
| 471 | + $this->row_label[ 'value' ] = esc_html( $args[ 'row_label' ][ 'value' ] ); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | // Validating row label field. |
| 475 | - if ( isset( $args['row_label']['field'] ) && ! empty( $args['row_label']['field'] ) && isset( $args['fields'][ sanitize_key( $args['row_label']['field'] ) ] ) ) { |
|
| 476 | - $this->row_label['field'] = esc_html( $args['row_label']['field'] ); |
|
| 475 | + if ( isset( $args[ 'row_label' ][ 'field' ] ) && ! empty( $args[ 'row_label' ][ 'field' ] ) && isset( $args[ 'fields' ][ sanitize_key( $args[ 'row_label' ][ 'field' ] ) ] ) ) { |
|
| 476 | + $this->row_label[ 'field' ] = esc_html( $args[ 'row_label' ][ 'field' ] ); |
|
| 477 | 477 | } else { |
| 478 | 478 | // If from field is not set correctly, making sure standard is set as the type. |
| 479 | - $this->row_label['type'] = 'text'; |
|
| 479 | + $this->row_label[ 'type' ] = 'text'; |
|
| 480 | 480 | } |
| 481 | 481 | } |
| 482 | 482 | } |
@@ -161,55 +161,55 @@ |
||
| 161 | 161 | parent::to_json(); |
| 162 | 162 | |
| 163 | 163 | // Default value. |
| 164 | - $this->json['default'] = $this->setting->default; |
|
| 164 | + $this->json[ 'default' ] = $this->setting->default; |
|
| 165 | 165 | if ( isset( $this->default ) ) { |
| 166 | - $this->json['default'] = $this->default; |
|
| 166 | + $this->json[ 'default' ] = $this->default; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | // Required. |
| 170 | - $this->json['required'] = $this->required; |
|
| 170 | + $this->json[ 'required' ] = $this->required; |
|
| 171 | 171 | |
| 172 | 172 | // Output. |
| 173 | - $this->json['output'] = $this->output; |
|
| 173 | + $this->json[ 'output' ] = $this->output; |
|
| 174 | 174 | |
| 175 | 175 | // Value. |
| 176 | - $this->json['value'] = $this->value(); |
|
| 176 | + $this->json[ 'value' ] = $this->value(); |
|
| 177 | 177 | |
| 178 | 178 | // Choices. |
| 179 | - $this->json['choices'] = $this->choices; |
|
| 179 | + $this->json[ 'choices' ] = $this->choices; |
|
| 180 | 180 | |
| 181 | 181 | // The link. |
| 182 | - $this->json['link'] = $this->get_link(); |
|
| 182 | + $this->json[ 'link' ] = $this->get_link(); |
|
| 183 | 183 | |
| 184 | 184 | // The ID. |
| 185 | - $this->json['id'] = $this->id; |
|
| 185 | + $this->json[ 'id' ] = $this->id; |
|
| 186 | 186 | |
| 187 | 187 | // Translation strings. |
| 188 | - $this->json['l10n'] = $this->l10n(); |
|
| 188 | + $this->json[ 'l10n' ] = $this->l10n(); |
|
| 189 | 189 | |
| 190 | 190 | // The ajaxurl in case we need it. |
| 191 | - $this->json['ajaxurl'] = admin_url( 'admin-ajax.php' ); |
|
| 191 | + $this->json[ 'ajaxurl' ] = admin_url( 'admin-ajax.php' ); |
|
| 192 | 192 | |
| 193 | 193 | // Input attributes. |
| 194 | - $this->json['inputAttrs'] = ''; |
|
| 194 | + $this->json[ 'inputAttrs' ] = ''; |
|
| 195 | 195 | foreach ( $this->input_attrs as $attr => $value ) { |
| 196 | - $this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
| 196 | + $this->json[ 'inputAttrs' ] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // The kirki-config. |
| 200 | - $this->json['kirkiConfig'] = $this->kirki_config; |
|
| 200 | + $this->json[ 'kirkiConfig' ] = $this->kirki_config; |
|
| 201 | 201 | |
| 202 | 202 | // The option-type. |
| 203 | - $this->json['kirkiOptionType'] = $this->option_type; |
|
| 203 | + $this->json[ 'kirkiOptionType' ] = $this->option_type; |
|
| 204 | 204 | |
| 205 | 205 | // The option-name. |
| 206 | - $this->json['kirkiOptionName'] = $this->option_name; |
|
| 206 | + $this->json[ 'kirkiOptionName' ] = $this->option_name; |
|
| 207 | 207 | |
| 208 | 208 | // The preset. |
| 209 | - $this->json['preset'] = $this->preset; |
|
| 209 | + $this->json[ 'preset' ] = $this->preset; |
|
| 210 | 210 | |
| 211 | 211 | // The CSS-Variables. |
| 212 | - $this->json['css-var'] = $this->css_vars; |
|
| 212 | + $this->json[ 'css-var' ] = $this->css_vars; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | */ |
| 53 | 53 | public function to_json() { |
| 54 | 54 | parent::to_json(); |
| 55 | - $this->json['multiple'] = $this->multiple; |
|
| 56 | - $this->json['placeholder'] = $this->placeholder; |
|
| 55 | + $this->json[ 'multiple' ] = $this->multiple; |
|
| 56 | + $this->json[ 'placeholder' ] = $this->placeholder; |
|
| 57 | 57 | } |
| 58 | 58 | } |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | public function to_json() { |
| 44 | 44 | parent::to_json(); |
| 45 | - $this->json['alpha'] = (bool) $this->alpha; |
|
| 45 | + $this->json[ 'alpha' ] = (bool) $this->alpha; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -36,10 +36,10 @@ |
||
| 36 | 36 | parent::to_json(); |
| 37 | 37 | foreach ( $this->input_attrs as $attr => $value ) { |
| 38 | 38 | if ( 'style' !== $attr ) { |
| 39 | - $this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
| 39 | + $this->json[ 'inputAttrs' ] .= $attr . '="' . esc_attr( $value ) . '" '; |
|
| 40 | 40 | continue; |
| 41 | 41 | } |
| 42 | - $this->json['labelStyle'] = 'style="' . esc_attr( $value ) . '" '; |
|
| 42 | + $this->json[ 'labelStyle' ] = 'style="' . esc_attr( $value ) . '" '; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | } |
@@ -36,8 +36,8 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | public function to_json() { |
| 38 | 38 | parent::to_json(); |
| 39 | - $this->json['choices'] = wp_parse_args( |
|
| 40 | - $this->json['choices'], array( |
|
| 39 | + $this->json[ 'choices' ] = wp_parse_args( |
|
| 40 | + $this->json[ 'choices' ], array( |
|
| 41 | 41 | 'min' => '0', |
| 42 | 42 | 'max' => '100', |
| 43 | 43 | 'step' => '1', |
@@ -23,8 +23,8 @@ |
||
| 23 | 23 | if ( ! is_array( $this->choices ) ) { |
| 24 | 24 | $this->choices = array(); |
| 25 | 25 | } |
| 26 | - $this->choices['element'] = 'input'; |
|
| 27 | - $this->choices['type'] = 'text'; |
|
| 26 | + $this->choices[ 'element' ] = 'input'; |
|
| 27 | + $this->choices[ 'type' ] = 'text'; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -97,14 +97,14 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | // Get the subfield-type. |
| 100 | - if ( ! isset( $this->fields[ $subfield_id ]['type'] ) ) { |
|
| 100 | + if ( ! isset( $this->fields[ $subfield_id ][ 'type' ] ) ) { |
|
| 101 | 101 | continue; |
| 102 | 102 | } |
| 103 | - $subfield_type = $this->fields[ $subfield_id ]['type']; |
|
| 103 | + $subfield_type = $this->fields[ $subfield_id ][ 'type' ]; |
|
| 104 | 104 | |
| 105 | 105 | // Allow using a sanitize-callback on a per-field basis. |
| 106 | - if ( isset( $this->fields[ $subfield_id ]['sanitize_callback'] ) ) { |
|
| 107 | - $subfield_value = call_user_func( $this->fields[ $subfield_id ]['sanitize_callback'], $subfield_value ); |
|
| 106 | + if ( isset( $this->fields[ $subfield_id ][ 'sanitize_callback' ] ) ) { |
|
| 107 | + $subfield_value = call_user_func( $this->fields[ $subfield_id ][ 'sanitize_callback' ], $subfield_value ); |
|
| 108 | 108 | } else { |
| 109 | 109 | |
| 110 | 110 | switch ( $subfield_type ) { |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | $subfield_value = (bool) $subfield_value; |
| 140 | 140 | break; |
| 141 | 141 | case 'select': |
| 142 | - if ( isset( $this->fields[ $subfield_id ]['multiple'] ) ) { |
|
| 143 | - if ( true === $this->fields[ $subfield_id ]['multiple'] ) { |
|
| 142 | + if ( isset( $this->fields[ $subfield_id ][ 'multiple' ] ) ) { |
|
| 143 | + if ( true === $this->fields[ $subfield_id ][ 'multiple' ] ) { |
|
| 144 | 144 | $multiple = 2; |
| 145 | 145 | } |
| 146 | - $multiple = (int) $this->fields[ $subfield_id ]['multiple']; |
|
| 146 | + $multiple = (int) $this->fields[ $subfield_id ][ 'multiple' ]; |
|
| 147 | 147 | if ( 1 < $multiple ) { |
| 148 | 148 | $subfield_value = (array) $subfield_value; |
| 149 | 149 | foreach ( $subfield_value as $sub_subfield_key => $sub_subfield_value ) { |
@@ -61,10 +61,10 @@ |
||
| 61 | 61 | * @access protected |
| 62 | 62 | */ |
| 63 | 63 | protected function set_choices() { |
| 64 | - $this->choices['controls'] = array(); |
|
| 64 | + $this->choices[ 'controls' ] = array(); |
|
| 65 | 65 | if ( is_array( $this->default ) ) { |
| 66 | 66 | foreach ( $this->default as $key => $value ) { |
| 67 | - $this->choices['controls'][ $key ] = true; |
|
| 67 | + $this->choices[ 'controls' ][ $key ] = true; |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | } |