Passed
Pull Request — master (#1889)
by Aristeides
03:44
created

Kirki_Field_Preset   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 27
rs 10
c 1
b 1
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set_type() 0 3 1
A set_preset() 0 8 2
1
<?php
2
/**
3
 * Override field methods
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.2.7
10
 */
11
12
/**
13
 * Field overrides.
14
 */
15
class Kirki_Field_Preset extends Kirki_Field_Select {
16
17
	/**
18
	 * Sets the control type.
19
	 *
20
	 * @access protected
21
	 */
22
	protected function set_type() {
23
24
		$this->type = 'kirki-select';
25
26
	}
27
28
	/**
29
	 * Set the preset.
30
	 *
31
	 * @access protected
32
	 * @since 3.0.28
33
	 */
34
	protected function set_preset() {
35
36
		// Set preset from the choices.
37
		$this->preset = $this->choices;
38
39
		// We're using a flat select.
40
		foreach ( $this->choices as $key => $args ) {
41
			$this->choices[ $key ] = $args['label'];
42
		}
43
	}
44
}
45