Completed
Push — develop ( 6bc4f7...cab9c0 )
by Aristeides
04:02
created

Kirki_Control_Repeater::to_json()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 25
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 16
nc 8
nop 0
dl 0
loc 25
rs 8.439
c 0
b 0
f 0
1
<?php
2
/**
3
 * Customizer Control: repeater.
4
 *
5
 * @package     Kirki
6
 * @subpackage  Controls
7
 * @copyright   Copyright (c) 2017, Aristeides Stathopoulos
8
 * @license     http://opensource.org/licenses/https://opensource.org/licenses/MIT
9
 * @since       2.0
10
 */
11
12
// Exit if accessed directly.
13
if ( ! defined( 'ABSPATH' ) ) {
14
	exit;
15
}
16
17
/**
18
 * Repeater control
19
 */
20
class Kirki_Control_Repeater extends WP_Customize_Control {
21
22
	/**
23
	 * The control type.
24
	 *
25
	 * @access public
26
	 * @var string
27
	 */
28
	public $type = 'repeater';
29
30
	/**
31
	 * Used to automatically generate all CSS output.
32
	 *
33
	 * @access public
34
	 * @var array
35
	 */
36
	public $output = array();
37
38
	/**
39
	 * Data type
40
	 *
41
	 * @access public
42
	 * @var string
43
	 */
44
	public $option_type = 'theme_mod';
45
46
	/**
47
	 * The kirki_config we're using for this control
48
	 *
49
	 * @access public
50
	 * @var string
51
	 */
52
	public $kirki_config = 'global';
53
54
	/**
55
	 * The fields that each container row will contain.
56
	 *
57
	 * @access public
58
	 * @var array
59
	 */
60
	public $fields = array();
61
62
	/**
63
	 * Will store a filtered version of value for advenced fields (like images).
64
	 *
65
	 * @access protected
66
	 * @var array
67
	 */
68
	protected $filtered_value = array();
69
70
	/**
71
	 * The row label
72
	 *
73
	 * @access public
74
	 * @var array
75
	 */
76
	public $row_label = array();
77
78
	/**
79
	 * Constructor.
80
	 * Supplied `$args` override class property defaults.
81
	 * If `$args['settings']` is not defined, use the $id as the setting ID.
82
	 *
83
	 * @param WP_Customize_Manager $manager Customizer bootstrap instance.
84
	 * @param string               $id      Control ID.
85
	 * @param array                $args    {@see WP_Customize_Control::__construct}.
86
	 */
87
	public function __construct( $manager, $id, $args = array() ) {
88
89
		parent::__construct( $manager, $id, $args );
90
91
		// Set up defaults for row labels.
92
		$this->row_label = array(
93
			'type' => 'text',
94
			'value' => $this->l10n( 'row' ),
95
			'field' => false,
96
		);
97
98
		// Validate row-labels.
99
		$this->row_label( $args );
100
101
		if ( empty( $this->button_label ) ) {
102
			$this->button_label = $this->l10n( 'add-new' ) . ' ' . $this->row_label['value'];
103
		}
104
105
		if ( empty( $args['fields'] ) || ! is_array( $args['fields'] ) ) {
106
			$args['fields'] = array();
107
		}
108
109
		// An array to store keys of fields that need to be filtered.
110
		$media_fields_to_filter = array();
111
112
		foreach ( $args['fields'] as $key => $value ) {
113
			if ( ! isset( $value['default'] ) ) {
114
				$args['fields'][ $key ]['default'] = '';
115
			}
116
			if ( ! isset( $value['label'] ) ) {
117
				$args['fields'][ $key ]['label'] = '';
118
			}
119
			$args['fields'][ $key ]['id']      = $key;
120
121
			// We check if the filed is an uploaded media ( image , file, video, etc.. ).
122
			if ( isset( $value['type'] ) ) {
123
				switch ( $value['type'] ) {
124
					case 'image':
125
					case 'cropped_image':
126
					case 'upload':
127
						// We add it to the list of fields that need some extra filtering/processing.
128
						$media_fields_to_filter[ $key ] = true;
129
						break;
130
131
					case 'dropdown-pages':
132
						// If the field is a dropdown-pages field then add it to args.
133
						$dropdown = wp_dropdown_pages(
134
							array(
135
								'name'              => '',
136
								'echo'              => 0,
137
								'show_option_none'  => esc_attr( $this->l10n( 'select-page' ) ),
138
								'option_none_value' => '0',
139
								'selected'          => '',
140
							)
141
						);
142
						// Hackily add in the data link parameter.
143
						$dropdown = str_replace( '<select', '<select data-field="' . esc_attr( $args['fields'][ $key ]['id'] ) . '"' . $this->get_link(), $dropdown );
144
						$args['fields'][ $key ]['dropdown'] = $dropdown;
145
						break;
146
				}
147
			}
148
		} // End foreach().
149
150
		$this->fields = $args['fields'];
151
152
		// Now we are going to filter the fields.
153
		// First we create a copy of the value that would be used otherwise.
154
		$this->filtered_value = $this->value();
155
156
		if ( is_array( $this->filtered_value ) && ! empty( $this->filtered_value ) ) {
157
158
			// We iterate over the list of fields.
159
			foreach ( $this->filtered_value as &$filtered_value_field ) {
160
161
				if ( is_array( $filtered_value_field ) && ! empty( $filtered_value_field ) ) {
162
163
					// We iterate over the list of properties for this field.
164
					foreach ( $filtered_value_field as $key => &$value ) {
165
166
						// We check if this field was marked as requiring extra filtering (in this case image, cropped_images, upload).
167
						if ( array_key_exists( $key, $media_fields_to_filter ) ) {
168
169
							// What follows was made this way to preserve backward compatibility.
170
							// The repeater control use to store the URL for images instead of the attachment ID.
171
							// We check if the value look like an ID (otherwise it's probably a URL so don't filter it).
172
							if ( is_numeric( $value ) ) {
173
174
								// "sanitize" the value.
175
								$attachment_id = (int) $value;
176
177
								// Try to get the attachment_url.
178
								$url = wp_get_attachment_url( $attachment_id );
179
180
								$filename = basename( get_attached_file( $attachment_id ) );
181
182
								// If we got a URL.
183
								if ( $url ) {
184
185
									// 'id' is needed for form hidden value, URL is needed to display the image.
186
									$value = array(
187
										'id'  => $attachment_id,
188
										'url' => $url,
189
										'filename' => $filename,
190
									);
191
								}
192
							}
193
						}
194
					}
195
				}
196
			} // End foreach().
197
		} // End if().
198
	}
199
200
	/**
201
	 * Refresh the parameters passed to the JavaScript via JSON.
202
	 *
203
	 * @access public
204
	 */
205
	public function to_json() {
206
		parent::to_json();
207
208
		$this->json['default'] = ( isset( $this->default ) ) ? $this->default : $this->setting->default;
209
		$this->json['output']  = $this->output;
210
		$this->json['value']   = $this->value();
211
		$this->json['choices'] = $this->choices;
212
		$this->json['link']    = $this->get_link();
213
		$this->json['id']      = $this->id;
214
215
		$this->json['inputAttrs'] = '';
216
		foreach ( $this->input_attrs as $attr => $value ) {
217
			$this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" ';
218
		}
219
220
		$fields = $this->fields;
221
222
		$this->json['fields'] = $fields;
223
		$this->json['row_label'] = $this->row_label;
224
225
		// If filtered_value has been set and is not empty we use it instead of the actual value.
226
		if ( is_array( $this->filtered_value ) && ! empty( $this->filtered_value ) ) {
227
			$this->json['value'] = $this->filtered_value;
228
		}
229
	}
230
231
	/**
232
	 * Enqueue control related scripts/styles.
233
	 *
234
	 * @access public
235
	 */
236
	public function enqueue() {
237
238
		// If we have a color picker field we need to enqueue the Wordpress Color Picker style and script.
239
		if ( is_array( $this->fields ) && ! empty( $this->fields ) ) {
240
			foreach ( $this->fields as $field ) {
241
				if ( isset( $field['type'] ) ) {
242
243
					// Some field-types require extra scripts.
244
					switch ( $field['type'] ) {
245
						case 'color':
246
							wp_enqueue_script( 'wp-color-picker' );
247
							wp_enqueue_style( 'wp-color-picker' );
248
							break;
249
						case 'select':
250
						case 'dropdown-pages':
251
							wp_enqueue_script( 'select2', trailingslashit( Kirki::$url ) . 'assets/vendor/select2/js/select2.full.js', array( 'jquery' ), false, true );
252
							wp_enqueue_style( 'select2', trailingslashit( Kirki::$url ) . 'assets/vendor/select2/kirki.css', null );
253
							break;
254
					}
255
				}
256
			}
257
		}
258
259
		wp_enqueue_script( 'kirki-repeater', trailingslashit( Kirki::$url ) . 'controls/repeater/repeater.js', array( 'jquery', 'customize-base', 'jquery-ui-core', 'jquery-ui-sortable' ), false, true );
260
		wp_enqueue_style( 'kirki-repeater-css', trailingslashit( Kirki::$url ) . 'controls/repeater/repeater.css', null );
261
	}
262
263
	/**
264
	 * Render the control's content.
265
	 * Allows the content to be overriden without having to rewrite the wrapper in $this->render().
266
	 *
267
	 * @access protected
268
	 */
269
	protected function render_content() {
270
		?>
271
		<label>
272
			<?php if ( ! empty( $this->label ) ) : ?>
273
				<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
274
			<?php endif; ?>
275
			<?php if ( ! empty( $this->description ) ) : ?>
276
				<span class="description customize-control-description"><?php echo wp_kses_post( $this->description ); ?></span>
277
			<?php endif; ?>
278
			<input type="hidden" {{{ data.inputAttrs }}} value="" <?php echo wp_kses_post( $this->get_link() ); ?> />
279
		</label>
280
281
		<ul class="repeater-fields"></ul>
282
283
		<?php if ( isset( $this->choices['limit'] ) ) : ?>
284
			<p class="limit"><?php printf( esc_html( $this->l10n( 'limit-rows' ) ), esc_html( $this->choices['limit'] ) ); ?></p>
285
		<?php endif; ?>
286
		<button class="button-secondary repeater-add"><?php echo esc_html( $this->button_label ); ?></button>
287
288
		<?php
289
290
		$this->repeater_js_template();
291
292
	}
293
294
	/**
295
	 * An Underscore (JS) template for this control's content (but not its container).
296
	 * Class variables for this control class are available in the `data` JS object.
297
	 *
298
	 * @access public
299
	 */
300
	public function repeater_js_template() {
301
		?>
302
		<script type="text/html" class="customize-control-repeater-content">
303
			<# var field; var index = data.index; #>
304
305
			<li class="repeater-row minimized" data-row="{{{ index }}}">
306
307
				<div class="repeater-row-header">
308
					<span class="repeater-row-label"></span>
309
					<i class="dashicons dashicons-arrow-down repeater-minimize"></i>
310
				</div>
311
				<div class="repeater-row-content">
312
					<# _.each( data, function( field, i ) { #>
313
314
						<div class="repeater-field repeater-field-{{{ field.type }}}">
315
316
							<# if ( 'text' === field.type || 'url' === field.type || 'link' === field.type || 'email' === field.type || 'tel' === field.type || 'date' === field.type || 'number' === field.type ) { #>
317
								<# var fieldExtras = ''; #>
318
								<# if ( 'link' === field.type ) { #>
319
									<# field.type = 'url' #>
320
								<# } #>
321
322
								<# if ( 'number' === field.type ) { #>
323
									<# if ( ! _.isUndefined( field.choices ) && ! _.isUndefined( field.choices.min ) ) { #>
324
										<# fieldExtras += ' min="' + field.choices.min + '"'; #>
325
									<# } #>
326
									<# if ( ! _.isUndefined( field.choices ) && ! _.isUndefined( field.choices.max ) ) { #>
327
										<# fieldExtras += ' max="' + field.choices.max + '"'; #>
328
									<# } #>
329
									<# if ( ! _.isUndefined( field.choices ) && ! _.isUndefined( field.choices.step ) ) { #>
330
										<# fieldExtras += ' step="' + field.choices.step + '"'; #>
331
									<# } #>
332
								<# } #>
333
334
								<label>
335
									<# if ( field.label ) { #>
336
										<span class="customize-control-title">{{ field.label }}</span>
337
									<# } #>
338
									<# if ( field.description ) { #>
339
										<span class="description customize-control-description">{{ field.description }}</span>
340
									<# } #>
341
									<input type="{{field.type}}" name="" value="{{{ field.default }}}" data-field="{{{ field.id }}}"{{ fieldExtras }}>
342
								</label>
343
344
							<# } else if ( 'number' === field.type ) { #>
345
346
								<label>
347
									<# if ( field.label ) { #>
348
										<span class="customize-control-title">{{ field.label }}</span>
349
									<# } #>
350
									<# if ( field.description ) { #>
351
										<span class="description customize-control-description">{{ field.description }}</span>
352
									<# } #>
353
									<input type="{{ field.type }}" name="" value="{{{ field.default }}}" data-field="{{{ field.id }}}"{{ numberFieldExtras }}>
354
								</label>
355
356
							<# } else if ( 'hidden' === field.type ) { #>
357
358
								<input type="hidden" data-field="{{{ field.id }}}" <# if ( field.default ) { #> value="{{{ field.default }}}" <# } #> />
359
360
							<# } else if ( 'checkbox' === field.type ) { #>
361
362
								<label>
363
									<input type="checkbox" value="true" data-field="{{{ field.id }}}" <# if ( field.default ) { #> checked="checked" <# } #> /> {{ field.label }}
364
									<# if ( field.description ) { #>
365
										{{ field.description }}
366
									<# } #>
367
								</label>
368
369
							<# } else if ( 'select' === field.type ) { #>
370
371
								<label>
372
									<# if ( field.label ) { #>
373
										<span class="customize-control-title">{{ field.label }}</span>
374
									<# } #>
375
									<# if ( field.description ) { #>
376
										<span class="description customize-control-description">{{ field.description }}</span>
377
									<# } #>
378
									<select data-field="{{{ field.id }}}"<# if ( ! _.isUndefined( field.multiple ) && false !== field.multiple ) { #> multiple="multiple" data-multiple="{{ field.multiple }}"<# } #>>
379
										<# _.each( field.choices, function( choice, i ) { #>
380
											<option value="{{{ i }}}" <# if ( field.default == i ) { #> selected="selected" <# } #>>{{ choice }}</option>
381
										<# }); #>
382
									</select>
383
								</label>
384
385
							<# } else if ( 'dropdown-pages' === field.type ) { #>
386
387
								<label>
388
									<# if ( field.label ) { #>
389
										<span class="customize-control-title">{{{ data.label }}}</span>
390
									<# } #>
391
									<# if ( field.description ) { #>
392
										<span class="description customize-control-description">{{{ field.description }}}</span>
393
									<# } #>
394
									<div class="customize-control-content repeater-dropdown-pages">{{{ field.dropdown }}}</div>
395
								</label>
396
397
							<# } else if ( 'radio' === field.type ) { #>
398
399
								<label>
400
									<# if ( field.label ) { #>
401
										<span class="customize-control-title">{{ field.label }}</span>
402
									<# } #>
403
									<# if ( field.description ) { #>
404
										<span class="description customize-control-description">{{ field.description }}</span>
405
									<# } #>
406
407
									<# _.each( field.choices, function( choice, i ) { #>
408
										<label>
409
											<input type="radio" name="{{{ field.id }}}{{ index }}" data-field="{{{ field.id }}}" value="{{{ i }}}" <# if ( field.default == i ) { #> checked="checked" <# } #>> {{ choice }} <br/>
410
										</label>
411
									<# }); #>
412
								</label>
413
414
							<# } else if ( 'radio-image' === field.type ) { #>
415
416
								<label>
417
									<# if ( field.label ) { #>
418
										<span class="customize-control-title">{{ field.label }}</span>
419
									<# } #>
420
									<# if ( field.description ) { #>
421
										<span class="description customize-control-description">{{ field.description }}</span>
422
									<# } #>
423
424
									<# _.each( field.choices, function( choice, i ) { #>
425
										<input type="radio" id="{{{ field.id }}}_{{ index }}_{{{ i }}}" name="{{{ field.id }}}{{ index }}" data-field="{{{ field.id }}}" value="{{{ i }}}" <# if ( field.default == i ) { #> checked="checked" <# } #>>
426
											<label for="{{{ field.id }}}_{{ index }}_{{{ i }}}">
427
												<img src="{{ choice }}">
428
											</label>
429
										</input>
430
									<# }); #>
431
								</label>
432
433
							<# } else if ( 'color' === field.type ) { #>
434
435
								<# var defaultValue = '';
436
								if ( field.default ) {
437
									if ( '#' !== field.default.substring( 0, 1 ) ) {
438
										defaultValue = '#' + field.default;
439
									} else {
440
										defaultValue = field.default;
441
									}
442
									defaultValue = ' data-default-color=' + defaultValue; // Quotes added automatically.
443
								} #>
444
								<label>
445
									<# if ( field.label ) { #>
446
										<span class="customize-control-title">{{{ field.label }}}</span>
447
									<# } #>
448
									<# if ( field.description ) { #>
449
										<span class="description customize-control-description">{{{ field.description }}}</span>
450
									<# } #>
451
									<input class="color-picker-hex" type="text" maxlength="7" placeholder="<?php echo esc_attr( $this->l10n( 'hex-value' ) ); ?>"  value="{{{ field.default }}}" data-field="{{{ field.id }}}" {{ defaultValue }} />
452
453
								</label>
454
455
							<# } else if ( 'textarea' === field.type ) { #>
456
457
								<# if ( field.label ) { #>
458
									<span class="customize-control-title">{{ field.label }}</span>
459
								<# } #>
460
								<# if ( field.description ) { #>
461
									<span class="description customize-control-description">{{ field.description }}</span>
462
								<# } #>
463
								<textarea rows="5" data-field="{{{ field.id }}}">{{ field.default }}</textarea>
464
465
							<# } else if ( field.type === 'image' || field.type === 'cropped_image' ) { #>
466
467
								<label>
468
									<# if ( field.label ) { #>
469
										<span class="customize-control-title">{{ field.label }}</span>
470
									<# } #>
471
									<# if ( field.description ) { #>
472
										<span class="description customize-control-description">{{ field.description }}</span>
473
									<# } #>
474
								</label>
475
476
								<figure class="kirki-image-attachment" data-placeholder="<?php echo esc_attr( $this->l10n( 'no-image-selected' ) ); ?>" >
477
									<# if ( field.default ) { #>
478
										<# var defaultImageURL = ( field.default.url ) ? field.default.url : field.default; #>
479
										<img src="{{{ defaultImageURL }}}">
480
									<# } else { #>
481
										<?php echo esc_attr( $this->l10n( 'no-image-selected' ) ); ?>
482
									<# } #>
483
								</figure>
484
485
								<div class="actions">
486
									<button type="button" class="button remove-button<# if ( ! field.default ) { #> hidden<# } #>"><?php echo esc_attr( $this->l10n( 'remove' ) ); ?></button>
487
									<button type="button" class="button upload-button" data-label=" <?php echo esc_attr( $this->l10n( 'add-image' ) ); ?>" data-alt-label="<?php echo esc_attr( $this->l10n( 'change-image' ) ); ?>" >
488
										<# if ( field.default ) { #>
489
											<?php echo esc_attr( $this->l10n( 'change-image' ) ); ?>
490
										<# } else { #>
491
											<?php echo esc_attr( $this->l10n( 'add-image' ) ); ?>
492
										<# } #>
493
									</button>
494
									<# if ( field.default.id ) { #>
495
										<input type="hidden" class="hidden-field" value="{{{ field.default.id }}}" data-field="{{{ field.id }}}" >
496
									<# } else { #>
497
										<input type="hidden" class="hidden-field" value="{{{ field.default }}}" data-field="{{{ field.id }}}" >
498
									<# } #>
499
								</div>
500
501
							<# } else if ( field.type === 'upload' ) { #>
502
503
								<label>
504
									<# if ( field.label ) { #>
505
										<span class="customize-control-title">{{ field.label }}</span>
506
									<# } #>
507
									<# if ( field.description ) { #>
508
										<span class="description customize-control-description">{{ field.description }}</span>
509
									<# } #>
510
								</label>
511
512
								<figure class="kirki-file-attachment" data-placeholder="<?php echo esc_attr( $this->l10n( 'no-file-selected' ) ); ?>" >
513
									<# if ( field.default ) { #>
514
										<# var defaultFilename = ( field.default.filename ) ? field.default.filename : field.default; #>
515
										<span class="file"><span class="dashicons dashicons-media-default"></span> {{ defaultFilename }}</span>
516
									<# } else { #>
517
										<?php echo esc_attr( $this->l10n( 'no-file-selected' ) ); ?>
518
									<# } #>
519
								</figure>
520
521
								<div class="actions">
522
									<button type="button" class="button remove-button<# if ( ! field.default ) { #> hidden<# } #>"></button>
523
									<button type="button" class="button upload-button" data-label="<?php echo esc_attr( $this->l10n( 'add-file' ) ); ?>" data-alt-label="<?php echo esc_attr( $this->l10n( 'change-file' ) ); ?>" >
524
										<# if ( field.default ) { #>
525
											<?php echo esc_attr( $this->l10n( 'change-file' ) ); ?>
526
										<# } else { #>
527
											<?php echo esc_attr( $this->l10n( 'add-file' ) ); ?>
528
										<# } #>
529
									</button>
530
									<# if ( field.default.id ) { #>
531
										<input type="hidden" class="hidden-field" value="{{{ field.default.id }}}" data-field="{{{ field.id }}}" >
532
									<# } else { #>
533
										<input type="hidden" class="hidden-field" value="{{{ field.default }}}" data-field="{{{ field.id }}}" >
534
									<# } #>
535
								</div>
536
537
							<# } else if ( 'custom' === field.type ) { #>
538
539
								<# if ( field.label ) { #>
540
									<span class="customize-control-title">{{ field.label }}</span>
541
								<# } #>
542
								<# if ( field.description ) { #>
543
									<span class="description customize-control-description">{{ field.description }}</span>
544
								<# } #>
545
								<div data-field="{{{ field.id }}}">{{{ field.default }}}</div>
546
547
							<# } #>
548
549
						</div>
550
					<# }); #>
551
					<button type="button" class="button-link repeater-row-remove"><?php echo esc_attr( $this->l10n( 'remove' ) ); ?></button>
552
				</div>
553
			</li>
554
		</script>
555
		<?php
556
	}
557
558
	/**
559
	 * Validate row-labels.
560
	 *
561
	 * @access protected
562
	 * @since 3.0.0
563
	 * @param array $args {@see WP_Customize_Control::__construct}.
564
	 */
565
	protected function row_label( $args ) {
566
567
		// Validating args for row labels.
568
		if ( isset( $args['row_label'] ) && is_array( $args['row_label'] ) && ! empty( $args['row_label'] ) ) {
569
570
			// Validating row label type.
571
			if ( isset( $args['row_label']['type'] ) && ( 'text' === $args['row_label']['type'] || 'field' === $args['row_label']['type'] ) ) {
572
				$this->row_label['type'] = $args['row_label']['type'];
573
			}
574
575
			// Validating row label type.
576
			if ( isset( $args['row_label']['value'] ) && ! empty( $args['row_label']['value'] ) ) {
577
				$this->row_label['value'] = esc_attr( $args['row_label']['value'] );
578
			}
579
580
			// Validating row label field.
581
			if ( isset( $args['row_label']['field'] ) && ! empty( $args['row_label']['field'] ) && isset( $args['fields'][ esc_attr( $args['row_label']['field'] ) ] ) ) {
582
				$this->row_label['field'] = esc_attr( $args['row_label']['field'] );
583
			} else {
584
				// If from field is not set correctly, making sure standard is set as the type.
585
				$this->row_label['type'] = 'text';
586
			}
587
		}
588
	}
589
590
	/**
591
	 * Returns an array of translation strings.
592
	 *
593
	 * @access protected
594
	 * @since 3.0.0
595
	 * @param string|false $config_id The string-ID.
596
	 * @return string
597
	 */
598
	protected function l10n( $config_id = false ) {
599
		$translation_strings = array(
600
			'row'               => esc_attr__( 'row', 'kirki' ),
601
			'add-new'           => esc_attr__( 'Add new', 'kirki' ),
602
			'select-page'       => esc_attr__( 'Select a Page', 'kirki' ),
603
			/* translators: %s represents the number of rows we're limiting the repeater to allow. */
604
			'limit-rows'        => esc_attr__( 'Limit: %s rows', 'kirki' ),
605
			'hex-value'         => esc_attr__( 'Hex Value', 'kirki' ),
606
			'no-image-selected' => esc_attr__( 'No Image Selected', 'kirki' ),
607
			'remove'            => esc_attr__( 'Remove', 'kirki' ),
608
			'add-image'         => esc_attr__( 'Add Image', 'kirki' ),
609
			'change-image'      => esc_attr__( 'Change Image', 'kirki' ),
610
			'no-file-selected'  => esc_attr__( 'No File Selected', 'kirki' ),
611
			'add-file'          => esc_attr__( 'Add File', 'kirki' ),
612
			'change-file'       => esc_attr__( 'Change File', 'kirki' ),
613
		);
614
		$translation_strings = apply_filters( "kirki/{$this->kirki_config}/l10n", $translation_strings );
615
		if ( false === $config_id ) {
616
			return $translation_strings;
617
		}
618
		return $translation_strings[ $config_id ];
619
	}
620
}
621