Completed
Push — develop ( d02e2f...d78a0c )
by Aristeides
02:28
created

Kirki_Field::set_active_callback()   C

Complexity

Conditions 7
Paths 12

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 11
nc 12
nop 0
dl 0
loc 22
rs 6.9811
c 0
b 0
f 0
1
<?php
2
/**
3
 * Creates and validates field parameters.
4
 *
5
 * @package     Kirki
6
 * @category    Core
7
 * @author      Aristeides Stathopoulos
8
 * @copyright   Copyright (c) 2016, Aristeides Stathopoulos
9
 * @license     http://opensource.org/licenses/https://opensource.org/licenses/MIT
10
 * @since       1.0
11
 */
12
13
/**
14
 * Please do not use this class directly.
15
 * You should instead extend it per-field-type.
16
 */
17
class Kirki_Field {
18
19
	/**
20
	 * The ID of the kirki_config we're using.
21
	 *
22
	 * @see Kirki_Config
23
	 * @access protected
24
	 * @var string
25
	 */
26
	protected $kirki_config = 'global';
27
28
	/**
29
	 * Thje capability required so that users can edit this field.
30
	 *
31
	 * @access protected
32
	 * @var string
33
	 */
34
	protected $capability = 'edit_theme_options';
35
36
	/**
37
	 * If we're using options instead of theme_mods
38
	 * and we want them serialized, this is the option that
39
	 * will saved in the db.
40
	 *
41
	 * @access protected
42
	 * @var string
43
	 */
44
	protected $option_name = '';
45
46
	/**
47
	 * Custom input attributes (defined as an array).
48
	 *
49
	 * @access protected
50
	 * @var array
51
	 */
52
	protected $input_attrs = array();
53
54
	/**
55
	 * Use "theme_mod" or "option".
56
	 *
57
	 * @access protected
58
	 * @var string
59
	 */
60
	protected $option_type = 'theme_mod';
61
62
	/**
63
	 * The name of this setting (id for the db).
64
	 *
65
	 * @access protected
66
	 * @var string|array
67
	 */
68
	protected $settings = '';
69
70
	/**
71
	 * Set to true if you want to disable all CSS output for this field.
72
	 *
73
	 * @access protected
74
	 * @var bool
75
	 */
76
	protected $disable_output = false;
77
78
	/**
79
	 * The field type.
80
	 *
81
	 * @access protected
82
	 * @var string
83
	 */
84
	protected $type = 'kirki-generic';
85
86
	/**
87
	 * Some fields require options to be set.
88
	 * We're whitelisting the property here
89
	 * and suggest you validate this in a child class.
90
	 *
91
	 * @access protected
92
	 * @var array
93
	 */
94
	protected $choices = array();
95
96
	/**
97
	 * Assign this field to a section.
98
	 * Fields not assigned to a section will not be displayed in the customizer.
99
	 *
100
	 * @access protected
101
	 * @var string
102
	 */
103
	protected $section = '';
104
105
	/**
106
	 * The default value for this field.
107
	 *
108
	 * @access protected
109
	 * @var string|array
110
	 */
111
	protected $default = '';
112
113
	/**
114
	 * Priority determines the position of a control inside a section.
115
	 * Lower priority numbers move the control to the top.
116
	 *
117
	 * @access protected
118
	 * @var int
119
	 */
120
	protected $priority = 10;
121
122
	/**
123
	 * Unique ID for this field.
124
	 * This is auto-calculated from the $settings argument.
125
	 *
126
	 * @access protected
127
	 * @var string
128
	 */
129
	protected $id = '';
130
131
	/**
132
	 * Use if you want to automatically generate CSS from this field's value.
133
	 *
134
	 * @see https://kirki.org/docs/arguments/output
135
	 * @access protected
136
	 * @var array
137
	 */
138
	protected $output = array();
139
140
	/**
141
	 * Use to automatically generate postMessage scripts.
142
	 * Not necessary to use if you use 'transport' => 'auto'
143
	 * and have already set an array for the 'output' argument.
144
	 *
145
	 * @see https://kirki.org/docs/arguments/js_vars
146
	 * @access protected
147
	 * @var array
148
	 */
149
	protected $js_vars = array();
150
151
	/**
152
	 * If you want to use a CSS compiler, then use this to set the variable names.
153
	 *
154
	 * @see https://kirki.org/docs/arguments/variables
155
	 * @access protected
156
	 * @var array
157
	 */
158
	protected $variables = array();
159
160
	/**
161
	 * Text that will be used in a tooltip to provide extra info for this field.
162
	 *
163
	 * @access protected
164
	 * @var string
165
	 */
166
	protected $tooltip = '';
167
168
	/**
169
	 * Whitelisting for backwards-compatibility.
170
	 *
171
	 * @access protected
172
	 * @var string
173
	 */
174
	protected $help = '';
175
176
	/**
177
	 * A custom callback to determine if the field should be visible or not.
178
	 *
179
	 * @access protected
180
	 * @var string|array
181
	 */
182
	protected $active_callback = '__return_true';
183
184
	/**
185
	 * A custom sanitize callback that will be used to properly save the values.
186
	 *
187
	 * @access protected
188
	 * @var string|array
189
	 */
190
	protected $sanitize_callback = '';
191
192
	/**
193
	 * Use 'refresh', 'postMessage' or 'auto'.
194
	 * 'auto' will automatically geberate any 'js_vars' from the 'output' argument.
195
	 *
196
	 * @access protected
197
	 * @var string
198
	 */
199
	protected $transport = 'refresh';
200
201
	/**
202
	 * Define dependencies to show/hide this field based on the values of other fields.
203
	 *
204
	 * @access protected
205
	 * @var array
206
	 */
207
	protected $required = array();
208
209
	/**
210
	 * Suggested width for cropped image.
211
	 *
212
	 * @access protected
213
	 * @var int
214
	 */
215
	protected $width = 150;
216
217
	/**
218
	 * Suggested height for cropped image.
219
	 *
220
	 * @access protected
221
	 * @var int
222
	 */
223
	protected $height = 150;
224
225
	/**
226
	 * Whether the width is flexible for cropped image.
227
	 *
228
	 * @access protected
229
	 * @var bool
230
	 */
231
	protected $flex_width = false;
232
233
	/**
234
	 * Whether the height is flexible for cropped image.
235
	 *
236
	 * @access protected
237
	 * @var bool
238
	 */
239
	protected $flex_height = false;
240
241
	/**
242
	 * Contain the settings for the repeater rows labels
243
	 *
244
	 * @access protected
245
	 * @var array
246
	 */
247
	protected $row_label = array();
248
249
	/**
250
	 * Partial Refreshes array.
251
	 *
252
	 * @access protected
253
	 * @var array
254
	 */
255
	protected $partial_refresh = array();
256
257
	/**
258
	 * Use only on image, cropped_image, upload controls.
259
	 * Limit the Media library to a specific mime type
260
	 *
261
	 * @access protected
262
	 * @var array
263
	 */
264
	protected $mime_type = '';
265
266
	/**
267
	 * Used only on repeaters.
268
	 * Contains an array of the fields.
269
	 *
270
	 * @access protected
271
	 * @var array
272
	 */
273
	protected $fields = array();
274
275
	/**
276
	 * Used by image fields.
277
	 *
278
	 * @access protected
279
	 * @var array
280
	 * @since 2.4.0
281
	 */
282
	protected $button_labels = array();
283
284
	/**
285
	 * The class constructor.
286
	 * Parses and sanitizes all field arguments.
287
	 * Then it adds the field to Kirki::$fields.
288
	 *
289
	 * @access public
290
	 * @param string $config_id    The ID of the config we want to use.
291
	 *                             Defaults to "global".
292
	 *                             Configs are handled by the Kirki_Config class.
293
	 * @param array  $args         The arguments of the field.
294
	 */
295
	public function __construct( $config_id = 'global', $args = array() ) {
296
297
		if ( isset( $args['setting'] ) && ! empty( $args['setting'] ) && ( ! isset( $args['settings'] ) || empty( $args['settings'] ) ) ) {
298
			$args['settings'] = $args['setting'];
299
			unset( $args['setting'] );
300
			error_log( 'Kirki: Typo found in field ' . $args['settings'] . ' ("setting" instead of "settings").' );
301
		}
302
303
		if ( is_string( $config_id ) ) {
304
			$args['kirki_config'] = $config_id;
305
		}
306
307
		// In case the user only provides 1 argument,
308
		// assume that the provided argument is $args and set $config_id = 'global'.
309
		if ( is_array( $config_id ) && empty( $args ) ) {
310
			$args = $config_id;
311
			$this->kirki_config = 'global';
312
		}
313
		$this->kirki_config = trim( esc_attr( $config_id ) );
314
		if ( '' === $config_id ) {
315
			$this->kirki_config = 'global';
316
		}
317
318
		// Get defaults from the class.
319
		$defaults = get_class_vars( __CLASS__ );
320
321
		// Get the config arguments, and merge them with the defaults.
322
		$config_defaults = ( isset( Kirki::$config['global'] ) ) ? Kirki::$config['global'] : array();
323
		if ( 'global' !== $this->kirki_config && isset( Kirki::$config[ $this->kirki_config ] ) ) {
324
			$config_defaults = Kirki::$config[ $this->kirki_config ];
325
		}
326
		$config_defaults = ( is_array( $config_defaults ) ) ? $config_defaults : array();
327
		foreach ( $config_defaults as $key => $value ) {
328
			if ( isset( $defaults[ $key ] ) ) {
329
				if ( ! empty( $value ) && $value != $defaults[ $key ] ) {
330
					$defaults[ $key ] = $value;
331
				}
332
			}
333
		}
334
335
		// Merge our args with the defaults.
336
		$args = wp_parse_args( $args, $defaults );
337
338
		// Set the class properties using the parsed args.
339
		foreach ( $args as $key => $value ) {
340
			$this->$key = $value;
341
		}
342
343
		// An array of whitelisted properties that don't need to be sanitized here.
344
		// Format: $key => $default_value.
345
		$whitelisted = apply_filters( 'kirki/' . $this->kirki_config . '/fields/properties_whitelist', array(
346
			'label'       => '', // This is sanitized later in the controls themselves.
347
			'description' => '', // This is sanitized later in the controls themselves.
348
			'mode'        => '', // Only used for backwards-compatibility reasons.
349
			'fields'      => array(), // Used in repeater fields.
350
			'row_label'   => array(), // Used in repeater fields.
351
		) );
352
353
		$this->set_field( $whitelisted );
354
355
	}
356
357
	/**
358
	 * Processes the field arguments
359
	 *
360
	 * @param array $whitelisted_properties Defines an array of arguments that will skip validation at this point.
361
	 */
362
	protected function set_field( $whitelisted_properties = array() ) {
363
364
		$properties = get_class_vars( __CLASS__ );
365
		// Remove any whitelisted properties from above.
366
		// These will get a free pass, completely unfiltered.
367
		foreach ( $whitelisted_properties as $key => $default_value ) {
368
			if ( isset( $properties[ $key ] ) ) {
369
				unset( $properties[ $key ] );
370
			}
371
		}
372
373
		// Some things must run before the others.
374
		$priorities = array(
375
			'option_name',
376
			'option_type',
377
			'settings',
378
		);
379
380
		foreach ( $priorities as $priority ) {
381
			if ( method_exists( $this, 'set_' . $priority ) ) {
382
				$method_name = 'set_' . $priority;
383
				$this->$method_name();
384
			}
385
		}
386
387
		// Sanitize the properties, skipping the ones run from the $priorities.
388
		foreach ( $properties as $property => $value ) {
389
			if ( in_array( $property, $priorities, true ) ) {
390
				continue;
391
			}
392
			if ( method_exists( $this, 'set_' . $property ) ) {
393
				$method_name = 'set_' . $property;
394
				$this->$method_name();
395
			}
396
		}
397
398
		// Get all arguments with their values.
399
		$args = get_class_vars( __CLASS__ );
400
		foreach ( $args as $key => $default_value ) {
401
			$args[ $key ] = $this->$key;
402
		}
403
404
		// Add the whitelisted properties through the back door.
405
		foreach ( $whitelisted_properties as $key => $default_value ) {
406
			if ( ! isset( $this->$key ) ) {
407
				$this->$key = $default_value;
408
			}
409
			$args[ $key ] = $this->$key;
410
		}
411
412
		// Add the field to the static $fields variable properly indexed.
413
		Kirki::$fields[ $this->settings ] = $args;
414
415
		if ( 'background' === $this->type ) {
416
			// Build the background fields.
417
			Kirki::$fields = Kirki_Explode_Background_Field::process_fields( Kirki::$fields );
418
		}
419
420
	}
421
422
	/**
423
	 * This allows us to process this on a field-basis
424
	 * by using sub-classes which can override this method.
425
	 *
426
	 * @access protected
427
	 */
428
	protected function set_default() {}
429
430
	/**
431
	 * Escape $kirki_config.
432
	 *
433
	 * @access protected
434
	 */
435
	protected function set_kirki_config() {
436
437
		$this->kirki_config = esc_attr( $this->kirki_config );
438
439
	}
440
441
	/**
442
	 * Escape $option_name.
443
	 *
444
	 * @access protected
445
	 */
446
	protected function set_option_name() {
447
448
		$this->option_name = esc_attr( $this->option_name );
449
450
	}
451
452
	/**
453
	 * Escape the $section.
454
	 *
455
	 * @access protected
456
	 */
457
	protected function set_section() {
458
459
		$this->section = sanitize_key( $this->section );
460
461
	}
462
463
	/**
464
	 * Escape the $section.
465
	 *
466
	 * @access protected
467
	 */
468
	protected function set_input_attrs() {
469
470
		if ( ! is_array( $this->input_attrs ) ) {
471
			$this->input_attrs = array();
472
		}
473
474
	}
475
476
	/**
477
	 * Checks the capability chosen is valid.
478
	 * If not, then falls back to 'edit_theme_options'
479
	 *
480
	 * @access protected
481
	 */
482
	protected function set_capability() {
483
		// Early exit if we're using 'edit_theme_options'.
484
		if ( 'edit_theme_options' === $this->capability ) {
485
			return;
486
		}
487
		// Escape & trim the capability.
488
		$this->capability = trim( esc_attr( $this->capability ) );
489
	}
490
491
	/**
492
	 * Make sure we're using the correct option_type
493
	 *
494
	 * @access protected
495
	 */
496
	protected function set_option_type() {
497
498
		// Take care of common typos.
499
		if ( 'options' === $this->option_type ) {
500
			$this->option_type = 'option';
501
		}
502
		// Take care of common typos.
503
		if ( 'theme_mods' === $this->option_type ) {
504
			$this->option_type = 'theme_mod';
505
		}
506
	}
507
508
	/**
509
	 * Modifications for partial refreshes.
510
	 *
511
	 * @access protected
512
	 */
513
	protected function set_partial_refresh() {
514
		if ( ! is_array( $this->partial_refresh ) ) {
515
			$this->partial_refresh = array();
516
		}
517
		foreach ( $this->partial_refresh as $id => $args ) {
518
			if ( ! is_array( $args ) || ! isset( $args['selector'] ) || ! isset( $args['render_callback'] ) || ! is_callable( $args['render_callback'] ) ) {
519
				unset( $this->partial_refresh[ $id ] );
520
				continue;
521
			}
522
		}
523
		if ( ! empty( $this->partial_refresh ) ) {
524
			$this->transport = 'postMessage';
525
		}
526
	}
527
528
	/**
529
	 * Sets the settings.
530
	 * If we're using serialized options it makes sure that settings are properly formatted.
531
	 * We'll also be escaping all setting names here for consistency.
532
	 *
533
	 * @access protected
534
	 */
535
	protected function set_settings() {
536
537
		// If settings is not an array, temporarily convert it to an array.
538
		// This is just to allow us to process everything the same way and avoid code duplication.
539
		// if settings is not an array then it will not be set as an array in the end.
540
		if ( ! is_array( $this->settings ) ) {
541
			$this->settings = array( 'kirki_placeholder_setting' => $this->settings );
542
		}
543
		$settings = array();
544
		foreach ( $this->settings as $setting_key => $setting_value ) {
545
			$settings[ sanitize_key( $setting_key ) ] = esc_attr( $setting_value );
546
			// If we're using serialized options then we need to spice this up.
547
			if ( 'option' === $this->option_type && '' !== $this->option_name && ( false === strpos( $setting_key, '[' ) ) ) {
548
				$settings[ sanitize_key( $setting_key ) ] = esc_attr( $this->option_name ) . '[' . esc_attr( $setting_value ) . ']';
549
			}
550
		}
551
		$this->settings = $settings;
552
		if ( isset( $this->settings['kirki_placeholder_setting'] ) ) {
553
			$this->settings = $this->settings['kirki_placeholder_setting'];
554
		}
555
556
	}
557
558
	/**
559
	 * Escapes the tooltip messages.
560
	 *
561
	 * @access protected
562
	 */
563
	protected function set_tooltip() {
564
565
		if ( '' !== $this->tooltip ) {
566
			$this->tooltip = wp_strip_all_tags( $this->tooltip );
567
			return;
568
		}
569
570
	}
571
572
	/**
573
	 * Sets the active_callback
574
	 * If we're using the $required argument,
575
	 * Then this is where the switch is made to our evaluation method.
576
	 *
577
	 * @access protected
578
	 */
579
	protected function set_active_callback() {
580
581
		if ( is_array( $this->active_callback ) && ! is_callable( $this->active_callback ) ) {
582
			if ( isset( $this->active_callback[0] ) ) {
583
				$this->required = $this->active_callback;
584
			}
585
		}
586
587
		if ( ! empty( $this->required ) ) {
588
			$this->active_callback = array( 'Kirki_Active_Callback', 'evaluate' );
589
			return;
590
		}
591
		// No need to proceed any further if we're using the default value.
592
		if ( '__return_true' === $this->active_callback ) {
593
			return;
594
		}
595
		// Make sure the function is callable, otherwise fallback to __return_true.
596
		if ( ! is_callable( $this->active_callback ) ) {
597
			$this->active_callback = '__return_true';
598
		}
599
600
	}
601
602
	/**
603
	 * Sets the control type.
604
	 *
605
	 * @access protected
606
	 */
607
	protected function set_type() {
608
609
		// Escape the control type (it doesn't hurt to be sure).
610
		$this->type = esc_attr( $this->type );
611
612
	}
613
614
	/**
615
	 * Sets the $id.
616
	 * Setting the ID should happen after the 'settings' sanitization.
617
	 * This way we can also properly handle cases where the option_type is set to 'option'
618
	 * and we're using an array instead of individual options.
619
	 *
620
	 * @access protected
621
	 */
622
	protected function set_id() {
623
624
		$this->id = sanitize_key( str_replace( '[', '-', str_replace( ']', '', $this->settings ) ) );
625
626
	}
627
628
	/**
629
	 * Sets the $sanitize_callback
630
	 *
631
	 * @access protected
632
	 */
633
	protected function set_sanitize_callback() {
634
635
		// If a custom sanitize_callback has been defined,
636
		// then we don't need to proceed any further.
637
		if ( ! empty( $this->sanitize_callback ) ) {
638
			return;
639
		}
640
641
		$default_callbacks = array(
642
			'kirki-multicheck'       => array( 'Kirki_Sanitize_Values', 'multicheck' ),
643
			'kirki-typography'       => array( 'Kirki_Sanitize_Values', 'typography' ),
644
		);
645
646
		if ( array_key_exists( $this->type, $default_callbacks ) ) {
647
			$this->sanitize_callback = $default_callbacks[ $this->type ];
648
		}
649
650
	}
651
652
	/**
653
	 * Sets the $choices.
654
	 *
655
	 * @access protected
656
	 */
657
	protected function set_choices() {
658
659
		if ( ! is_array( $this->choices ) ) {
660
			$this->choices = array();
661
		}
662
663
	}
664
665
	/**
666
	 * Escapes the $disable_output.
667
	 *
668
	 * @access protected
669
	 */
670
	protected function set_disable_output() {
671
672
		$this->disable_output = (bool) $this->disable_output;
673
674
	}
675
676
	/**
677
	 * Sets the $sanitize_callback
678
	 *
679
	 * @access protected
680
	 */
681
	protected function set_output() {
682
683
		if ( empty( $this->output ) ) {
684
			return;
685
		}
686
		if ( ! empty( $this->output ) && ! is_array( $this->output ) ) {
687
			$this->output = array( array( 'element' => $this->output ) );
688
		}
689
		// Convert to array of arrays if needed.
690
		if ( isset( $this->output['element'] ) ) {
691
			$this->output = array( $this->output );
692
		}
693
		$outputs = array();
694
		foreach ( $this->output as $output ) {
695
			if ( ! isset( $output['element'] ) || ( ! isset( $output['property'] ) && ! in_array( $this->type, array( 'kirki-typography', 'background' ), true ) ) ) {
696
				continue;
697
			}
698
			if ( ! isset( $output['sanitize_callback'] ) && isset( $output['callback'] ) ) {
699
				$output['sanitize_callback'] = $output['callback'];
700
			}
701
			// Convert element arrays to strings.
702
			if ( is_array( $output['element'] ) ) {
703
				$output['element'] = array_unique( $output['element'] );
704
				sort( $output['element'] );
705
				$output['element'] = implode( ',', $output['element'] );
706
			}
707
			$outputs[] = array(
708
				'element'           => $output['element'],
709
				'property'          => ( isset( $output['property'] ) ) ? $output['property'] : '',
710
				'media_query'       => ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global',
711
				'sanitize_callback' => ( isset( $output['sanitize_callback'] ) ) ? $output['sanitize_callback'] : '',
712
				'units'             => ( isset( $output['units'] ) ) ? $output['units'] : '',
713
				'prefix'            => ( isset( $output['prefix'] ) ) ? $output['prefix'] : '',
714
				'suffix'            => ( isset( $output['suffix'] ) ) ? $output['suffix'] : '',
715
				'exclude'           => ( isset( $output['exclude'] ) ) ? $output['exclude'] : false,
716
			);
717
		}
718
	}
719
720
	/**
721
	 * Sets the $js_vars
722
	 *
723
	 * @access protected
724
	 */
725
	protected function set_js_vars() {
726
727
		if ( ! is_array( $this->js_vars ) ) {
728
			$this->js_vars = array();
729
		}
730
731
		// Check if transport is set to auto.
732
		// If not, then skip the auto-calculations and exit early.
733
		if ( 'auto' !== $this->transport ) {
734
			return;
735
		}
736
737
		// Set transport to refresh initially.
738
		// Serves as a fallback in case we failt to auto-calculate js_vars.
739
		$this->transport = 'refresh';
740
741
		$js_vars = array();
742
743
		// Try to auto-generate js_vars.
744
		// First we need to check if js_vars are empty, and that output is not empty.
745
		if ( empty( $this->js_vars ) && ! empty( $this->output ) ) {
746
747
			// Start going through each item in the $output array.
748
			foreach ( $this->output as $output ) {
749
				$output['function'] = 'css';
750
751
				// If 'element' or 'property' are not defined, skip this.
752
				if ( ! isset( $output['element'] ) || ! isset( $output['property'] ) ) {
753
					continue;
754
				}
755
				if ( is_array( $output['element'] ) ) {
756
					$output['element'] = implode( ',', $output['element'] );
757
				}
758
				if ( false !== strpos( $output['element'], ':' ) ) {
759
					$output['function'] = 'style';
760
				}
761
762
				// If there's a sanitize_callback defined, skip this.
763
				if ( isset( $output['sanitize_callback'] ) && ! empty( $output['sanitize_callback'] ) ) {
764
					continue;
765
				}
766
767
				// If we got this far, it's safe to add this.
768
				$js_vars[] = $output;
769
			}
770
771
			// Did we manage to get all the items from 'output'?
772
			// If not, then we're missing something so don't add this.
773
			if ( count( $js_vars ) !== count( $this->output ) ) {
774
				return;
775
			}
776
			$this->js_vars   = $js_vars;
777
			$this->transport = 'postMessage';
778
779
		}
780
781
	}
782
783
	/**
784
	 * Sets the $variables
785
	 *
786
	 * @access protected
787
	 */
788
	protected function set_variables() {
789
		if ( ! is_array( $this->variables ) ) {
790
			$variable = ( is_string( $this->variables ) && ! empty( $this->variables ) ) ? $this->variables : false;
791
			$this->variables = array();
792
			if ( $variable && empty( $this->variables ) ) {
793
				$this->variables[0]['name'] = $variable;
794
			}
795
		}
796
	}
797
798
	/**
799
	 * This is a fallback method:
800
	 * $help has now become $tooltip, so this just migrates the data
801
	 *
802
	 * @access protected
803
	 */
804
	protected function set_help() {
805
806
		if ( '' !== $this->tooltip ) {
807
			return;
808
		}
809
		if ( '' !== $this->help ) {
810
			$this->tooltip = wp_strip_all_tags( $this->help );
811
			// $help has been deprecated
812
			$this->help = '';
813
			return;
814
		}
815
816
	}
817
818
	/**
819
	 * Sets the $transport
820
	 *
821
	 * @access protected
822
	 */
823
	protected function set_transport() {
824
825
		if ( 'postmessage' === trim( strtolower( $this->transport ) ) ) {
826
			$this->transport = 'postMessage';
827
		}
828
829
	}
830
831
	/**
832
	 * Sets the $required
833
	 *
834
	 * @access protected
835
	 */
836
	protected function set_required() {
837
838
		if ( ! is_array( $this->required ) ) {
839
			$this->required = array();
840
		}
841
842
	}
843
844
	/**
845
	 * Sets the $priority
846
	 *
847
	 * @access protected
848
	 */
849
	protected function set_priority() {
850
851
		$this->priority = absint( $this->priority );
852
853
	}
854
}
855