@@ -19,86 +19,86 @@ |
||
19 | 19 | */ |
20 | 20 | class Sortable extends Field { |
21 | 21 | |
22 | - /** |
|
23 | - * The field type. |
|
24 | - * |
|
25 | - * @access public |
|
26 | - * @since 1.0 |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - public $type = 'kirki-sortable'; |
|
22 | + /** |
|
23 | + * The field type. |
|
24 | + * |
|
25 | + * @access public |
|
26 | + * @since 1.0 |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + public $type = 'kirki-sortable'; |
|
30 | 30 | |
31 | - /** |
|
32 | - * The control class-name. |
|
33 | - * |
|
34 | - * @access protected |
|
35 | - * @since 0.1 |
|
36 | - * @var string |
|
37 | - */ |
|
38 | - protected $control_class = '\Kirki\Control\Sortable'; |
|
31 | + /** |
|
32 | + * The control class-name. |
|
33 | + * |
|
34 | + * @access protected |
|
35 | + * @since 0.1 |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + protected $control_class = '\Kirki\Control\Sortable'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Whether we should register the control class for JS-templating or not. |
|
42 | - * |
|
43 | - * @access protected |
|
44 | - * @since 0.1 |
|
45 | - * @var bool |
|
46 | - */ |
|
47 | - protected $control_has_js_template = true; |
|
40 | + /** |
|
41 | + * Whether we should register the control class for JS-templating or not. |
|
42 | + * |
|
43 | + * @access protected |
|
44 | + * @since 0.1 |
|
45 | + * @var bool |
|
46 | + */ |
|
47 | + protected $control_has_js_template = true; |
|
48 | 48 | |
49 | - /** |
|
50 | - * Filter arguments before creating the setting. |
|
51 | - * |
|
52 | - * @access public |
|
53 | - * @since 0.1 |
|
54 | - * @param array $args The field arguments. |
|
55 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - public function filter_setting_args( $args, $wp_customize ) { |
|
59 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
60 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
49 | + /** |
|
50 | + * Filter arguments before creating the setting. |
|
51 | + * |
|
52 | + * @access public |
|
53 | + * @since 0.1 |
|
54 | + * @param array $args The field arguments. |
|
55 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + public function filter_setting_args( $args, $wp_customize ) { |
|
59 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
60 | + $args = parent::filter_setting_args( $args, $wp_customize ); |
|
61 | 61 | |
62 | - // Set the sanitize-callback if none is defined. |
|
63 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
64 | - $args['sanitize_callback'] = [ $this, 'sanitize' ]; |
|
65 | - } |
|
66 | - } |
|
67 | - return $args; |
|
68 | - } |
|
62 | + // Set the sanitize-callback if none is defined. |
|
63 | + if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
64 | + $args['sanitize_callback'] = [ $this, 'sanitize' ]; |
|
65 | + } |
|
66 | + } |
|
67 | + return $args; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * Filter arguments before creating the control. |
|
72 | - * |
|
73 | - * @access public |
|
74 | - * @since 0.1 |
|
75 | - * @param array $args The field arguments. |
|
76 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
77 | - * @return array |
|
78 | - */ |
|
79 | - public function filter_control_args( $args, $wp_customize ) { |
|
80 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
81 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
82 | - $args['type'] = 'kirki-sortable'; |
|
83 | - } |
|
84 | - return $args; |
|
85 | - } |
|
70 | + /** |
|
71 | + * Filter arguments before creating the control. |
|
72 | + * |
|
73 | + * @access public |
|
74 | + * @since 0.1 |
|
75 | + * @param array $args The field arguments. |
|
76 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
77 | + * @return array |
|
78 | + */ |
|
79 | + public function filter_control_args( $args, $wp_customize ) { |
|
80 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
81 | + $args = parent::filter_control_args( $args, $wp_customize ); |
|
82 | + $args['type'] = 'kirki-sortable'; |
|
83 | + } |
|
84 | + return $args; |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * Sanitizes sortable values. |
|
89 | - * |
|
90 | - * @static |
|
91 | - * @access public |
|
92 | - * @since 1.0 |
|
93 | - * @param array $value The checkbox value. |
|
94 | - * @return array |
|
95 | - */ |
|
96 | - public function sanitize( $value = [] ) { |
|
97 | - $value = (array) $value; |
|
87 | + /** |
|
88 | + * Sanitizes sortable values. |
|
89 | + * |
|
90 | + * @static |
|
91 | + * @access public |
|
92 | + * @since 1.0 |
|
93 | + * @param array $value The checkbox value. |
|
94 | + * @return array |
|
95 | + */ |
|
96 | + public function sanitize( $value = [] ) { |
|
97 | + $value = (array) $value; |
|
98 | 98 | |
99 | - foreach ( $value as $key => $sub_value ) { |
|
100 | - $value[ $key ] = sanitize_text_field( $sub_value ); |
|
101 | - } |
|
102 | - return $value; |
|
103 | - } |
|
99 | + foreach ( $value as $key => $sub_value ) { |
|
100 | + $value[ $key ] = sanitize_text_field( $sub_value ); |
|
101 | + } |
|
102 | + return $value; |
|
103 | + } |
|
104 | 104 | } |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
56 | 56 | * @return array |
57 | 57 | */ |
58 | - public function filter_setting_args( $args, $wp_customize ) { |
|
59 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
60 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
58 | + public function filter_setting_args($args, $wp_customize) { |
|
59 | + if ($args['settings'] === $this->args['settings']) { |
|
60 | + $args = parent::filter_setting_args($args, $wp_customize); |
|
61 | 61 | |
62 | 62 | // Set the sanitize-callback if none is defined. |
63 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
64 | - $args['sanitize_callback'] = [ $this, 'sanitize' ]; |
|
63 | + if (!isset($args['sanitize_callback']) || !$args['sanitize_callback']) { |
|
64 | + $args['sanitize_callback'] = [$this, 'sanitize']; |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | return $args; |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
77 | 77 | * @return array |
78 | 78 | */ |
79 | - public function filter_control_args( $args, $wp_customize ) { |
|
80 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
81 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
79 | + public function filter_control_args($args, $wp_customize) { |
|
80 | + if ($args['settings'] === $this->args['settings']) { |
|
81 | + $args = parent::filter_control_args($args, $wp_customize); |
|
82 | 82 | $args['type'] = 'kirki-sortable'; |
83 | 83 | } |
84 | 84 | return $args; |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | * @param array $value The checkbox value. |
94 | 94 | * @return array |
95 | 95 | */ |
96 | - public function sanitize( $value = [] ) { |
|
96 | + public function sanitize($value = []) { |
|
97 | 97 | $value = (array) $value; |
98 | 98 | |
99 | - foreach ( $value as $key => $sub_value ) { |
|
100 | - $value[ $key ] = sanitize_text_field( $sub_value ); |
|
99 | + foreach ($value as $key => $sub_value) { |
|
100 | + $value[$key] = sanitize_text_field($sub_value); |
|
101 | 101 | } |
102 | 102 | return $value; |
103 | 103 | } |
@@ -18,56 +18,56 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class Sortable extends Base { |
20 | 20 | |
21 | - /** |
|
22 | - * The control type. |
|
23 | - * |
|
24 | - * @access public |
|
25 | - * @since 1.0 |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - public $type = 'kirki-sortable'; |
|
21 | + /** |
|
22 | + * The control type. |
|
23 | + * |
|
24 | + * @access public |
|
25 | + * @since 1.0 |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + public $type = 'kirki-sortable'; |
|
29 | 29 | |
30 | - /** |
|
31 | - * The version. Used in scripts & styles for cache-busting. |
|
32 | - * |
|
33 | - * @static |
|
34 | - * @access public |
|
35 | - * @since 1.0 |
|
36 | - * @var string |
|
37 | - */ |
|
38 | - public static $control_ver = '1.0'; |
|
30 | + /** |
|
31 | + * The version. Used in scripts & styles for cache-busting. |
|
32 | + * |
|
33 | + * @static |
|
34 | + * @access public |
|
35 | + * @since 1.0 |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + public static $control_ver = '1.0'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Enqueue control related scripts/styles. |
|
42 | - * |
|
43 | - * @access public |
|
44 | - * @since 1.0 |
|
45 | - * @return void |
|
46 | - */ |
|
47 | - public function enqueue() { |
|
48 | - parent::enqueue(); |
|
40 | + /** |
|
41 | + * Enqueue control related scripts/styles. |
|
42 | + * |
|
43 | + * @access public |
|
44 | + * @since 1.0 |
|
45 | + * @return void |
|
46 | + */ |
|
47 | + public function enqueue() { |
|
48 | + parent::enqueue(); |
|
49 | 49 | |
50 | - // Enqueue the script. |
|
51 | - wp_enqueue_script( 'kirki-control-sortable', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base' ], self::$control_ver, false ); |
|
50 | + // Enqueue the script. |
|
51 | + wp_enqueue_script( 'kirki-control-sortable', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base' ], self::$control_ver, false ); |
|
52 | 52 | |
53 | - // Enqueue the style. |
|
54 | - wp_enqueue_style( 'kirki-control-sortable-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver ); |
|
55 | - } |
|
53 | + // Enqueue the style. |
|
54 | + wp_enqueue_style( 'kirki-control-sortable-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver ); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * An Underscore (JS) template for this control's content (but not its container). |
|
59 | - * |
|
60 | - * Class variables for this control class are available in the `data` JS object; |
|
61 | - * export custom variables by overriding {@see WP_Customize_Control::to_json()}. |
|
62 | - * |
|
63 | - * @see WP_Customize_Control::print_template() |
|
64 | - * |
|
65 | - * @access protected |
|
66 | - * @since 1.0 |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - protected function content_template() { |
|
70 | - ?> |
|
57 | + /** |
|
58 | + * An Underscore (JS) template for this control's content (but not its container). |
|
59 | + * |
|
60 | + * Class variables for this control class are available in the `data` JS object; |
|
61 | + * export custom variables by overriding {@see WP_Customize_Control::to_json()}. |
|
62 | + * |
|
63 | + * @see WP_Customize_Control::print_template() |
|
64 | + * |
|
65 | + * @access protected |
|
66 | + * @since 1.0 |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + protected function content_template() { |
|
70 | + ?> |
|
71 | 71 | <label class='kirki-sortable'> |
72 | 72 | <span class="customize-control-title"> |
73 | 73 | {{{ data.label }}} |
@@ -98,5 +98,5 @@ discard block |
||
98 | 98 | </ul> |
99 | 99 | </label> |
100 | 100 | <?php |
101 | - } |
|
101 | + } |
|
102 | 102 | } |
@@ -48,10 +48,10 @@ |
||
48 | 48 | parent::enqueue(); |
49 | 49 | |
50 | 50 | // Enqueue the script. |
51 | - wp_enqueue_script( 'kirki-control-sortable', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base' ], self::$control_ver, false ); |
|
51 | + wp_enqueue_script('kirki-control-sortable', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.js'), ['jquery', 'customize-base'], self::$control_ver, false); |
|
52 | 52 | |
53 | 53 | // Enqueue the style. |
54 | - wp_enqueue_style( 'kirki-control-sortable-style', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], self::$control_ver ); |
|
54 | + wp_enqueue_style('kirki-control-sortable-style', URL::get_from_path(dirname(dirname(__DIR__)) . '/dist/control.css'), [], self::$control_ver); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -19,66 +19,66 @@ |
||
19 | 19 | */ |
20 | 20 | class Custom extends Field { |
21 | 21 | |
22 | - /** |
|
23 | - * The field type. |
|
24 | - * |
|
25 | - * @access public |
|
26 | - * @since 1.0 |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - public $type = 'kirki-custom'; |
|
22 | + /** |
|
23 | + * The field type. |
|
24 | + * |
|
25 | + * @access public |
|
26 | + * @since 1.0 |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + public $type = 'kirki-custom'; |
|
30 | 30 | |
31 | - /** |
|
32 | - * The control class-name. |
|
33 | - * |
|
34 | - * @access protected |
|
35 | - * @since 0.1 |
|
36 | - * @var string |
|
37 | - */ |
|
38 | - protected $control_class = '\Kirki\Control\Custom'; |
|
31 | + /** |
|
32 | + * The control class-name. |
|
33 | + * |
|
34 | + * @access protected |
|
35 | + * @since 0.1 |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + protected $control_class = '\Kirki\Control\Custom'; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Whether we should register the control class for JS-templating or not. |
|
42 | - * |
|
43 | - * @access protected |
|
44 | - * @since 0.1 |
|
45 | - * @var bool |
|
46 | - */ |
|
47 | - protected $control_has_js_template = true; |
|
40 | + /** |
|
41 | + * Whether we should register the control class for JS-templating or not. |
|
42 | + * |
|
43 | + * @access protected |
|
44 | + * @since 0.1 |
|
45 | + * @var bool |
|
46 | + */ |
|
47 | + protected $control_has_js_template = true; |
|
48 | 48 | |
49 | - /** |
|
50 | - * Filter arguments before creating the setting. |
|
51 | - * |
|
52 | - * @access public |
|
53 | - * @since 0.1 |
|
54 | - * @param array $args The field arguments. |
|
55 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - public function filter_setting_args( $args, $wp_customize ) { |
|
59 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
60 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
61 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
62 | - $args['sanitize_callback'] = '__return_null'; |
|
63 | - } |
|
64 | - } |
|
65 | - return $args; |
|
66 | - } |
|
49 | + /** |
|
50 | + * Filter arguments before creating the setting. |
|
51 | + * |
|
52 | + * @access public |
|
53 | + * @since 0.1 |
|
54 | + * @param array $args The field arguments. |
|
55 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + public function filter_setting_args( $args, $wp_customize ) { |
|
59 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
60 | + $args = parent::filter_setting_args( $args, $wp_customize ); |
|
61 | + if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
62 | + $args['sanitize_callback'] = '__return_null'; |
|
63 | + } |
|
64 | + } |
|
65 | + return $args; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * Filter arguments before creating the control. |
|
70 | - * |
|
71 | - * @access public |
|
72 | - * @since 0.1 |
|
73 | - * @param array $args The field arguments. |
|
74 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
75 | - * @return array |
|
76 | - */ |
|
77 | - public function filter_control_args( $args, $wp_customize ) { |
|
78 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
79 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
80 | - $args['type'] = 'kirki-custom'; |
|
81 | - } |
|
82 | - return $args; |
|
83 | - } |
|
68 | + /** |
|
69 | + * Filter arguments before creating the control. |
|
70 | + * |
|
71 | + * @access public |
|
72 | + * @since 0.1 |
|
73 | + * @param array $args The field arguments. |
|
74 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
75 | + * @return array |
|
76 | + */ |
|
77 | + public function filter_control_args( $args, $wp_customize ) { |
|
78 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
79 | + $args = parent::filter_control_args( $args, $wp_customize ); |
|
80 | + $args['type'] = 'kirki-custom'; |
|
81 | + } |
|
82 | + return $args; |
|
83 | + } |
|
84 | 84 | } |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
56 | 56 | * @return array |
57 | 57 | */ |
58 | - public function filter_setting_args( $args, $wp_customize ) { |
|
59 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
60 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
61 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
58 | + public function filter_setting_args($args, $wp_customize) { |
|
59 | + if ($args['settings'] === $this->args['settings']) { |
|
60 | + $args = parent::filter_setting_args($args, $wp_customize); |
|
61 | + if (!isset($args['sanitize_callback']) || !$args['sanitize_callback']) { |
|
62 | 62 | $args['sanitize_callback'] = '__return_null'; |
63 | 63 | } |
64 | 64 | } |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * @param WP_Customize_Manager $wp_customize The customizer instance. |
75 | 75 | * @return array |
76 | 76 | */ |
77 | - public function filter_control_args( $args, $wp_customize ) { |
|
78 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
79 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
77 | + public function filter_control_args($args, $wp_customize) { |
|
78 | + if ($args['settings'] === $this->args['settings']) { |
|
79 | + $args = parent::filter_control_args($args, $wp_customize); |
|
80 | 80 | $args['type'] = 'kirki-custom'; |
81 | 81 | } |
82 | 82 | return $args; |
@@ -22,43 +22,43 @@ |
||
22 | 22 | */ |
23 | 23 | class Custom extends Base { |
24 | 24 | |
25 | - /** |
|
26 | - * The control type. |
|
27 | - * |
|
28 | - * @access public |
|
29 | - * @since 1.0 |
|
30 | - * @var string |
|
31 | - */ |
|
32 | - public $type = 'kirki-custom'; |
|
25 | + /** |
|
26 | + * The control type. |
|
27 | + * |
|
28 | + * @access public |
|
29 | + * @since 1.0 |
|
30 | + * @var string |
|
31 | + */ |
|
32 | + public $type = 'kirki-custom'; |
|
33 | 33 | |
34 | - /** |
|
35 | - * An Underscore (JS) template for this control's content (but not its container). |
|
36 | - * |
|
37 | - * Class variables for this control class are available in the `data` JS object; |
|
38 | - * export custom variables by overriding {@see WP_Customize_Control::to_json()}. |
|
39 | - * |
|
40 | - * @see WP_Customize_Control::print_template() |
|
41 | - * |
|
42 | - * @access protected |
|
43 | - * @since 1.0 |
|
44 | - * @return void |
|
45 | - */ |
|
46 | - protected function content_template() { |
|
47 | - ?> |
|
34 | + /** |
|
35 | + * An Underscore (JS) template for this control's content (but not its container). |
|
36 | + * |
|
37 | + * Class variables for this control class are available in the `data` JS object; |
|
38 | + * export custom variables by overriding {@see WP_Customize_Control::to_json()}. |
|
39 | + * |
|
40 | + * @see WP_Customize_Control::print_template() |
|
41 | + * |
|
42 | + * @access protected |
|
43 | + * @since 1.0 |
|
44 | + * @return void |
|
45 | + */ |
|
46 | + protected function content_template() { |
|
47 | + ?> |
|
48 | 48 | <label> |
49 | 49 | <# if ( data.label ) { #><span class="customize-control-title">{{{ data.label }}}</span><# } #> |
50 | 50 | <# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #> |
51 | 51 | <?php |
52 | - /** |
|
53 | - * The value is defined by the developer in the field configuration as 'default'. |
|
54 | - * There is no user input on this field, it's a raw HTML/JS field and we do not sanitize it. |
|
55 | - * Do not be alarmed, this is not a security issue. |
|
56 | - * In order for someone to be able to change this they would have to have access to your filesystem. |
|
57 | - * If that happens, they can change whatever they want anyways. This field is not a concern. |
|
58 | - */ |
|
59 | - ?> |
|
52 | + /** |
|
53 | + * The value is defined by the developer in the field configuration as 'default'. |
|
54 | + * There is no user input on this field, it's a raw HTML/JS field and we do not sanitize it. |
|
55 | + * Do not be alarmed, this is not a security issue. |
|
56 | + * In order for someone to be able to change this they would have to have access to your filesystem. |
|
57 | + * If that happens, they can change whatever they want anyways. This field is not a concern. |
|
58 | + */ |
|
59 | + ?> |
|
60 | 60 | {{{ data.value }}} |
61 | 61 | </label> |
62 | 62 | <?php |
63 | - } |
|
63 | + } |
|
64 | 64 | } |
@@ -21,104 +21,104 @@ |
||
21 | 21 | */ |
22 | 22 | class Values { |
23 | 23 | |
24 | - /** |
|
25 | - * Get the value of a field. |
|
26 | - * |
|
27 | - * @static |
|
28 | - * @access public |
|
29 | - * @param string $config_id The configuration ID. @see Kirki\Compatibility\Config. |
|
30 | - * @param string $field_id The field ID. |
|
31 | - * @return string|array |
|
32 | - */ |
|
33 | - public static function get_value( $config_id = '', $field_id = '' ) { |
|
34 | - |
|
35 | - // Make sure value is defined. |
|
36 | - $value = ''; |
|
37 | - |
|
38 | - // This allows us to skip the $config_id argument. |
|
39 | - // If we skip adding a $config_id, use the 'global' configuration. |
|
40 | - if ( ( '' === $field_id ) && '' !== $config_id ) { |
|
41 | - $field_id = $config_id; |
|
42 | - $config_id = 'global'; |
|
43 | - } |
|
44 | - |
|
45 | - // If $config_id is empty, set it to 'global'. |
|
46 | - $config_id = ( '' === $config_id ) ? 'global' : $config_id; |
|
47 | - |
|
48 | - // Fallback to 'global' if $config_id is not found. |
|
49 | - if ( ! isset( Kirki::$config[ $config_id ] ) ) { |
|
50 | - $config_id = 'global'; |
|
51 | - } |
|
52 | - |
|
53 | - if ( 'theme_mod' === Kirki::$config[ $config_id ]['option_type'] ) { |
|
54 | - |
|
55 | - // We're using theme_mods so just get the value using get_theme_mod. |
|
56 | - $default_value = null; |
|
57 | - |
|
58 | - if ( isset( Kirki::$all_fields[ $field_id ] ) && isset( Kirki::$all_fields[ $field_id ]['default'] ) ) { |
|
59 | - $default_value = Kirki::$all_fields[ $field_id ]['default']; |
|
60 | - } |
|
61 | - |
|
62 | - $value = get_theme_mod( $field_id, $default_value ); |
|
63 | - |
|
64 | - return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
|
65 | - } |
|
66 | - |
|
67 | - if ( 'option' === Kirki::$config[ $config_id ]['option_type'] ) { |
|
68 | - |
|
69 | - // We're using options. |
|
70 | - if ( '' !== Kirki::$config[ $config_id ]['option_name'] ) { |
|
71 | - // Options are serialized as a single option in the db. |
|
72 | - // We'll have to get the option and then get the item from the array. |
|
73 | - $options = get_option( Kirki::$config[ $config_id ]['option_name'] ); |
|
74 | - |
|
75 | - if ( ! isset( Kirki::$all_fields[ $field_id ] ) && isset( Kirki::$all_fields[ Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']' ] ) ) { |
|
76 | - $field_id = Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']'; |
|
77 | - } |
|
78 | - |
|
79 | - $setting_modified = str_replace( ']', '', str_replace( Kirki::$config[ $config_id ]['option_name'] . '[', '', $field_id ) ); |
|
80 | - |
|
81 | - $default_value = ( isset( Kirki::$all_fields[ $field_id ] ) && isset( Kirki::$all_fields[ $field_id ]['default'] ) ) ? Kirki::$all_fields[ $field_id ]['default'] : ''; |
|
82 | - $value = ( isset( $options[ $setting_modified ] ) ) ? $options[ $setting_modified ] : $default_value; |
|
83 | - $value = maybe_unserialize( $value ); |
|
84 | - |
|
85 | - return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
|
86 | - } |
|
87 | - |
|
88 | - // Each option separately saved in the db. |
|
89 | - $value = get_option( $field_id, Kirki::$all_fields[ $field_id ]['default'] ); |
|
90 | - |
|
91 | - return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
|
92 | - |
|
93 | - } |
|
94 | - |
|
95 | - return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
|
96 | - |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Gets the value or fallsback to default. |
|
101 | - * |
|
102 | - * @static |
|
103 | - * @access public |
|
104 | - * @param array $field The field aruments. |
|
105 | - * @return string|array |
|
106 | - */ |
|
107 | - public static function get_sanitized_field_value( $field ) { |
|
108 | - $value = $field['default']; |
|
109 | - if ( ! isset( $field['option_type'] ) || 'theme_mod' === $field['option_type'] ) { |
|
110 | - $value = get_theme_mod( $field['settings'], $field['default'] ); |
|
111 | - } elseif ( isset( $field['option_type'] ) && 'option' === $field['option_type'] ) { |
|
112 | - if ( isset( $field['option_name'] ) && '' !== $field['option_name'] ) { |
|
113 | - $all_values = get_option( $field['option_name'], [] ); |
|
114 | - $sub_setting_id = str_replace( [ ']', $field['option_name'] . '[' ], '', $field['settings'] ); |
|
115 | - if ( isset( $all_values[ $sub_setting_id ] ) ) { |
|
116 | - $value = $all_values[ $sub_setting_id ]; |
|
117 | - } |
|
118 | - } else { |
|
119 | - $value = get_option( $field['settings'], $field['default'] ); |
|
120 | - } |
|
121 | - } |
|
122 | - return $value; |
|
123 | - } |
|
24 | + /** |
|
25 | + * Get the value of a field. |
|
26 | + * |
|
27 | + * @static |
|
28 | + * @access public |
|
29 | + * @param string $config_id The configuration ID. @see Kirki\Compatibility\Config. |
|
30 | + * @param string $field_id The field ID. |
|
31 | + * @return string|array |
|
32 | + */ |
|
33 | + public static function get_value( $config_id = '', $field_id = '' ) { |
|
34 | + |
|
35 | + // Make sure value is defined. |
|
36 | + $value = ''; |
|
37 | + |
|
38 | + // This allows us to skip the $config_id argument. |
|
39 | + // If we skip adding a $config_id, use the 'global' configuration. |
|
40 | + if ( ( '' === $field_id ) && '' !== $config_id ) { |
|
41 | + $field_id = $config_id; |
|
42 | + $config_id = 'global'; |
|
43 | + } |
|
44 | + |
|
45 | + // If $config_id is empty, set it to 'global'. |
|
46 | + $config_id = ( '' === $config_id ) ? 'global' : $config_id; |
|
47 | + |
|
48 | + // Fallback to 'global' if $config_id is not found. |
|
49 | + if ( ! isset( Kirki::$config[ $config_id ] ) ) { |
|
50 | + $config_id = 'global'; |
|
51 | + } |
|
52 | + |
|
53 | + if ( 'theme_mod' === Kirki::$config[ $config_id ]['option_type'] ) { |
|
54 | + |
|
55 | + // We're using theme_mods so just get the value using get_theme_mod. |
|
56 | + $default_value = null; |
|
57 | + |
|
58 | + if ( isset( Kirki::$all_fields[ $field_id ] ) && isset( Kirki::$all_fields[ $field_id ]['default'] ) ) { |
|
59 | + $default_value = Kirki::$all_fields[ $field_id ]['default']; |
|
60 | + } |
|
61 | + |
|
62 | + $value = get_theme_mod( $field_id, $default_value ); |
|
63 | + |
|
64 | + return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
|
65 | + } |
|
66 | + |
|
67 | + if ( 'option' === Kirki::$config[ $config_id ]['option_type'] ) { |
|
68 | + |
|
69 | + // We're using options. |
|
70 | + if ( '' !== Kirki::$config[ $config_id ]['option_name'] ) { |
|
71 | + // Options are serialized as a single option in the db. |
|
72 | + // We'll have to get the option and then get the item from the array. |
|
73 | + $options = get_option( Kirki::$config[ $config_id ]['option_name'] ); |
|
74 | + |
|
75 | + if ( ! isset( Kirki::$all_fields[ $field_id ] ) && isset( Kirki::$all_fields[ Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']' ] ) ) { |
|
76 | + $field_id = Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']'; |
|
77 | + } |
|
78 | + |
|
79 | + $setting_modified = str_replace( ']', '', str_replace( Kirki::$config[ $config_id ]['option_name'] . '[', '', $field_id ) ); |
|
80 | + |
|
81 | + $default_value = ( isset( Kirki::$all_fields[ $field_id ] ) && isset( Kirki::$all_fields[ $field_id ]['default'] ) ) ? Kirki::$all_fields[ $field_id ]['default'] : ''; |
|
82 | + $value = ( isset( $options[ $setting_modified ] ) ) ? $options[ $setting_modified ] : $default_value; |
|
83 | + $value = maybe_unserialize( $value ); |
|
84 | + |
|
85 | + return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
|
86 | + } |
|
87 | + |
|
88 | + // Each option separately saved in the db. |
|
89 | + $value = get_option( $field_id, Kirki::$all_fields[ $field_id ]['default'] ); |
|
90 | + |
|
91 | + return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
|
92 | + |
|
93 | + } |
|
94 | + |
|
95 | + return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
|
96 | + |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Gets the value or fallsback to default. |
|
101 | + * |
|
102 | + * @static |
|
103 | + * @access public |
|
104 | + * @param array $field The field aruments. |
|
105 | + * @return string|array |
|
106 | + */ |
|
107 | + public static function get_sanitized_field_value( $field ) { |
|
108 | + $value = $field['default']; |
|
109 | + if ( ! isset( $field['option_type'] ) || 'theme_mod' === $field['option_type'] ) { |
|
110 | + $value = get_theme_mod( $field['settings'], $field['default'] ); |
|
111 | + } elseif ( isset( $field['option_type'] ) && 'option' === $field['option_type'] ) { |
|
112 | + if ( isset( $field['option_name'] ) && '' !== $field['option_name'] ) { |
|
113 | + $all_values = get_option( $field['option_name'], [] ); |
|
114 | + $sub_setting_id = str_replace( [ ']', $field['option_name'] . '[' ], '', $field['settings'] ); |
|
115 | + if ( isset( $all_values[ $sub_setting_id ] ) ) { |
|
116 | + $value = $all_values[ $sub_setting_id ]; |
|
117 | + } |
|
118 | + } else { |
|
119 | + $value = get_option( $field['settings'], $field['default'] ); |
|
120 | + } |
|
121 | + } |
|
122 | + return $value; |
|
123 | + } |
|
124 | 124 | } |
@@ -30,69 +30,69 @@ discard block |
||
30 | 30 | * @param string $field_id The field ID. |
31 | 31 | * @return string|array |
32 | 32 | */ |
33 | - public static function get_value( $config_id = '', $field_id = '' ) { |
|
33 | + public static function get_value($config_id = '', $field_id = '') { |
|
34 | 34 | |
35 | 35 | // Make sure value is defined. |
36 | 36 | $value = ''; |
37 | 37 | |
38 | 38 | // This allows us to skip the $config_id argument. |
39 | 39 | // If we skip adding a $config_id, use the 'global' configuration. |
40 | - if ( ( '' === $field_id ) && '' !== $config_id ) { |
|
40 | + if (('' === $field_id) && '' !== $config_id) { |
|
41 | 41 | $field_id = $config_id; |
42 | 42 | $config_id = 'global'; |
43 | 43 | } |
44 | 44 | |
45 | 45 | // If $config_id is empty, set it to 'global'. |
46 | - $config_id = ( '' === $config_id ) ? 'global' : $config_id; |
|
46 | + $config_id = ('' === $config_id) ? 'global' : $config_id; |
|
47 | 47 | |
48 | 48 | // Fallback to 'global' if $config_id is not found. |
49 | - if ( ! isset( Kirki::$config[ $config_id ] ) ) { |
|
49 | + if (!isset(Kirki::$config[$config_id])) { |
|
50 | 50 | $config_id = 'global'; |
51 | 51 | } |
52 | 52 | |
53 | - if ( 'theme_mod' === Kirki::$config[ $config_id ]['option_type'] ) { |
|
53 | + if ('theme_mod' === Kirki::$config[$config_id]['option_type']) { |
|
54 | 54 | |
55 | 55 | // We're using theme_mods so just get the value using get_theme_mod. |
56 | 56 | $default_value = null; |
57 | 57 | |
58 | - if ( isset( Kirki::$all_fields[ $field_id ] ) && isset( Kirki::$all_fields[ $field_id ]['default'] ) ) { |
|
59 | - $default_value = Kirki::$all_fields[ $field_id ]['default']; |
|
58 | + if (isset(Kirki::$all_fields[$field_id]) && isset(Kirki::$all_fields[$field_id]['default'])) { |
|
59 | + $default_value = Kirki::$all_fields[$field_id]['default']; |
|
60 | 60 | } |
61 | 61 | |
62 | - $value = get_theme_mod( $field_id, $default_value ); |
|
62 | + $value = get_theme_mod($field_id, $default_value); |
|
63 | 63 | |
64 | - return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
|
64 | + return apply_filters('kirki_values_get_value', $value, $field_id); |
|
65 | 65 | } |
66 | 66 | |
67 | - if ( 'option' === Kirki::$config[ $config_id ]['option_type'] ) { |
|
67 | + if ('option' === Kirki::$config[$config_id]['option_type']) { |
|
68 | 68 | |
69 | 69 | // We're using options. |
70 | - if ( '' !== Kirki::$config[ $config_id ]['option_name'] ) { |
|
70 | + if ('' !== Kirki::$config[$config_id]['option_name']) { |
|
71 | 71 | // Options are serialized as a single option in the db. |
72 | 72 | // We'll have to get the option and then get the item from the array. |
73 | - $options = get_option( Kirki::$config[ $config_id ]['option_name'] ); |
|
73 | + $options = get_option(Kirki::$config[$config_id]['option_name']); |
|
74 | 74 | |
75 | - if ( ! isset( Kirki::$all_fields[ $field_id ] ) && isset( Kirki::$all_fields[ Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']' ] ) ) { |
|
76 | - $field_id = Kirki::$config[ $config_id ]['option_name'] . '[' . $field_id . ']'; |
|
75 | + if (!isset(Kirki::$all_fields[$field_id]) && isset(Kirki::$all_fields[Kirki::$config[$config_id]['option_name'] . '[' . $field_id . ']'])) { |
|
76 | + $field_id = Kirki::$config[$config_id]['option_name'] . '[' . $field_id . ']'; |
|
77 | 77 | } |
78 | 78 | |
79 | - $setting_modified = str_replace( ']', '', str_replace( Kirki::$config[ $config_id ]['option_name'] . '[', '', $field_id ) ); |
|
79 | + $setting_modified = str_replace(']', '', str_replace(Kirki::$config[$config_id]['option_name'] . '[', '', $field_id)); |
|
80 | 80 | |
81 | - $default_value = ( isset( Kirki::$all_fields[ $field_id ] ) && isset( Kirki::$all_fields[ $field_id ]['default'] ) ) ? Kirki::$all_fields[ $field_id ]['default'] : ''; |
|
82 | - $value = ( isset( $options[ $setting_modified ] ) ) ? $options[ $setting_modified ] : $default_value; |
|
83 | - $value = maybe_unserialize( $value ); |
|
81 | + $default_value = (isset(Kirki::$all_fields[$field_id]) && isset(Kirki::$all_fields[$field_id]['default'])) ? Kirki::$all_fields[$field_id]['default'] : ''; |
|
82 | + $value = (isset($options[$setting_modified])) ? $options[$setting_modified] : $default_value; |
|
83 | + $value = maybe_unserialize($value); |
|
84 | 84 | |
85 | - return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
|
85 | + return apply_filters('kirki_values_get_value', $value, $field_id); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | // Each option separately saved in the db. |
89 | - $value = get_option( $field_id, Kirki::$all_fields[ $field_id ]['default'] ); |
|
89 | + $value = get_option($field_id, Kirki::$all_fields[$field_id]['default']); |
|
90 | 90 | |
91 | - return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
|
91 | + return apply_filters('kirki_values_get_value', $value, $field_id); |
|
92 | 92 | |
93 | 93 | } |
94 | 94 | |
95 | - return apply_filters( 'kirki_values_get_value', $value, $field_id ); |
|
95 | + return apply_filters('kirki_values_get_value', $value, $field_id); |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
@@ -104,19 +104,19 @@ discard block |
||
104 | 104 | * @param array $field The field aruments. |
105 | 105 | * @return string|array |
106 | 106 | */ |
107 | - public static function get_sanitized_field_value( $field ) { |
|
107 | + public static function get_sanitized_field_value($field) { |
|
108 | 108 | $value = $field['default']; |
109 | - if ( ! isset( $field['option_type'] ) || 'theme_mod' === $field['option_type'] ) { |
|
110 | - $value = get_theme_mod( $field['settings'], $field['default'] ); |
|
111 | - } elseif ( isset( $field['option_type'] ) && 'option' === $field['option_type'] ) { |
|
112 | - if ( isset( $field['option_name'] ) && '' !== $field['option_name'] ) { |
|
113 | - $all_values = get_option( $field['option_name'], [] ); |
|
114 | - $sub_setting_id = str_replace( [ ']', $field['option_name'] . '[' ], '', $field['settings'] ); |
|
115 | - if ( isset( $all_values[ $sub_setting_id ] ) ) { |
|
116 | - $value = $all_values[ $sub_setting_id ]; |
|
109 | + if (!isset($field['option_type']) || 'theme_mod' === $field['option_type']) { |
|
110 | + $value = get_theme_mod($field['settings'], $field['default']); |
|
111 | + } elseif (isset($field['option_type']) && 'option' === $field['option_type']) { |
|
112 | + if (isset($field['option_name']) && '' !== $field['option_name']) { |
|
113 | + $all_values = get_option($field['option_name'], []); |
|
114 | + $sub_setting_id = str_replace([']', $field['option_name'] . '['], '', $field['settings']); |
|
115 | + if (isset($all_values[$sub_setting_id])) { |
|
116 | + $value = $all_values[$sub_setting_id]; |
|
117 | 117 | } |
118 | 118 | } else { |
119 | - $value = get_option( $field['settings'], $field['default'] ); |
|
119 | + $value = get_option($field['settings'], $field['default']); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | return $value; |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | // Exit if accessed directly. |
22 | 22 | if ( ! defined( 'ABSPATH' ) ) { |
23 | - exit; |
|
23 | + exit; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
@@ -31,274 +31,274 @@ discard block |
||
31 | 31 | */ |
32 | 32 | class Kirki extends Init { |
33 | 33 | |
34 | - /** |
|
35 | - * URL to the Kirki folder. |
|
36 | - * |
|
37 | - * @deprecated This is no longer used. Only kept here for backwards compatibility to avoid fatal errors. |
|
38 | - * @static |
|
39 | - * @access public |
|
40 | - * @var string |
|
41 | - */ |
|
42 | - public static $url; |
|
43 | - |
|
44 | - /** |
|
45 | - * An array containing all configurations. |
|
46 | - * |
|
47 | - * @static |
|
48 | - * @access public |
|
49 | - * @var array |
|
50 | - */ |
|
51 | - public static $config = []; |
|
52 | - |
|
53 | - /** |
|
54 | - * An array containing all fields for compatibility purpose. |
|
55 | - * |
|
56 | - * @static |
|
57 | - * @access public |
|
58 | - * @var array |
|
59 | - */ |
|
60 | - public static $fields = []; |
|
61 | - |
|
62 | - /** |
|
63 | - * An array containing all fields. |
|
64 | - * |
|
65 | - * @static |
|
66 | - * @access public |
|
67 | - * @var array |
|
68 | - */ |
|
69 | - public static $all_fields = []; |
|
70 | - |
|
71 | - /** |
|
72 | - * An array containing all controls to be removed. |
|
73 | - * |
|
74 | - * @static |
|
75 | - * @access public |
|
76 | - * @since 3.0.17 |
|
77 | - * @var array |
|
78 | - */ |
|
79 | - public static $controls_to_remove = []; |
|
80 | - |
|
81 | - /** |
|
82 | - * Modules object. |
|
83 | - * |
|
84 | - * @access public |
|
85 | - * @since 3.0.0 |
|
86 | - * @var object |
|
87 | - */ |
|
88 | - public $modules; |
|
89 | - |
|
90 | - /** |
|
91 | - * Get the value of an option from the db. |
|
92 | - * |
|
93 | - * @static |
|
94 | - * @access public |
|
95 | - * @param string $config_id The ID of the configuration corresponding to this field. |
|
96 | - * @param string $field_id The field_id (defined as 'settings' in the field arguments). |
|
97 | - * @return mixed The saved value of the field. |
|
98 | - */ |
|
99 | - public static function get_option( $config_id = '', $field_id = '' ) { |
|
100 | - |
|
101 | - return Values::get_value( $config_id, $field_id ); |
|
102 | - |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * Sets the configuration options. |
|
107 | - * |
|
108 | - * @static |
|
109 | - * @access public |
|
110 | - * @param string $config_id The configuration ID. |
|
111 | - * @param array $args The configuration options. |
|
112 | - */ |
|
113 | - public static function add_config( $config_id, $args = [] ) { |
|
114 | - |
|
115 | - $config = Config::get_instance( $config_id, $args ); |
|
116 | - $config_args = $config->get_config(); |
|
117 | - |
|
118 | - self::$config[ $config_args['id'] ] = $config_args; |
|
119 | - |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Create a new panel. |
|
124 | - * |
|
125 | - * @static |
|
126 | - * @access public |
|
127 | - * @param string $id The ID for this panel. |
|
128 | - * @param array $args The panel arguments. |
|
129 | - */ |
|
130 | - public static function add_panel( $id = '', $args = [] ) { |
|
131 | - |
|
132 | - new \Kirki\Panel( $id, $args ); |
|
133 | - |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Remove a panel. |
|
138 | - * |
|
139 | - * @static |
|
140 | - * @access public |
|
141 | - * @since 3.0.17 |
|
142 | - * @param string $id The ID for this panel. |
|
143 | - */ |
|
144 | - public static function remove_panel( $id = '' ) { |
|
145 | - |
|
146 | - $panel = new \Kirki\Panel( $id ); |
|
147 | - $panel->remove(); |
|
148 | - |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * Create a new section. |
|
153 | - * |
|
154 | - * @static |
|
155 | - * @access public |
|
156 | - * @param string $id The ID for this section. |
|
157 | - * @param array $args The section arguments. |
|
158 | - */ |
|
159 | - public static function add_section( $id, $args ) { |
|
160 | - |
|
161 | - new \Kirki\Section( $id, $args ); |
|
162 | - |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Remove a section. |
|
167 | - * |
|
168 | - * @static |
|
169 | - * @access public |
|
170 | - * @since 3.0.17 |
|
171 | - * @param string $id The ID for this section. |
|
172 | - */ |
|
173 | - public static function remove_section( $id = '' ) { |
|
174 | - |
|
175 | - $section = new \Kirki\Section( $id, $args ); |
|
176 | - $section->remove(); |
|
177 | - |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * Create a new field. |
|
182 | - * |
|
183 | - * @static |
|
184 | - * @access public |
|
185 | - * @param string $config_id The configuration ID for this field. |
|
186 | - * @param array $args The field arguments. |
|
187 | - */ |
|
188 | - public static function add_field( $config_id, $args = [] ) { |
|
189 | - |
|
190 | - if ( doing_action( 'customize_register' ) ) { |
|
191 | - _doing_it_wrong( __METHOD__, esc_html__( 'Kirki fields should not be added on customize_register. Please add them directly, or on init.', 'kirki' ), '3.0.10' ); |
|
192 | - } |
|
193 | - |
|
194 | - parent::maybe_show_fontawesome_nag( $args ); |
|
195 | - |
|
196 | - // Early exit if 'type' is not defined. |
|
197 | - if ( ! isset( $args['type'] ) ) { |
|
198 | - return; |
|
199 | - } |
|
200 | - |
|
201 | - $args = self::migrate_css_vars( $args ); |
|
202 | - |
|
203 | - $str = str_replace( [ '-', '_' ], ' ', $args['type'] ); |
|
204 | - $classname = '\Kirki\Field\\' . str_replace( ' ', '_', ucwords( $str ) ); |
|
205 | - |
|
206 | - $config = Config::get_instance( $config_id )->get_config(); |
|
207 | - $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : $config_id; |
|
208 | - |
|
209 | - unset( $config['id'] ); |
|
210 | - |
|
211 | - $args = wp_parse_args( $args, $config ); |
|
212 | - |
|
213 | - if ( class_exists( $classname ) ) { |
|
214 | - unset( $args['type'] ); |
|
215 | - new $classname( $args ); |
|
216 | - return; |
|
217 | - } |
|
218 | - |
|
219 | - new Field( $config_id, $args ); |
|
220 | - |
|
221 | - } |
|
222 | - |
|
223 | - /** |
|
224 | - * Remove a control. |
|
225 | - * |
|
226 | - * @static |
|
227 | - * @access public |
|
228 | - * @since 3.0.17 |
|
229 | - * @param string $id The field ID. |
|
230 | - */ |
|
231 | - public static function remove_control( $id ) { |
|
232 | - |
|
233 | - if ( ! in_array( $id, self::$controls_to_remove, true ) ) { |
|
234 | - self::$controls_to_remove[] = $id; |
|
235 | - } |
|
236 | - |
|
237 | - } |
|
238 | - |
|
239 | - /** |
|
240 | - * Gets a parameter for a config-id. |
|
241 | - * |
|
242 | - * @static |
|
243 | - * @access public |
|
244 | - * @since 3.0.10 |
|
245 | - * @param string $id The config-ID. |
|
246 | - * @param string $param The parameter we want. |
|
247 | - * @return string |
|
248 | - */ |
|
249 | - public static function get_config_param( $id, $param ) { |
|
250 | - |
|
251 | - if ( ! isset( self::$config[ $id ] ) || ! isset( self::$config[ $id ][ $param ] ) ) { |
|
252 | - return ''; |
|
253 | - } |
|
254 | - |
|
255 | - return self::$config[ $id ][ $param ]; |
|
256 | - |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Migrate css-variables to output argument. |
|
261 | - * |
|
262 | - * This only exists for backwards-compatibility with the deprecated css-vars argument. |
|
263 | - * |
|
264 | - * @static |
|
265 | - * @since 4.0 |
|
266 | - * @param array $args The field arguments. |
|
267 | - * @return array |
|
268 | - */ |
|
269 | - private static function migrate_css_vars( $args ) { |
|
270 | - |
|
271 | - // Convert css_vars to output args. |
|
272 | - if ( isset( $args['css_vars'] ) ) { |
|
273 | - |
|
274 | - if ( isset( $args['transport'] ) && 'postMessage' === $args['transport'] ) { |
|
275 | - $args['transport'] = 'auto'; |
|
276 | - } |
|
277 | - |
|
278 | - // Convert to properly-formatted arrays. |
|
279 | - $args['css_vars'] = (array) $args['css_vars']; |
|
280 | - |
|
281 | - if ( isset( $args['css_vars'][0] ) && is_string( $args['css_vars'][0] ) ) { |
|
282 | - $args['css_vars'] = [ $args['css_vars'] ]; |
|
283 | - } |
|
284 | - |
|
285 | - foreach ( $args['css_vars'] as $css_var ) { |
|
286 | - $output = [ |
|
287 | - 'element' => ':root', |
|
288 | - 'property' => $css_var[0], |
|
289 | - ]; |
|
290 | - if ( isset( $css_var[1] ) ) { |
|
291 | - $output['value_pattern'] = $css_var[1]; |
|
292 | - } |
|
293 | - if ( isset( $css_var[2] ) ) { |
|
294 | - $output['choice'] = $css_var[2]; |
|
295 | - } |
|
296 | - $args['output'][] = $output; |
|
297 | - } |
|
298 | - } |
|
299 | - |
|
300 | - return $args; |
|
301 | - |
|
302 | - } |
|
34 | + /** |
|
35 | + * URL to the Kirki folder. |
|
36 | + * |
|
37 | + * @deprecated This is no longer used. Only kept here for backwards compatibility to avoid fatal errors. |
|
38 | + * @static |
|
39 | + * @access public |
|
40 | + * @var string |
|
41 | + */ |
|
42 | + public static $url; |
|
43 | + |
|
44 | + /** |
|
45 | + * An array containing all configurations. |
|
46 | + * |
|
47 | + * @static |
|
48 | + * @access public |
|
49 | + * @var array |
|
50 | + */ |
|
51 | + public static $config = []; |
|
52 | + |
|
53 | + /** |
|
54 | + * An array containing all fields for compatibility purpose. |
|
55 | + * |
|
56 | + * @static |
|
57 | + * @access public |
|
58 | + * @var array |
|
59 | + */ |
|
60 | + public static $fields = []; |
|
61 | + |
|
62 | + /** |
|
63 | + * An array containing all fields. |
|
64 | + * |
|
65 | + * @static |
|
66 | + * @access public |
|
67 | + * @var array |
|
68 | + */ |
|
69 | + public static $all_fields = []; |
|
70 | + |
|
71 | + /** |
|
72 | + * An array containing all controls to be removed. |
|
73 | + * |
|
74 | + * @static |
|
75 | + * @access public |
|
76 | + * @since 3.0.17 |
|
77 | + * @var array |
|
78 | + */ |
|
79 | + public static $controls_to_remove = []; |
|
80 | + |
|
81 | + /** |
|
82 | + * Modules object. |
|
83 | + * |
|
84 | + * @access public |
|
85 | + * @since 3.0.0 |
|
86 | + * @var object |
|
87 | + */ |
|
88 | + public $modules; |
|
89 | + |
|
90 | + /** |
|
91 | + * Get the value of an option from the db. |
|
92 | + * |
|
93 | + * @static |
|
94 | + * @access public |
|
95 | + * @param string $config_id The ID of the configuration corresponding to this field. |
|
96 | + * @param string $field_id The field_id (defined as 'settings' in the field arguments). |
|
97 | + * @return mixed The saved value of the field. |
|
98 | + */ |
|
99 | + public static function get_option( $config_id = '', $field_id = '' ) { |
|
100 | + |
|
101 | + return Values::get_value( $config_id, $field_id ); |
|
102 | + |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * Sets the configuration options. |
|
107 | + * |
|
108 | + * @static |
|
109 | + * @access public |
|
110 | + * @param string $config_id The configuration ID. |
|
111 | + * @param array $args The configuration options. |
|
112 | + */ |
|
113 | + public static function add_config( $config_id, $args = [] ) { |
|
114 | + |
|
115 | + $config = Config::get_instance( $config_id, $args ); |
|
116 | + $config_args = $config->get_config(); |
|
117 | + |
|
118 | + self::$config[ $config_args['id'] ] = $config_args; |
|
119 | + |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * Create a new panel. |
|
124 | + * |
|
125 | + * @static |
|
126 | + * @access public |
|
127 | + * @param string $id The ID for this panel. |
|
128 | + * @param array $args The panel arguments. |
|
129 | + */ |
|
130 | + public static function add_panel( $id = '', $args = [] ) { |
|
131 | + |
|
132 | + new \Kirki\Panel( $id, $args ); |
|
133 | + |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Remove a panel. |
|
138 | + * |
|
139 | + * @static |
|
140 | + * @access public |
|
141 | + * @since 3.0.17 |
|
142 | + * @param string $id The ID for this panel. |
|
143 | + */ |
|
144 | + public static function remove_panel( $id = '' ) { |
|
145 | + |
|
146 | + $panel = new \Kirki\Panel( $id ); |
|
147 | + $panel->remove(); |
|
148 | + |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * Create a new section. |
|
153 | + * |
|
154 | + * @static |
|
155 | + * @access public |
|
156 | + * @param string $id The ID for this section. |
|
157 | + * @param array $args The section arguments. |
|
158 | + */ |
|
159 | + public static function add_section( $id, $args ) { |
|
160 | + |
|
161 | + new \Kirki\Section( $id, $args ); |
|
162 | + |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Remove a section. |
|
167 | + * |
|
168 | + * @static |
|
169 | + * @access public |
|
170 | + * @since 3.0.17 |
|
171 | + * @param string $id The ID for this section. |
|
172 | + */ |
|
173 | + public static function remove_section( $id = '' ) { |
|
174 | + |
|
175 | + $section = new \Kirki\Section( $id, $args ); |
|
176 | + $section->remove(); |
|
177 | + |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * Create a new field. |
|
182 | + * |
|
183 | + * @static |
|
184 | + * @access public |
|
185 | + * @param string $config_id The configuration ID for this field. |
|
186 | + * @param array $args The field arguments. |
|
187 | + */ |
|
188 | + public static function add_field( $config_id, $args = [] ) { |
|
189 | + |
|
190 | + if ( doing_action( 'customize_register' ) ) { |
|
191 | + _doing_it_wrong( __METHOD__, esc_html__( 'Kirki fields should not be added on customize_register. Please add them directly, or on init.', 'kirki' ), '3.0.10' ); |
|
192 | + } |
|
193 | + |
|
194 | + parent::maybe_show_fontawesome_nag( $args ); |
|
195 | + |
|
196 | + // Early exit if 'type' is not defined. |
|
197 | + if ( ! isset( $args['type'] ) ) { |
|
198 | + return; |
|
199 | + } |
|
200 | + |
|
201 | + $args = self::migrate_css_vars( $args ); |
|
202 | + |
|
203 | + $str = str_replace( [ '-', '_' ], ' ', $args['type'] ); |
|
204 | + $classname = '\Kirki\Field\\' . str_replace( ' ', '_', ucwords( $str ) ); |
|
205 | + |
|
206 | + $config = Config::get_instance( $config_id )->get_config(); |
|
207 | + $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : $config_id; |
|
208 | + |
|
209 | + unset( $config['id'] ); |
|
210 | + |
|
211 | + $args = wp_parse_args( $args, $config ); |
|
212 | + |
|
213 | + if ( class_exists( $classname ) ) { |
|
214 | + unset( $args['type'] ); |
|
215 | + new $classname( $args ); |
|
216 | + return; |
|
217 | + } |
|
218 | + |
|
219 | + new Field( $config_id, $args ); |
|
220 | + |
|
221 | + } |
|
222 | + |
|
223 | + /** |
|
224 | + * Remove a control. |
|
225 | + * |
|
226 | + * @static |
|
227 | + * @access public |
|
228 | + * @since 3.0.17 |
|
229 | + * @param string $id The field ID. |
|
230 | + */ |
|
231 | + public static function remove_control( $id ) { |
|
232 | + |
|
233 | + if ( ! in_array( $id, self::$controls_to_remove, true ) ) { |
|
234 | + self::$controls_to_remove[] = $id; |
|
235 | + } |
|
236 | + |
|
237 | + } |
|
238 | + |
|
239 | + /** |
|
240 | + * Gets a parameter for a config-id. |
|
241 | + * |
|
242 | + * @static |
|
243 | + * @access public |
|
244 | + * @since 3.0.10 |
|
245 | + * @param string $id The config-ID. |
|
246 | + * @param string $param The parameter we want. |
|
247 | + * @return string |
|
248 | + */ |
|
249 | + public static function get_config_param( $id, $param ) { |
|
250 | + |
|
251 | + if ( ! isset( self::$config[ $id ] ) || ! isset( self::$config[ $id ][ $param ] ) ) { |
|
252 | + return ''; |
|
253 | + } |
|
254 | + |
|
255 | + return self::$config[ $id ][ $param ]; |
|
256 | + |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Migrate css-variables to output argument. |
|
261 | + * |
|
262 | + * This only exists for backwards-compatibility with the deprecated css-vars argument. |
|
263 | + * |
|
264 | + * @static |
|
265 | + * @since 4.0 |
|
266 | + * @param array $args The field arguments. |
|
267 | + * @return array |
|
268 | + */ |
|
269 | + private static function migrate_css_vars( $args ) { |
|
270 | + |
|
271 | + // Convert css_vars to output args. |
|
272 | + if ( isset( $args['css_vars'] ) ) { |
|
273 | + |
|
274 | + if ( isset( $args['transport'] ) && 'postMessage' === $args['transport'] ) { |
|
275 | + $args['transport'] = 'auto'; |
|
276 | + } |
|
277 | + |
|
278 | + // Convert to properly-formatted arrays. |
|
279 | + $args['css_vars'] = (array) $args['css_vars']; |
|
280 | + |
|
281 | + if ( isset( $args['css_vars'][0] ) && is_string( $args['css_vars'][0] ) ) { |
|
282 | + $args['css_vars'] = [ $args['css_vars'] ]; |
|
283 | + } |
|
284 | + |
|
285 | + foreach ( $args['css_vars'] as $css_var ) { |
|
286 | + $output = [ |
|
287 | + 'element' => ':root', |
|
288 | + 'property' => $css_var[0], |
|
289 | + ]; |
|
290 | + if ( isset( $css_var[1] ) ) { |
|
291 | + $output['value_pattern'] = $css_var[1]; |
|
292 | + } |
|
293 | + if ( isset( $css_var[2] ) ) { |
|
294 | + $output['choice'] = $css_var[2]; |
|
295 | + } |
|
296 | + $args['output'][] = $output; |
|
297 | + } |
|
298 | + } |
|
299 | + |
|
300 | + return $args; |
|
301 | + |
|
302 | + } |
|
303 | 303 | |
304 | 304 | } |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | use Kirki\Compatibility\Field; |
20 | 20 | |
21 | 21 | // Exit if accessed directly. |
22 | -if ( ! defined( 'ABSPATH' ) ) { |
|
22 | +if (!defined('ABSPATH')) { |
|
23 | 23 | exit; |
24 | 24 | } |
25 | 25 | |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | * @param string $field_id The field_id (defined as 'settings' in the field arguments). |
97 | 97 | * @return mixed The saved value of the field. |
98 | 98 | */ |
99 | - public static function get_option( $config_id = '', $field_id = '' ) { |
|
99 | + public static function get_option($config_id = '', $field_id = '') { |
|
100 | 100 | |
101 | - return Values::get_value( $config_id, $field_id ); |
|
101 | + return Values::get_value($config_id, $field_id); |
|
102 | 102 | |
103 | 103 | } |
104 | 104 | |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | * @param string $config_id The configuration ID. |
111 | 111 | * @param array $args The configuration options. |
112 | 112 | */ |
113 | - public static function add_config( $config_id, $args = [] ) { |
|
113 | + public static function add_config($config_id, $args = []) { |
|
114 | 114 | |
115 | - $config = Config::get_instance( $config_id, $args ); |
|
115 | + $config = Config::get_instance($config_id, $args); |
|
116 | 116 | $config_args = $config->get_config(); |
117 | 117 | |
118 | - self::$config[ $config_args['id'] ] = $config_args; |
|
118 | + self::$config[$config_args['id']] = $config_args; |
|
119 | 119 | |
120 | 120 | } |
121 | 121 | |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | * @param string $id The ID for this panel. |
128 | 128 | * @param array $args The panel arguments. |
129 | 129 | */ |
130 | - public static function add_panel( $id = '', $args = [] ) { |
|
130 | + public static function add_panel($id = '', $args = []) { |
|
131 | 131 | |
132 | - new \Kirki\Panel( $id, $args ); |
|
132 | + new \Kirki\Panel($id, $args); |
|
133 | 133 | |
134 | 134 | } |
135 | 135 | |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | * @since 3.0.17 |
142 | 142 | * @param string $id The ID for this panel. |
143 | 143 | */ |
144 | - public static function remove_panel( $id = '' ) { |
|
144 | + public static function remove_panel($id = '') { |
|
145 | 145 | |
146 | - $panel = new \Kirki\Panel( $id ); |
|
146 | + $panel = new \Kirki\Panel($id); |
|
147 | 147 | $panel->remove(); |
148 | 148 | |
149 | 149 | } |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | * @param string $id The ID for this section. |
157 | 157 | * @param array $args The section arguments. |
158 | 158 | */ |
159 | - public static function add_section( $id, $args ) { |
|
159 | + public static function add_section($id, $args) { |
|
160 | 160 | |
161 | - new \Kirki\Section( $id, $args ); |
|
161 | + new \Kirki\Section($id, $args); |
|
162 | 162 | |
163 | 163 | } |
164 | 164 | |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | * @since 3.0.17 |
171 | 171 | * @param string $id The ID for this section. |
172 | 172 | */ |
173 | - public static function remove_section( $id = '' ) { |
|
173 | + public static function remove_section($id = '') { |
|
174 | 174 | |
175 | - $section = new \Kirki\Section( $id, $args ); |
|
175 | + $section = new \Kirki\Section($id, $args); |
|
176 | 176 | $section->remove(); |
177 | 177 | |
178 | 178 | } |
@@ -185,38 +185,38 @@ discard block |
||
185 | 185 | * @param string $config_id The configuration ID for this field. |
186 | 186 | * @param array $args The field arguments. |
187 | 187 | */ |
188 | - public static function add_field( $config_id, $args = [] ) { |
|
188 | + public static function add_field($config_id, $args = []) { |
|
189 | 189 | |
190 | - if ( doing_action( 'customize_register' ) ) { |
|
191 | - _doing_it_wrong( __METHOD__, esc_html__( 'Kirki fields should not be added on customize_register. Please add them directly, or on init.', 'kirki' ), '3.0.10' ); |
|
190 | + if (doing_action('customize_register')) { |
|
191 | + _doing_it_wrong(__METHOD__, esc_html__('Kirki fields should not be added on customize_register. Please add them directly, or on init.', 'kirki'), '3.0.10'); |
|
192 | 192 | } |
193 | 193 | |
194 | - parent::maybe_show_fontawesome_nag( $args ); |
|
194 | + parent::maybe_show_fontawesome_nag($args); |
|
195 | 195 | |
196 | 196 | // Early exit if 'type' is not defined. |
197 | - if ( ! isset( $args['type'] ) ) { |
|
197 | + if (!isset($args['type'])) { |
|
198 | 198 | return; |
199 | 199 | } |
200 | 200 | |
201 | - $args = self::migrate_css_vars( $args ); |
|
201 | + $args = self::migrate_css_vars($args); |
|
202 | 202 | |
203 | - $str = str_replace( [ '-', '_' ], ' ', $args['type'] ); |
|
204 | - $classname = '\Kirki\Field\\' . str_replace( ' ', '_', ucwords( $str ) ); |
|
203 | + $str = str_replace(['-', '_'], ' ', $args['type']); |
|
204 | + $classname = '\Kirki\Field\\' . str_replace(' ', '_', ucwords($str)); |
|
205 | 205 | |
206 | - $config = Config::get_instance( $config_id )->get_config(); |
|
207 | - $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : $config_id; |
|
206 | + $config = Config::get_instance($config_id)->get_config(); |
|
207 | + $args['kirki_config'] = isset($args['kirki_config']) ? $args['kirki_config'] : $config_id; |
|
208 | 208 | |
209 | - unset( $config['id'] ); |
|
209 | + unset($config['id']); |
|
210 | 210 | |
211 | - $args = wp_parse_args( $args, $config ); |
|
211 | + $args = wp_parse_args($args, $config); |
|
212 | 212 | |
213 | - if ( class_exists( $classname ) ) { |
|
214 | - unset( $args['type'] ); |
|
215 | - new $classname( $args ); |
|
213 | + if (class_exists($classname)) { |
|
214 | + unset($args['type']); |
|
215 | + new $classname($args); |
|
216 | 216 | return; |
217 | 217 | } |
218 | 218 | |
219 | - new Field( $config_id, $args ); |
|
219 | + new Field($config_id, $args); |
|
220 | 220 | |
221 | 221 | } |
222 | 222 | |
@@ -228,9 +228,9 @@ discard block |
||
228 | 228 | * @since 3.0.17 |
229 | 229 | * @param string $id The field ID. |
230 | 230 | */ |
231 | - public static function remove_control( $id ) { |
|
231 | + public static function remove_control($id) { |
|
232 | 232 | |
233 | - if ( ! in_array( $id, self::$controls_to_remove, true ) ) { |
|
233 | + if (!in_array($id, self::$controls_to_remove, true)) { |
|
234 | 234 | self::$controls_to_remove[] = $id; |
235 | 235 | } |
236 | 236 | |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | * @param string $param The parameter we want. |
247 | 247 | * @return string |
248 | 248 | */ |
249 | - public static function get_config_param( $id, $param ) { |
|
249 | + public static function get_config_param($id, $param) { |
|
250 | 250 | |
251 | - if ( ! isset( self::$config[ $id ] ) || ! isset( self::$config[ $id ][ $param ] ) ) { |
|
251 | + if (!isset(self::$config[$id]) || !isset(self::$config[$id][$param])) { |
|
252 | 252 | return ''; |
253 | 253 | } |
254 | 254 | |
255 | - return self::$config[ $id ][ $param ]; |
|
255 | + return self::$config[$id][$param]; |
|
256 | 256 | |
257 | 257 | } |
258 | 258 | |
@@ -266,31 +266,31 @@ discard block |
||
266 | 266 | * @param array $args The field arguments. |
267 | 267 | * @return array |
268 | 268 | */ |
269 | - private static function migrate_css_vars( $args ) { |
|
269 | + private static function migrate_css_vars($args) { |
|
270 | 270 | |
271 | 271 | // Convert css_vars to output args. |
272 | - if ( isset( $args['css_vars'] ) ) { |
|
272 | + if (isset($args['css_vars'])) { |
|
273 | 273 | |
274 | - if ( isset( $args['transport'] ) && 'postMessage' === $args['transport'] ) { |
|
274 | + if (isset($args['transport']) && 'postMessage' === $args['transport']) { |
|
275 | 275 | $args['transport'] = 'auto'; |
276 | 276 | } |
277 | 277 | |
278 | 278 | // Convert to properly-formatted arrays. |
279 | 279 | $args['css_vars'] = (array) $args['css_vars']; |
280 | 280 | |
281 | - if ( isset( $args['css_vars'][0] ) && is_string( $args['css_vars'][0] ) ) { |
|
282 | - $args['css_vars'] = [ $args['css_vars'] ]; |
|
281 | + if (isset($args['css_vars'][0]) && is_string($args['css_vars'][0])) { |
|
282 | + $args['css_vars'] = [$args['css_vars']]; |
|
283 | 283 | } |
284 | 284 | |
285 | - foreach ( $args['css_vars'] as $css_var ) { |
|
285 | + foreach ($args['css_vars'] as $css_var) { |
|
286 | 286 | $output = [ |
287 | 287 | 'element' => ':root', |
288 | 288 | 'property' => $css_var[0], |
289 | 289 | ]; |
290 | - if ( isset( $css_var[1] ) ) { |
|
290 | + if (isset($css_var[1])) { |
|
291 | 291 | $output['value_pattern'] = $css_var[1]; |
292 | 292 | } |
293 | - if ( isset( $css_var[2] ) ) { |
|
293 | + if (isset($css_var[2])) { |
|
294 | 294 | $output['choice'] = $css_var[2]; |
295 | 295 | } |
296 | 296 | $args['output'][] = $output; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | // Exit if accessed directly. |
16 | 16 | if ( ! defined( 'ABSPATH' ) ) { |
17 | - exit; |
|
17 | + exit; |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | /** |
@@ -22,26 +22,26 @@ discard block |
||
22 | 22 | */ |
23 | 23 | final class Framework { |
24 | 24 | |
25 | - /** |
|
26 | - * Holds the one, true instance of this object. |
|
27 | - * |
|
28 | - * @static |
|
29 | - * @access protected |
|
30 | - * @var object |
|
31 | - */ |
|
32 | - protected static $instance = null; |
|
25 | + /** |
|
26 | + * Holds the one, true instance of this object. |
|
27 | + * |
|
28 | + * @static |
|
29 | + * @access protected |
|
30 | + * @var object |
|
31 | + */ |
|
32 | + protected static $instance = null; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Access the single instance of this class. |
|
36 | - * |
|
37 | - * @static |
|
38 | - * @access public |
|
39 | - * @return Kirki\Compatibility\Framework |
|
40 | - */ |
|
41 | - public static function get_instance() { |
|
42 | - if ( null === self::$instance ) { |
|
43 | - self::$instance = new self(); |
|
44 | - } |
|
45 | - return self::$instance; |
|
46 | - } |
|
34 | + /** |
|
35 | + * Access the single instance of this class. |
|
36 | + * |
|
37 | + * @static |
|
38 | + * @access public |
|
39 | + * @return Kirki\Compatibility\Framework |
|
40 | + */ |
|
41 | + public static function get_instance() { |
|
42 | + if ( null === self::$instance ) { |
|
43 | + self::$instance = new self(); |
|
44 | + } |
|
45 | + return self::$instance; |
|
46 | + } |
|
47 | 47 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | namespace Kirki\Compatibility; |
14 | 14 | |
15 | 15 | // Exit if accessed directly. |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if (!defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @return Kirki\Compatibility\Framework |
40 | 40 | */ |
41 | 41 | public static function get_instance() { |
42 | - if ( null === self::$instance ) { |
|
42 | + if (null === self::$instance) { |
|
43 | 43 | self::$instance = new self(); |
44 | 44 | } |
45 | 45 | return self::$instance; |
@@ -18,15 +18,15 @@ |
||
18 | 18 | */ |
19 | 19 | class Deprecated { |
20 | 20 | |
21 | - /** |
|
22 | - * Constructor. |
|
23 | - * |
|
24 | - * @access public |
|
25 | - * @since 1.0 |
|
26 | - */ |
|
27 | - public function __construct() { |
|
28 | - require_once __DIR__ . '/deprecated/classes.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
|
29 | - require_once __DIR__ . '/deprecated/functions.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
|
30 | - require_once __DIR__ . '/deprecated/filters.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
|
31 | - } |
|
21 | + /** |
|
22 | + * Constructor. |
|
23 | + * |
|
24 | + * @access public |
|
25 | + * @since 1.0 |
|
26 | + */ |
|
27 | + public function __construct() { |
|
28 | + require_once __DIR__ . '/deprecated/classes.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
|
29 | + require_once __DIR__ . '/deprecated/functions.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
|
30 | + require_once __DIR__ . '/deprecated/filters.php'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude |
|
31 | + } |
|
32 | 32 | } |
@@ -3,55 +3,55 @@ |
||
3 | 3 | |
4 | 4 | // Exit if accessed directly. |
5 | 5 | if ( ! defined( 'ABSPATH' ) ) { |
6 | - exit; |
|
6 | + exit; |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | if ( ! function_exists( 'kirki_get_option' ) ) { |
10 | - /** |
|
11 | - * Get the value of a field. |
|
12 | - * This is a deprecated function that we used when there was no API. |
|
13 | - * Please use get_theme_mod() or get_option() instead. |
|
14 | - * @see https://developer.wordpress.org/reference/functions/get_theme_mod/ |
|
15 | - * @see https://developer.wordpress.org/reference/functions/get_option/ |
|
16 | - * |
|
17 | - * @return mixed |
|
18 | - */ |
|
19 | - function kirki_get_option( $option = '' ) { |
|
20 | - _deprecated_function( __FUNCTION__, '1.0.0', sprintf( esc_html__( '%1$s or %2$s', 'kirki' ), 'get_theme_mod', 'get_option' ) ); |
|
21 | - return Kirki::get_option( '', $option ); |
|
22 | - } |
|
10 | + /** |
|
11 | + * Get the value of a field. |
|
12 | + * This is a deprecated function that we used when there was no API. |
|
13 | + * Please use get_theme_mod() or get_option() instead. |
|
14 | + * @see https://developer.wordpress.org/reference/functions/get_theme_mod/ |
|
15 | + * @see https://developer.wordpress.org/reference/functions/get_option/ |
|
16 | + * |
|
17 | + * @return mixed |
|
18 | + */ |
|
19 | + function kirki_get_option( $option = '' ) { |
|
20 | + _deprecated_function( __FUNCTION__, '1.0.0', sprintf( esc_html__( '%1$s or %2$s', 'kirki' ), 'get_theme_mod', 'get_option' ) ); |
|
21 | + return Kirki::get_option( '', $option ); |
|
22 | + } |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | if ( ! function_exists( 'kirki_sanitize_hex' ) ) { |
26 | - function kirki_sanitize_hex( $color ) { |
|
27 | - _deprecated_function( __FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->toCSS( \'hex\' )' ); |
|
28 | - return Kirki_Color::sanitize_hex( $color ); |
|
29 | - } |
|
26 | + function kirki_sanitize_hex( $color ) { |
|
27 | + _deprecated_function( __FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->toCSS( \'hex\' )' ); |
|
28 | + return Kirki_Color::sanitize_hex( $color ); |
|
29 | + } |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | if ( ! function_exists( 'kirki_get_rgb' ) ) { |
33 | - function kirki_get_rgb( $hex, $implode = false ) { |
|
34 | - _deprecated_function( __FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->toCSS( \'rgb\' )' ); |
|
35 | - return Kirki_Color::get_rgb( $hex, $implode ); |
|
36 | - } |
|
33 | + function kirki_get_rgb( $hex, $implode = false ) { |
|
34 | + _deprecated_function( __FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->toCSS( \'rgb\' )' ); |
|
35 | + return Kirki_Color::get_rgb( $hex, $implode ); |
|
36 | + } |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | if ( ! function_exists( 'kirki_get_rgba' ) ) { |
40 | - function kirki_get_rgba( $hex = '#fff', $opacity = 100 ) { |
|
41 | - _deprecated_function( __FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->toCSS( \'rgba\' )' ); |
|
42 | - return Kirki_Color::get_rgba( $hex, $opacity ); |
|
43 | - } |
|
40 | + function kirki_get_rgba( $hex = '#fff', $opacity = 100 ) { |
|
41 | + _deprecated_function( __FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->toCSS( \'rgba\' )' ); |
|
42 | + return Kirki_Color::get_rgba( $hex, $opacity ); |
|
43 | + } |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | if ( ! function_exists( 'kirki_get_brightness' ) ) { |
47 | - function kirki_get_brightness( $hex ) { |
|
48 | - _deprecated_function( __FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->lightness' ); |
|
49 | - return Kirki_Color::get_brightness( $hex ); |
|
50 | - } |
|
47 | + function kirki_get_brightness( $hex ) { |
|
48 | + _deprecated_function( __FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->lightness' ); |
|
49 | + return Kirki_Color::get_brightness( $hex ); |
|
50 | + } |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | if ( ! function_exists( 'Kirki' ) ) { |
54 | - function Kirki() { |
|
55 | - return \Kirki\Compatibility\Framework::get_instance(); |
|
56 | - } |
|
54 | + function Kirki() { |
|
55 | + return \Kirki\Compatibility\Framework::get_instance(); |
|
56 | + } |
|
57 | 57 | } |
@@ -2,11 +2,11 @@ discard block |
||
2 | 2 | // phpcs:ignoreFile |
3 | 3 | |
4 | 4 | // Exit if accessed directly. |
5 | -if ( ! defined( 'ABSPATH' ) ) { |
|
5 | +if (!defined('ABSPATH')) { |
|
6 | 6 | exit; |
7 | 7 | } |
8 | 8 | |
9 | -if ( ! function_exists( 'kirki_get_option' ) ) { |
|
9 | +if (!function_exists('kirki_get_option')) { |
|
10 | 10 | /** |
11 | 11 | * Get the value of a field. |
12 | 12 | * This is a deprecated function that we used when there was no API. |
@@ -16,41 +16,41 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @return mixed |
18 | 18 | */ |
19 | - function kirki_get_option( $option = '' ) { |
|
20 | - _deprecated_function( __FUNCTION__, '1.0.0', sprintf( esc_html__( '%1$s or %2$s', 'kirki' ), 'get_theme_mod', 'get_option' ) ); |
|
21 | - return Kirki::get_option( '', $option ); |
|
19 | + function kirki_get_option($option = '') { |
|
20 | + _deprecated_function(__FUNCTION__, '1.0.0', sprintf(esc_html__('%1$s or %2$s', 'kirki'), 'get_theme_mod', 'get_option')); |
|
21 | + return Kirki::get_option('', $option); |
|
22 | 22 | } |
23 | 23 | } |
24 | 24 | |
25 | -if ( ! function_exists( 'kirki_sanitize_hex' ) ) { |
|
26 | - function kirki_sanitize_hex( $color ) { |
|
27 | - _deprecated_function( __FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->toCSS( \'hex\' )' ); |
|
28 | - return Kirki_Color::sanitize_hex( $color ); |
|
25 | +if (!function_exists('kirki_sanitize_hex')) { |
|
26 | + function kirki_sanitize_hex($color) { |
|
27 | + _deprecated_function(__FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->toCSS( \'hex\' )'); |
|
28 | + return Kirki_Color::sanitize_hex($color); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | -if ( ! function_exists( 'kirki_get_rgb' ) ) { |
|
33 | - function kirki_get_rgb( $hex, $implode = false ) { |
|
34 | - _deprecated_function( __FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->toCSS( \'rgb\' )' ); |
|
35 | - return Kirki_Color::get_rgb( $hex, $implode ); |
|
32 | +if (!function_exists('kirki_get_rgb')) { |
|
33 | + function kirki_get_rgb($hex, $implode = false) { |
|
34 | + _deprecated_function(__FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->toCSS( \'rgb\' )'); |
|
35 | + return Kirki_Color::get_rgb($hex, $implode); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | -if ( ! function_exists( 'kirki_get_rgba' ) ) { |
|
40 | - function kirki_get_rgba( $hex = '#fff', $opacity = 100 ) { |
|
41 | - _deprecated_function( __FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->toCSS( \'rgba\' )' ); |
|
42 | - return Kirki_Color::get_rgba( $hex, $opacity ); |
|
39 | +if (!function_exists('kirki_get_rgba')) { |
|
40 | + function kirki_get_rgba($hex = '#fff', $opacity = 100) { |
|
41 | + _deprecated_function(__FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->toCSS( \'rgba\' )'); |
|
42 | + return Kirki_Color::get_rgba($hex, $opacity); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | -if ( ! function_exists( 'kirki_get_brightness' ) ) { |
|
47 | - function kirki_get_brightness( $hex ) { |
|
48 | - _deprecated_function( __FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->lightness' ); |
|
49 | - return Kirki_Color::get_brightness( $hex ); |
|
46 | +if (!function_exists('kirki_get_brightness')) { |
|
47 | + function kirki_get_brightness($hex) { |
|
48 | + _deprecated_function(__FUNCTION__, '1.0.0', 'ariColor::newColor( $color )->lightness'); |
|
49 | + return Kirki_Color::get_brightness($hex); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -if ( ! function_exists( 'Kirki' ) ) { |
|
53 | +if (!function_exists('Kirki')) { |
|
54 | 54 | function Kirki() { |
55 | 55 | return \Kirki\Compatibility\Framework::get_instance(); |
56 | 56 | } |