@@ -19,113 +19,113 @@ |
||
19 | 19 | */ |
20 | 20 | class Section_Icons { |
21 | 21 | |
22 | - /** |
|
23 | - * An array of panels and sections with icons. |
|
24 | - * |
|
25 | - * @static |
|
26 | - * @access private |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - private static $icons = []; |
|
30 | - |
|
31 | - /** |
|
32 | - * An array of panels. |
|
33 | - * |
|
34 | - * @access private |
|
35 | - * @since 1.0 |
|
36 | - * @var array |
|
37 | - */ |
|
38 | - private $panels = []; |
|
39 | - |
|
40 | - /** |
|
41 | - * An array of sections. |
|
42 | - * |
|
43 | - * @access private |
|
44 | - * @since 1.0 |
|
45 | - * @var array |
|
46 | - */ |
|
47 | - private $sections = []; |
|
48 | - |
|
49 | - /** |
|
50 | - * The class constructor. |
|
51 | - * |
|
52 | - * @access public |
|
53 | - */ |
|
54 | - public function __construct() { |
|
55 | - |
|
56 | - add_action( 'customize_controls_enqueue_scripts', [ $this, 'customize_controls_enqueue_scripts' ], 99 ); |
|
57 | - add_action( 'kirki_panel_added', [ $this, 'panel_added' ], 10, 2 ); |
|
58 | - add_action( 'kirki_section_added', [ $this, 'section_added' ], 10, 2 ); |
|
59 | - |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Adds icon for a section/panel. |
|
64 | - * |
|
65 | - * @access public |
|
66 | - * @since 3.0.0 |
|
67 | - * @param string $id The panel or section ID. |
|
68 | - * @param string $icon The icon to add. |
|
69 | - * @param string $context Lowercase 'section' or 'panel'. |
|
70 | - */ |
|
71 | - public function add_icon( $id, $icon, $context = 'section' ) { |
|
72 | - |
|
73 | - self::$icons[ $context ][ $id ] = trim( $icon ); |
|
74 | - |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Hooks in kirki_panel_added to populate $this->panels. |
|
79 | - * |
|
80 | - * @access public |
|
81 | - * @since 1.0 |
|
82 | - * @param string $id The panel ID. |
|
83 | - * @param array $args The panel arguments. |
|
84 | - */ |
|
85 | - public function panel_added( $id, $args ) { |
|
86 | - |
|
87 | - if ( isset( $args['icon'] ) ) { |
|
88 | - $args['id'] = $id; |
|
89 | - $this->panels[] = $args; |
|
90 | - } |
|
91 | - |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Hooks in kirki_section_added to populate $this->sections. |
|
96 | - * |
|
97 | - * @access public |
|
98 | - * @since 1.0 |
|
99 | - * @param string $id The section ID. |
|
100 | - * @param array $args The section arguments. |
|
101 | - */ |
|
102 | - public function section_added( $id, $args ) { |
|
103 | - |
|
104 | - if ( isset( $args['icon'] ) ) { |
|
105 | - $args['id'] = $id; |
|
106 | - $this->sections[] = $args; |
|
107 | - } |
|
108 | - |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Format the script in a way that will be compatible with WordPress. |
|
113 | - */ |
|
114 | - public function customize_controls_enqueue_scripts() { |
|
115 | - |
|
116 | - // Parse panels and find ones with icons. |
|
117 | - foreach ( $this->panels as $panel ) { |
|
118 | - $this->add_icon( $panel['id'], $panel['icon'], 'panel' ); |
|
119 | - } |
|
120 | - |
|
121 | - // Parse sections and find ones with icons. |
|
122 | - foreach ( $this->sections as $section ) { |
|
123 | - $this->add_icon( $section['id'], $section['icon'], 'section' ); |
|
124 | - } |
|
125 | - |
|
126 | - wp_enqueue_script( 'kirki_panel_and_section_icons', URL::get_from_path( __DIR__ . '/icons.js' ), [ 'jquery', 'customize-base', 'customize-controls' ], '1.0', true ); |
|
127 | - wp_localize_script( 'kirki_panel_and_section_icons', 'kirkiIcons', self::$icons ); |
|
128 | - |
|
129 | - } |
|
22 | + /** |
|
23 | + * An array of panels and sections with icons. |
|
24 | + * |
|
25 | + * @static |
|
26 | + * @access private |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + private static $icons = []; |
|
30 | + |
|
31 | + /** |
|
32 | + * An array of panels. |
|
33 | + * |
|
34 | + * @access private |
|
35 | + * @since 1.0 |
|
36 | + * @var array |
|
37 | + */ |
|
38 | + private $panels = []; |
|
39 | + |
|
40 | + /** |
|
41 | + * An array of sections. |
|
42 | + * |
|
43 | + * @access private |
|
44 | + * @since 1.0 |
|
45 | + * @var array |
|
46 | + */ |
|
47 | + private $sections = []; |
|
48 | + |
|
49 | + /** |
|
50 | + * The class constructor. |
|
51 | + * |
|
52 | + * @access public |
|
53 | + */ |
|
54 | + public function __construct() { |
|
55 | + |
|
56 | + add_action( 'customize_controls_enqueue_scripts', [ $this, 'customize_controls_enqueue_scripts' ], 99 ); |
|
57 | + add_action( 'kirki_panel_added', [ $this, 'panel_added' ], 10, 2 ); |
|
58 | + add_action( 'kirki_section_added', [ $this, 'section_added' ], 10, 2 ); |
|
59 | + |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Adds icon for a section/panel. |
|
64 | + * |
|
65 | + * @access public |
|
66 | + * @since 3.0.0 |
|
67 | + * @param string $id The panel or section ID. |
|
68 | + * @param string $icon The icon to add. |
|
69 | + * @param string $context Lowercase 'section' or 'panel'. |
|
70 | + */ |
|
71 | + public function add_icon( $id, $icon, $context = 'section' ) { |
|
72 | + |
|
73 | + self::$icons[ $context ][ $id ] = trim( $icon ); |
|
74 | + |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Hooks in kirki_panel_added to populate $this->panels. |
|
79 | + * |
|
80 | + * @access public |
|
81 | + * @since 1.0 |
|
82 | + * @param string $id The panel ID. |
|
83 | + * @param array $args The panel arguments. |
|
84 | + */ |
|
85 | + public function panel_added( $id, $args ) { |
|
86 | + |
|
87 | + if ( isset( $args['icon'] ) ) { |
|
88 | + $args['id'] = $id; |
|
89 | + $this->panels[] = $args; |
|
90 | + } |
|
91 | + |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Hooks in kirki_section_added to populate $this->sections. |
|
96 | + * |
|
97 | + * @access public |
|
98 | + * @since 1.0 |
|
99 | + * @param string $id The section ID. |
|
100 | + * @param array $args The section arguments. |
|
101 | + */ |
|
102 | + public function section_added( $id, $args ) { |
|
103 | + |
|
104 | + if ( isset( $args['icon'] ) ) { |
|
105 | + $args['id'] = $id; |
|
106 | + $this->sections[] = $args; |
|
107 | + } |
|
108 | + |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Format the script in a way that will be compatible with WordPress. |
|
113 | + */ |
|
114 | + public function customize_controls_enqueue_scripts() { |
|
115 | + |
|
116 | + // Parse panels and find ones with icons. |
|
117 | + foreach ( $this->panels as $panel ) { |
|
118 | + $this->add_icon( $panel['id'], $panel['icon'], 'panel' ); |
|
119 | + } |
|
120 | + |
|
121 | + // Parse sections and find ones with icons. |
|
122 | + foreach ( $this->sections as $section ) { |
|
123 | + $this->add_icon( $section['id'], $section['icon'], 'section' ); |
|
124 | + } |
|
125 | + |
|
126 | + wp_enqueue_script( 'kirki_panel_and_section_icons', URL::get_from_path( __DIR__ . '/icons.js' ), [ 'jquery', 'customize-base', 'customize-controls' ], '1.0', true ); |
|
127 | + wp_localize_script( 'kirki_panel_and_section_icons', 'kirkiIcons', self::$icons ); |
|
128 | + |
|
129 | + } |
|
130 | 130 | |
131 | 131 | } |
@@ -15,36 +15,36 @@ |
||
15 | 15 | */ |
16 | 16 | class Textarea extends Generic { |
17 | 17 | |
18 | - /** |
|
19 | - * The field type. |
|
20 | - * |
|
21 | - * @access public |
|
22 | - * @since 1.0 |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - public $type = 'kirki-textarea'; |
|
18 | + /** |
|
19 | + * The field type. |
|
20 | + * |
|
21 | + * @access public |
|
22 | + * @since 1.0 |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + public $type = 'kirki-textarea'; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Filter arguments before creating the control. |
|
29 | - * |
|
30 | - * @access public |
|
31 | - * @since 0.1 |
|
32 | - * @param array $args The field arguments. |
|
33 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
34 | - * @return array |
|
35 | - */ |
|
36 | - public function filter_control_args( $args, $wp_customize ) { |
|
37 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
38 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
27 | + /** |
|
28 | + * Filter arguments before creating the control. |
|
29 | + * |
|
30 | + * @access public |
|
31 | + * @since 0.1 |
|
32 | + * @param array $args The field arguments. |
|
33 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
34 | + * @return array |
|
35 | + */ |
|
36 | + public function filter_control_args( $args, $wp_customize ) { |
|
37 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
38 | + $args = parent::filter_control_args( $args, $wp_customize ); |
|
39 | 39 | |
40 | - // Set the control-type. |
|
41 | - $args['type'] = 'kirki-generic'; |
|
40 | + // Set the control-type. |
|
41 | + $args['type'] = 'kirki-generic'; |
|
42 | 42 | |
43 | - // Choices. |
|
44 | - $args['choices'] = isset( $args['choices'] ) ? $args['choices'] : []; |
|
45 | - $args['choices']['element'] = 'textarea'; |
|
46 | - $args['choices']['rows'] = '5'; |
|
47 | - } |
|
48 | - return $args; |
|
49 | - } |
|
43 | + // Choices. |
|
44 | + $args['choices'] = isset( $args['choices'] ) ? $args['choices'] : []; |
|
45 | + $args['choices']['element'] = 'textarea'; |
|
46 | + $args['choices']['rows'] = '5'; |
|
47 | + } |
|
48 | + return $args; |
|
49 | + } |
|
50 | 50 | } |
@@ -17,94 +17,94 @@ |
||
17 | 17 | */ |
18 | 18 | class Number extends Generic { |
19 | 19 | |
20 | - /** |
|
21 | - * The field type. |
|
22 | - * |
|
23 | - * @access public |
|
24 | - * @since 1.0 |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - public $type = 'kirki-number'; |
|
28 | - |
|
29 | - /** |
|
30 | - * Filter arguments before creating the setting. |
|
31 | - * |
|
32 | - * @access public |
|
33 | - * @since 0.1 |
|
34 | - * @param array $args The field arguments. |
|
35 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
36 | - * @return array |
|
37 | - */ |
|
38 | - public function filter_setting_args( $args, $wp_customize ) { |
|
39 | - |
|
40 | - if ( $args['settings'] !== $this->args['settings'] ) { |
|
41 | - return $args; |
|
42 | - } |
|
43 | - |
|
44 | - // Set the sanitize-callback if none is defined. |
|
45 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
46 | - |
|
47 | - $args['sanitize_callback'] = function( $value ) use ( $args ) { |
|
48 | - $value = filter_var( $value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
49 | - |
|
50 | - if ( isset( $args['choices'] ) && isset( $args['choices']['min'] ) && isset( $args['choices']['max'] ) ) { |
|
51 | - // Make sure min & max are all numeric. |
|
52 | - $min = filter_var( $args['choices']['min'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
53 | - $max = filter_var( $args['choices']['max'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
54 | - |
|
55 | - if ( $value < $min ) { |
|
56 | - $value = $min; |
|
57 | - } elseif ( $value > $max ) { |
|
58 | - $value = $max; |
|
59 | - } |
|
60 | - } |
|
61 | - |
|
62 | - return $value; |
|
63 | - }; |
|
64 | - |
|
65 | - } |
|
66 | - |
|
67 | - return $args; |
|
68 | - } |
|
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 | - |
|
81 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
82 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
83 | - |
|
84 | - // Set the control-type. |
|
85 | - $args['type'] = 'kirki-generic'; |
|
86 | - |
|
87 | - // Choices. |
|
88 | - $args['choices'] = isset( $args['choices'] ) ? $args['choices'] : []; |
|
89 | - $args['choices']['element'] = 'input'; |
|
90 | - $args['choices']['type'] = 'number'; |
|
91 | - $args['choices'] = wp_parse_args( |
|
92 | - $args['choices'], |
|
93 | - [ |
|
94 | - 'min' => -999999999, |
|
95 | - 'max' => 999999999, |
|
96 | - 'step' => 1, |
|
97 | - ] |
|
98 | - ); |
|
99 | - |
|
100 | - // Make sure min, max & step are all numeric. |
|
101 | - $args['choices']['min'] = filter_var( $args['choices']['min'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
102 | - $args['choices']['max'] = filter_var( $args['choices']['max'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
103 | - $args['choices']['step'] = filter_var( $args['choices']['step'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
104 | - } |
|
105 | - |
|
106 | - return $args; |
|
107 | - |
|
108 | - } |
|
20 | + /** |
|
21 | + * The field type. |
|
22 | + * |
|
23 | + * @access public |
|
24 | + * @since 1.0 |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + public $type = 'kirki-number'; |
|
28 | + |
|
29 | + /** |
|
30 | + * Filter arguments before creating the setting. |
|
31 | + * |
|
32 | + * @access public |
|
33 | + * @since 0.1 |
|
34 | + * @param array $args The field arguments. |
|
35 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
36 | + * @return array |
|
37 | + */ |
|
38 | + public function filter_setting_args( $args, $wp_customize ) { |
|
39 | + |
|
40 | + if ( $args['settings'] !== $this->args['settings'] ) { |
|
41 | + return $args; |
|
42 | + } |
|
43 | + |
|
44 | + // Set the sanitize-callback if none is defined. |
|
45 | + if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
46 | + |
|
47 | + $args['sanitize_callback'] = function( $value ) use ( $args ) { |
|
48 | + $value = filter_var( $value, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
49 | + |
|
50 | + if ( isset( $args['choices'] ) && isset( $args['choices']['min'] ) && isset( $args['choices']['max'] ) ) { |
|
51 | + // Make sure min & max are all numeric. |
|
52 | + $min = filter_var( $args['choices']['min'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
53 | + $max = filter_var( $args['choices']['max'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
54 | + |
|
55 | + if ( $value < $min ) { |
|
56 | + $value = $min; |
|
57 | + } elseif ( $value > $max ) { |
|
58 | + $value = $max; |
|
59 | + } |
|
60 | + } |
|
61 | + |
|
62 | + return $value; |
|
63 | + }; |
|
64 | + |
|
65 | + } |
|
66 | + |
|
67 | + return $args; |
|
68 | + } |
|
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 | + |
|
81 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
82 | + $args = parent::filter_control_args( $args, $wp_customize ); |
|
83 | + |
|
84 | + // Set the control-type. |
|
85 | + $args['type'] = 'kirki-generic'; |
|
86 | + |
|
87 | + // Choices. |
|
88 | + $args['choices'] = isset( $args['choices'] ) ? $args['choices'] : []; |
|
89 | + $args['choices']['element'] = 'input'; |
|
90 | + $args['choices']['type'] = 'number'; |
|
91 | + $args['choices'] = wp_parse_args( |
|
92 | + $args['choices'], |
|
93 | + [ |
|
94 | + 'min' => -999999999, |
|
95 | + 'max' => 999999999, |
|
96 | + 'step' => 1, |
|
97 | + ] |
|
98 | + ); |
|
99 | + |
|
100 | + // Make sure min, max & step are all numeric. |
|
101 | + $args['choices']['min'] = filter_var( $args['choices']['min'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
102 | + $args['choices']['max'] = filter_var( $args['choices']['max'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
103 | + $args['choices']['step'] = filter_var( $args['choices']['step'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); |
|
104 | + } |
|
105 | + |
|
106 | + return $args; |
|
107 | + |
|
108 | + } |
|
109 | 109 | |
110 | 110 | } |
@@ -19,80 +19,80 @@ |
||
19 | 19 | */ |
20 | 20 | class Generic 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-generic'; |
|
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\Generic'; |
|
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; |
|
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 | - |
|
60 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
61 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
62 | - |
|
63 | - // Set the sanitize-callback if none is defined. |
|
64 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
65 | - $args['sanitize_callback'] = 'wp_kses_post'; |
|
66 | - } |
|
67 | - } |
|
68 | - |
|
69 | - return $args; |
|
70 | - |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * Filter arguments before creating the control. |
|
75 | - * |
|
76 | - * @access public |
|
77 | - * @since 0.1 |
|
78 | - * @param array $args The field arguments. |
|
79 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
80 | - * @return array |
|
81 | - */ |
|
82 | - public function filter_control_args( $args, $wp_customize ) { |
|
83 | - |
|
84 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
85 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
86 | - |
|
87 | - // Set the control-type. |
|
88 | - $args['type'] = 'kirki-generic'; |
|
89 | - |
|
90 | - // Choices. |
|
91 | - $args['choices'] = isset( $args['choices'] ) ? $args['choices'] : []; |
|
92 | - $args['choices']['element'] = isset( $args['choices']['element'] ) ? $args['choices']['element'] : 'input'; |
|
93 | - } |
|
94 | - |
|
95 | - return $args; |
|
96 | - |
|
97 | - } |
|
22 | + /** |
|
23 | + * The field type. |
|
24 | + * |
|
25 | + * @access public |
|
26 | + * @since 1.0 |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + public $type = 'kirki-generic'; |
|
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\Generic'; |
|
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; |
|
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 | + |
|
60 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
61 | + $args = parent::filter_setting_args( $args, $wp_customize ); |
|
62 | + |
|
63 | + // Set the sanitize-callback if none is defined. |
|
64 | + if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
65 | + $args['sanitize_callback'] = 'wp_kses_post'; |
|
66 | + } |
|
67 | + } |
|
68 | + |
|
69 | + return $args; |
|
70 | + |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Filter arguments before creating the control. |
|
75 | + * |
|
76 | + * @access public |
|
77 | + * @since 0.1 |
|
78 | + * @param array $args The field arguments. |
|
79 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
80 | + * @return array |
|
81 | + */ |
|
82 | + public function filter_control_args( $args, $wp_customize ) { |
|
83 | + |
|
84 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
85 | + $args = parent::filter_control_args( $args, $wp_customize ); |
|
86 | + |
|
87 | + // Set the control-type. |
|
88 | + $args['type'] = 'kirki-generic'; |
|
89 | + |
|
90 | + // Choices. |
|
91 | + $args['choices'] = isset( $args['choices'] ) ? $args['choices'] : []; |
|
92 | + $args['choices']['element'] = isset( $args['choices']['element'] ) ? $args['choices']['element'] : 'input'; |
|
93 | + } |
|
94 | + |
|
95 | + return $args; |
|
96 | + |
|
97 | + } |
|
98 | 98 | } |
@@ -17,33 +17,33 @@ |
||
17 | 17 | */ |
18 | 18 | class URL extends Text { |
19 | 19 | |
20 | - /** |
|
21 | - * The field type. |
|
22 | - * |
|
23 | - * @access public |
|
24 | - * @since 1.0 |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - public $type = 'kirki-url'; |
|
20 | + /** |
|
21 | + * The field type. |
|
22 | + * |
|
23 | + * @access public |
|
24 | + * @since 1.0 |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + public $type = 'kirki-url'; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Filter arguments before creating the setting. |
|
31 | - * |
|
32 | - * @access public |
|
33 | - * @since 0.1 |
|
34 | - * @param array $args The field arguments. |
|
35 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
36 | - * @return array |
|
37 | - */ |
|
38 | - public function filter_setting_args( $args, $wp_customize ) { |
|
39 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
40 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
29 | + /** |
|
30 | + * Filter arguments before creating the setting. |
|
31 | + * |
|
32 | + * @access public |
|
33 | + * @since 0.1 |
|
34 | + * @param array $args The field arguments. |
|
35 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
36 | + * @return array |
|
37 | + */ |
|
38 | + public function filter_setting_args( $args, $wp_customize ) { |
|
39 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
40 | + $args = parent::filter_setting_args( $args, $wp_customize ); |
|
41 | 41 | |
42 | - // Set the sanitize-callback if none is defined. |
|
43 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
44 | - $args['sanitize_callback'] = 'esc_url_raw'; |
|
45 | - } |
|
46 | - } |
|
47 | - return $args; |
|
48 | - } |
|
42 | + // Set the sanitize-callback if none is defined. |
|
43 | + if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
44 | + $args['sanitize_callback'] = 'esc_url_raw'; |
|
45 | + } |
|
46 | + } |
|
47 | + return $args; |
|
48 | + } |
|
49 | 49 | } |
@@ -17,57 +17,57 @@ |
||
17 | 17 | */ |
18 | 18 | class Text extends Generic { |
19 | 19 | |
20 | - /** |
|
21 | - * The field type. |
|
22 | - * |
|
23 | - * @access public |
|
24 | - * @since 1.0 |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - public $type = 'kirki-text'; |
|
20 | + /** |
|
21 | + * The field type. |
|
22 | + * |
|
23 | + * @access public |
|
24 | + * @since 1.0 |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + public $type = 'kirki-text'; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Filter arguments before creating the setting. |
|
31 | - * |
|
32 | - * @access public |
|
33 | - * @since 0.1 |
|
34 | - * @param array $args The field arguments. |
|
35 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
36 | - * @return array |
|
37 | - */ |
|
38 | - public function filter_setting_args( $args, $wp_customize ) { |
|
39 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
40 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
29 | + /** |
|
30 | + * Filter arguments before creating the setting. |
|
31 | + * |
|
32 | + * @access public |
|
33 | + * @since 0.1 |
|
34 | + * @param array $args The field arguments. |
|
35 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
36 | + * @return array |
|
37 | + */ |
|
38 | + public function filter_setting_args( $args, $wp_customize ) { |
|
39 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
40 | + $args = parent::filter_setting_args( $args, $wp_customize ); |
|
41 | 41 | |
42 | - // Set the sanitize-callback if none is defined. |
|
43 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
44 | - $args['sanitize_callback'] = 'sanitize_textarea_field'; // ? Bagus: should we use `sanitize_text_field` instead ? |
|
45 | - } |
|
46 | - } |
|
47 | - return $args; |
|
48 | - } |
|
42 | + // Set the sanitize-callback if none is defined. |
|
43 | + if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
44 | + $args['sanitize_callback'] = 'sanitize_textarea_field'; // ? Bagus: should we use `sanitize_text_field` instead ? |
|
45 | + } |
|
46 | + } |
|
47 | + return $args; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Filter arguments before creating the control. |
|
52 | - * |
|
53 | - * @access public |
|
54 | - * @since 0.1 |
|
55 | - * @param array $args The field arguments. |
|
56 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
57 | - * @return array |
|
58 | - */ |
|
59 | - public function filter_control_args( $args, $wp_customize ) { |
|
60 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
61 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
50 | + /** |
|
51 | + * Filter arguments before creating the control. |
|
52 | + * |
|
53 | + * @access public |
|
54 | + * @since 0.1 |
|
55 | + * @param array $args The field arguments. |
|
56 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
57 | + * @return array |
|
58 | + */ |
|
59 | + public function filter_control_args( $args, $wp_customize ) { |
|
60 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
61 | + $args = parent::filter_control_args( $args, $wp_customize ); |
|
62 | 62 | |
63 | - // Set the control-type. |
|
64 | - $args['type'] = 'kirki-generic'; |
|
63 | + // Set the control-type. |
|
64 | + $args['type'] = 'kirki-generic'; |
|
65 | 65 | |
66 | - // Choices. |
|
67 | - $args['choices'] = isset( $args['choices'] ) ? $args['choices'] : []; |
|
68 | - $args['choices']['element'] = 'input'; |
|
69 | - $args['choices']['type'] = 'text'; |
|
70 | - } |
|
71 | - return $args; |
|
72 | - } |
|
66 | + // Choices. |
|
67 | + $args['choices'] = isset( $args['choices'] ) ? $args['choices'] : []; |
|
68 | + $args['choices']['element'] = 'input'; |
|
69 | + $args['choices']['type'] = 'text'; |
|
70 | + } |
|
71 | + return $args; |
|
72 | + } |
|
73 | 73 | } |
@@ -21,54 +21,54 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class Generic extends Base { |
23 | 23 | |
24 | - /** |
|
25 | - * The control type. |
|
26 | - * |
|
27 | - * @access public |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - public $type = 'kirki-generic'; |
|
24 | + /** |
|
25 | + * The control type. |
|
26 | + * |
|
27 | + * @access public |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + public $type = 'kirki-generic'; |
|
31 | 31 | |
32 | - /** |
|
33 | - * The version. Used in scripts & styles for cache-busting. |
|
34 | - * |
|
35 | - * @static |
|
36 | - * @access public |
|
37 | - * @since 1.0 |
|
38 | - * @var string |
|
39 | - */ |
|
40 | - public static $control_ver = '1.0.2'; |
|
32 | + /** |
|
33 | + * The version. Used in scripts & styles for cache-busting. |
|
34 | + * |
|
35 | + * @static |
|
36 | + * @access public |
|
37 | + * @since 1.0 |
|
38 | + * @var string |
|
39 | + */ |
|
40 | + public static $control_ver = '1.0.2'; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Enqueue control related scripts/styles. |
|
44 | - * |
|
45 | - * @access public |
|
46 | - * @since 1.0 |
|
47 | - * @return void |
|
48 | - */ |
|
49 | - public function enqueue() { |
|
42 | + /** |
|
43 | + * Enqueue control related scripts/styles. |
|
44 | + * |
|
45 | + * @access public |
|
46 | + * @since 1.0 |
|
47 | + * @return void |
|
48 | + */ |
|
49 | + public function enqueue() { |
|
50 | 50 | |
51 | - parent::enqueue(); |
|
51 | + parent::enqueue(); |
|
52 | 52 | |
53 | - // Enqueue the script. |
|
54 | - wp_enqueue_script( 'kirki-control-generic', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'kirki-control-base' ], self::$control_ver, false ); |
|
53 | + // Enqueue the script. |
|
54 | + wp_enqueue_script( 'kirki-control-generic', URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [ 'jquery', 'customize-base', 'kirki-control-base' ], self::$control_ver, false ); |
|
55 | 55 | |
56 | - } |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * An Underscore (JS) template for this control's content (but not its container). |
|
60 | - * |
|
61 | - * Class variables for this control class are available in the `data` JS object; |
|
62 | - * export custom variables by overriding {@see WP_Customize_Control::to_json()}. |
|
63 | - * |
|
64 | - * @see WP_Customize_Control::print_template() |
|
65 | - * |
|
66 | - * @access protected |
|
67 | - * @since 1.1 |
|
68 | - * @return void |
|
69 | - */ |
|
70 | - protected function content_template() { |
|
71 | - ?> |
|
58 | + /** |
|
59 | + * An Underscore (JS) template for this control's content (but not its container). |
|
60 | + * |
|
61 | + * Class variables for this control class are available in the `data` JS object; |
|
62 | + * export custom variables by overriding {@see WP_Customize_Control::to_json()}. |
|
63 | + * |
|
64 | + * @see WP_Customize_Control::print_template() |
|
65 | + * |
|
66 | + * @access protected |
|
67 | + * @since 1.1 |
|
68 | + * @return void |
|
69 | + */ |
|
70 | + protected function content_template() { |
|
71 | + ?> |
|
72 | 72 | <label class="customize-control-label" for="{{ ! data.choices.id ? 'customize-input-' + data.id : data.choices.id }}"> |
73 | 73 | <span class="customize-control-title">{{{ data.label }}}</span> |
74 | 74 | <# if ( data.description ) { #> |
@@ -106,5 +106,5 @@ discard block |
||
106 | 106 | <# } #> |
107 | 107 | </div> |
108 | 108 | <?php |
109 | - } |
|
109 | + } |
|
110 | 110 | } |
@@ -18,146 +18,146 @@ |
||
18 | 18 | */ |
19 | 19 | class L10n { |
20 | 20 | |
21 | - /** |
|
22 | - * The plugin textdomain |
|
23 | - * |
|
24 | - * @access private |
|
25 | - * @since 1.0 |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - private $textdomain; |
|
29 | - |
|
30 | - /** |
|
31 | - * The folder path containing translation files. |
|
32 | - * |
|
33 | - * @access private |
|
34 | - * @since 1.0 |
|
35 | - * @var string |
|
36 | - */ |
|
37 | - private $languages_path; |
|
38 | - |
|
39 | - /** |
|
40 | - * The theme textdomain |
|
41 | - * |
|
42 | - * @access private |
|
43 | - * @since 1.0 |
|
44 | - * @var string |
|
45 | - */ |
|
46 | - private $theme_textdomain = ''; |
|
47 | - |
|
48 | - /** |
|
49 | - * The class constructor. |
|
50 | - * Adds actions & filters to handle the rest of the methods. |
|
51 | - * |
|
52 | - * @access public |
|
53 | - * @since 1.0 |
|
54 | - * @param string $textdomain The textdomain we want to use. Defaults to "kirki". |
|
55 | - * @param string $languages_path The path to languages files. |
|
56 | - */ |
|
57 | - public function __construct( $textdomain = 'kirki', $languages_path = '' ) { |
|
58 | - |
|
59 | - $this->textdomain = $textdomain; |
|
60 | - $this->languages_path = $languages_path; |
|
61 | - // This will only work if we're inside a plugin. |
|
62 | - add_action( 'plugins_loaded', [ $this, 'load_textdomain' ] ); |
|
63 | - |
|
64 | - // If we got this far, then Kirki is embedded in a plugin. |
|
65 | - // We want the theme's textdomain to handle translations. |
|
66 | - add_filter( 'override_load_textdomain', [ $this, 'override_load_textdomain' ], 5, 3 ); |
|
67 | - } |
|
68 | - |
|
69 | - /** |
|
70 | - * Load the plugin textdomain |
|
71 | - * |
|
72 | - * @access public |
|
73 | - * @since 1.0 |
|
74 | - */ |
|
75 | - public function load_textdomain() { |
|
76 | - if ( null !== $this->get_path() ) { |
|
77 | - load_textdomain( $this->textdomain, $this->get_path() ); |
|
78 | - } |
|
79 | - load_plugin_textdomain( $this->textdomain, false, $this->languages_path ); |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Gets the path to a translation file. |
|
84 | - * |
|
85 | - * @access protected |
|
86 | - * @since 1.0 |
|
87 | - * @return string Absolute path to the translation file. |
|
88 | - */ |
|
89 | - protected function get_path() { |
|
90 | - $path_found = false; |
|
91 | - $found_path = null; |
|
92 | - foreach ( $this->get_paths() as $path ) { |
|
93 | - if ( $path_found ) { |
|
94 | - continue; |
|
95 | - } |
|
96 | - $path = wp_normalize_path( $path ); |
|
97 | - if ( file_exists( $path ) ) { |
|
98 | - $path_found = true; |
|
99 | - $found_path = $path; |
|
100 | - } |
|
101 | - } |
|
102 | - return $found_path; |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * Returns an array of paths where translation files may be located. |
|
107 | - * |
|
108 | - * @access protected |
|
109 | - * @since 1.0 |
|
110 | - * @return array |
|
111 | - */ |
|
112 | - protected function get_paths() { |
|
113 | - return [ |
|
114 | - WP_LANG_DIR . '/' . $this->textdomain . '-' . get_locale() . '.mo', |
|
115 | - trailingslashit( $this->languages_path ) . $this->textdomain . '-' . get_locale() . '.mo', |
|
116 | - ]; |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * Allows overriding the textdomain from a theme. |
|
121 | - * |
|
122 | - * @access public |
|
123 | - * @since 1.0 |
|
124 | - * @param bool $override Whether to override the .mo file loading. Default false. |
|
125 | - * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
|
126 | - * @param string $mofile Path to the MO file. |
|
127 | - * @return bool |
|
128 | - */ |
|
129 | - public function override_load_textdomain( $override, $domain, $mofile ) { |
|
130 | - global $l10n; |
|
131 | - if ( isset( $l10n[ $this->get_theme_textdomain() ] ) ) { |
|
132 | - $l10n[ $this->textdomain ] = $l10n[ $this->get_theme_textdomain() ]; // phpcs:ignore WordPress.WP.GlobalVariablesOverride |
|
133 | - } |
|
134 | - |
|
135 | - // Check if the domain is the one we have defined. |
|
136 | - if ( $this->textdomain === $domain ) { |
|
137 | - return true; |
|
138 | - } |
|
139 | - return $override; |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * Get the theme's textdomain. |
|
144 | - * |
|
145 | - * @access private |
|
146 | - * @since 1.0 |
|
147 | - * @return string |
|
148 | - */ |
|
149 | - private function get_theme_textdomain() { |
|
150 | - if ( '' === $this->theme_textdomain ) { |
|
151 | - |
|
152 | - // Get the textdomain. |
|
153 | - $theme = wp_get_theme(); |
|
154 | - $this->theme_textdomain = $theme->get( 'TextDomain' ); |
|
155 | - |
|
156 | - // If no texdomain was found, use the template folder name. |
|
157 | - if ( ! $this->theme_textdomain ) { |
|
158 | - $this->theme_textdomain = get_template(); |
|
159 | - } |
|
160 | - } |
|
161 | - return $this->theme_textdomain; |
|
162 | - } |
|
21 | + /** |
|
22 | + * The plugin textdomain |
|
23 | + * |
|
24 | + * @access private |
|
25 | + * @since 1.0 |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + private $textdomain; |
|
29 | + |
|
30 | + /** |
|
31 | + * The folder path containing translation files. |
|
32 | + * |
|
33 | + * @access private |
|
34 | + * @since 1.0 |
|
35 | + * @var string |
|
36 | + */ |
|
37 | + private $languages_path; |
|
38 | + |
|
39 | + /** |
|
40 | + * The theme textdomain |
|
41 | + * |
|
42 | + * @access private |
|
43 | + * @since 1.0 |
|
44 | + * @var string |
|
45 | + */ |
|
46 | + private $theme_textdomain = ''; |
|
47 | + |
|
48 | + /** |
|
49 | + * The class constructor. |
|
50 | + * Adds actions & filters to handle the rest of the methods. |
|
51 | + * |
|
52 | + * @access public |
|
53 | + * @since 1.0 |
|
54 | + * @param string $textdomain The textdomain we want to use. Defaults to "kirki". |
|
55 | + * @param string $languages_path The path to languages files. |
|
56 | + */ |
|
57 | + public function __construct( $textdomain = 'kirki', $languages_path = '' ) { |
|
58 | + |
|
59 | + $this->textdomain = $textdomain; |
|
60 | + $this->languages_path = $languages_path; |
|
61 | + // This will only work if we're inside a plugin. |
|
62 | + add_action( 'plugins_loaded', [ $this, 'load_textdomain' ] ); |
|
63 | + |
|
64 | + // If we got this far, then Kirki is embedded in a plugin. |
|
65 | + // We want the theme's textdomain to handle translations. |
|
66 | + add_filter( 'override_load_textdomain', [ $this, 'override_load_textdomain' ], 5, 3 ); |
|
67 | + } |
|
68 | + |
|
69 | + /** |
|
70 | + * Load the plugin textdomain |
|
71 | + * |
|
72 | + * @access public |
|
73 | + * @since 1.0 |
|
74 | + */ |
|
75 | + public function load_textdomain() { |
|
76 | + if ( null !== $this->get_path() ) { |
|
77 | + load_textdomain( $this->textdomain, $this->get_path() ); |
|
78 | + } |
|
79 | + load_plugin_textdomain( $this->textdomain, false, $this->languages_path ); |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Gets the path to a translation file. |
|
84 | + * |
|
85 | + * @access protected |
|
86 | + * @since 1.0 |
|
87 | + * @return string Absolute path to the translation file. |
|
88 | + */ |
|
89 | + protected function get_path() { |
|
90 | + $path_found = false; |
|
91 | + $found_path = null; |
|
92 | + foreach ( $this->get_paths() as $path ) { |
|
93 | + if ( $path_found ) { |
|
94 | + continue; |
|
95 | + } |
|
96 | + $path = wp_normalize_path( $path ); |
|
97 | + if ( file_exists( $path ) ) { |
|
98 | + $path_found = true; |
|
99 | + $found_path = $path; |
|
100 | + } |
|
101 | + } |
|
102 | + return $found_path; |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * Returns an array of paths where translation files may be located. |
|
107 | + * |
|
108 | + * @access protected |
|
109 | + * @since 1.0 |
|
110 | + * @return array |
|
111 | + */ |
|
112 | + protected function get_paths() { |
|
113 | + return [ |
|
114 | + WP_LANG_DIR . '/' . $this->textdomain . '-' . get_locale() . '.mo', |
|
115 | + trailingslashit( $this->languages_path ) . $this->textdomain . '-' . get_locale() . '.mo', |
|
116 | + ]; |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * Allows overriding the textdomain from a theme. |
|
121 | + * |
|
122 | + * @access public |
|
123 | + * @since 1.0 |
|
124 | + * @param bool $override Whether to override the .mo file loading. Default false. |
|
125 | + * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
|
126 | + * @param string $mofile Path to the MO file. |
|
127 | + * @return bool |
|
128 | + */ |
|
129 | + public function override_load_textdomain( $override, $domain, $mofile ) { |
|
130 | + global $l10n; |
|
131 | + if ( isset( $l10n[ $this->get_theme_textdomain() ] ) ) { |
|
132 | + $l10n[ $this->textdomain ] = $l10n[ $this->get_theme_textdomain() ]; // phpcs:ignore WordPress.WP.GlobalVariablesOverride |
|
133 | + } |
|
134 | + |
|
135 | + // Check if the domain is the one we have defined. |
|
136 | + if ( $this->textdomain === $domain ) { |
|
137 | + return true; |
|
138 | + } |
|
139 | + return $override; |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * Get the theme's textdomain. |
|
144 | + * |
|
145 | + * @access private |
|
146 | + * @since 1.0 |
|
147 | + * @return string |
|
148 | + */ |
|
149 | + private function get_theme_textdomain() { |
|
150 | + if ( '' === $this->theme_textdomain ) { |
|
151 | + |
|
152 | + // Get the textdomain. |
|
153 | + $theme = wp_get_theme(); |
|
154 | + $this->theme_textdomain = $theme->get( 'TextDomain' ); |
|
155 | + |
|
156 | + // If no texdomain was found, use the template folder name. |
|
157 | + if ( ! $this->theme_textdomain ) { |
|
158 | + $this->theme_textdomain = get_template(); |
|
159 | + } |
|
160 | + } |
|
161 | + return $this->theme_textdomain; |
|
162 | + } |
|
163 | 163 | } |
@@ -17,124 +17,124 @@ |
||
17 | 17 | */ |
18 | 18 | class Code extends Field { |
19 | 19 | |
20 | - /** |
|
21 | - * The field type. |
|
22 | - * |
|
23 | - * @access public |
|
24 | - * @since 1.0 |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - public $type = 'kirki-code'; |
|
20 | + /** |
|
21 | + * The field type. |
|
22 | + * |
|
23 | + * @access public |
|
24 | + * @since 1.0 |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + public $type = 'kirki-code'; |
|
28 | 28 | |
29 | - /** |
|
30 | - * The control class-name. |
|
31 | - * |
|
32 | - * @access protected |
|
33 | - * @since 0.1 |
|
34 | - * @var string |
|
35 | - */ |
|
36 | - protected $control_class = '\Kirki\Control\Code'; |
|
29 | + /** |
|
30 | + * The control class-name. |
|
31 | + * |
|
32 | + * @access protected |
|
33 | + * @since 0.1 |
|
34 | + * @var string |
|
35 | + */ |
|
36 | + protected $control_class = '\Kirki\Control\Code'; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Filter arguments before creating the setting. |
|
40 | - * |
|
41 | - * @access public |
|
42 | - * @since 0.1 |
|
43 | - * @param array $args The field arguments. |
|
44 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - public function filter_setting_args( $args, $wp_customize ) { |
|
48 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
49 | - $args = parent::filter_setting_args( $args, $wp_customize ); |
|
38 | + /** |
|
39 | + * Filter arguments before creating the setting. |
|
40 | + * |
|
41 | + * @access public |
|
42 | + * @since 0.1 |
|
43 | + * @param array $args The field arguments. |
|
44 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + public function filter_setting_args( $args, $wp_customize ) { |
|
48 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
49 | + $args = parent::filter_setting_args( $args, $wp_customize ); |
|
50 | 50 | |
51 | - // Set the sanitize-callback if none is defined. |
|
52 | - if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
53 | - $args['sanitize_callback'] = function( $value ) { |
|
54 | - /** |
|
55 | - * Code fields should not be filtered by default. |
|
56 | - * Their values usually contain CSS/JS and it it the responsibility |
|
57 | - * of the theme/plugin that registers this field |
|
58 | - * to properly apply any necessary sanitization. |
|
59 | - */ |
|
60 | - return $value; |
|
61 | - }; |
|
62 | - } |
|
63 | - } |
|
64 | - return $args; |
|
65 | - } |
|
51 | + // Set the sanitize-callback if none is defined. |
|
52 | + if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) { |
|
53 | + $args['sanitize_callback'] = function( $value ) { |
|
54 | + /** |
|
55 | + * Code fields should not be filtered by default. |
|
56 | + * Their values usually contain CSS/JS and it it the responsibility |
|
57 | + * of the theme/plugin that registers this field |
|
58 | + * to properly apply any necessary sanitization. |
|
59 | + */ |
|
60 | + return $value; |
|
61 | + }; |
|
62 | + } |
|
63 | + } |
|
64 | + return $args; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Filter arguments before creating the control. |
|
69 | - * |
|
70 | - * @access public |
|
71 | - * @since 0.1 |
|
72 | - * @param array $args The field arguments. |
|
73 | - * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
74 | - * @return array |
|
75 | - */ |
|
76 | - public function filter_control_args( $args, $wp_customize ) { |
|
77 | - if ( $args['settings'] === $this->args['settings'] ) { |
|
78 | - $args = parent::filter_control_args( $args, $wp_customize ); |
|
67 | + /** |
|
68 | + * Filter arguments before creating the control. |
|
69 | + * |
|
70 | + * @access public |
|
71 | + * @since 0.1 |
|
72 | + * @param array $args The field arguments. |
|
73 | + * @param WP_Customize_Manager $wp_customize The customizer instance. |
|
74 | + * @return array |
|
75 | + */ |
|
76 | + public function filter_control_args( $args, $wp_customize ) { |
|
77 | + if ( $args['settings'] === $this->args['settings'] ) { |
|
78 | + $args = parent::filter_control_args( $args, $wp_customize ); |
|
79 | 79 | |
80 | - $args['type'] = 'code_editor'; |
|
80 | + $args['type'] = 'code_editor'; |
|
81 | 81 | |
82 | - $args['input_attrs'] = [ |
|
83 | - 'aria-describedby' => 'kirki-code editor-keyboard-trap-help-1 editor-keyboard-trap-help-2 editor-keyboard-trap-help-3 editor-keyboard-trap-help-4', |
|
84 | - ]; |
|
85 | - if ( ! isset( $args['choices']['language'] ) ) { |
|
86 | - return; |
|
87 | - } |
|
82 | + $args['input_attrs'] = [ |
|
83 | + 'aria-describedby' => 'kirki-code editor-keyboard-trap-help-1 editor-keyboard-trap-help-2 editor-keyboard-trap-help-3 editor-keyboard-trap-help-4', |
|
84 | + ]; |
|
85 | + if ( ! isset( $args['choices']['language'] ) ) { |
|
86 | + return; |
|
87 | + } |
|
88 | 88 | |
89 | - $language = $args['choices']['language']; |
|
90 | - switch ( $language ) { |
|
91 | - case 'json': |
|
92 | - case 'xml': |
|
93 | - $language = 'application/' . $language; |
|
94 | - break; |
|
95 | - case 'http': |
|
96 | - $language = 'message/' . $language; |
|
97 | - break; |
|
98 | - case 'js': |
|
99 | - case 'javascript': |
|
100 | - $language = 'text/javascript'; |
|
101 | - break; |
|
102 | - case 'txt': |
|
103 | - $language = 'text/plain'; |
|
104 | - break; |
|
105 | - case 'css': |
|
106 | - case 'jsx': |
|
107 | - case 'html': |
|
108 | - $language = 'text/' . $language; |
|
109 | - break; |
|
110 | - default: |
|
111 | - $language = ( 'js' === $language ) ? 'javascript' : $language; |
|
112 | - $language = ( 'htm' === $language ) ? 'html' : $language; |
|
113 | - $language = ( 'yml' === $language ) ? 'yaml' : $language; |
|
114 | - $language = 'text/x-' . $language; |
|
115 | - break; |
|
116 | - } |
|
117 | - if ( ! isset( $args['editor_settings'] ) ) { |
|
118 | - $args['editor_settings'] = []; |
|
119 | - } |
|
120 | - if ( ! isset( $args['editor_settings']['codemirror'] ) ) { |
|
121 | - $args['editor_settings']['codemirror'] = []; |
|
122 | - } |
|
123 | - if ( ! isset( $args['editor_settings']['codemirror']['mode'] ) ) { |
|
124 | - $args['editor_settings']['codemirror']['mode'] = $language; |
|
125 | - } |
|
89 | + $language = $args['choices']['language']; |
|
90 | + switch ( $language ) { |
|
91 | + case 'json': |
|
92 | + case 'xml': |
|
93 | + $language = 'application/' . $language; |
|
94 | + break; |
|
95 | + case 'http': |
|
96 | + $language = 'message/' . $language; |
|
97 | + break; |
|
98 | + case 'js': |
|
99 | + case 'javascript': |
|
100 | + $language = 'text/javascript'; |
|
101 | + break; |
|
102 | + case 'txt': |
|
103 | + $language = 'text/plain'; |
|
104 | + break; |
|
105 | + case 'css': |
|
106 | + case 'jsx': |
|
107 | + case 'html': |
|
108 | + $language = 'text/' . $language; |
|
109 | + break; |
|
110 | + default: |
|
111 | + $language = ( 'js' === $language ) ? 'javascript' : $language; |
|
112 | + $language = ( 'htm' === $language ) ? 'html' : $language; |
|
113 | + $language = ( 'yml' === $language ) ? 'yaml' : $language; |
|
114 | + $language = 'text/x-' . $language; |
|
115 | + break; |
|
116 | + } |
|
117 | + if ( ! isset( $args['editor_settings'] ) ) { |
|
118 | + $args['editor_settings'] = []; |
|
119 | + } |
|
120 | + if ( ! isset( $args['editor_settings']['codemirror'] ) ) { |
|
121 | + $args['editor_settings']['codemirror'] = []; |
|
122 | + } |
|
123 | + if ( ! isset( $args['editor_settings']['codemirror']['mode'] ) ) { |
|
124 | + $args['editor_settings']['codemirror']['mode'] = $language; |
|
125 | + } |
|
126 | 126 | |
127 | - if ( 'text/x-scss' === $args['editor_settings']['codemirror']['mode'] ) { |
|
128 | - $args['editor_settings']['codemirror'] = array_merge( |
|
129 | - $args['editor_settings']['codemirror'], |
|
130 | - [ |
|
131 | - 'lint' => false, |
|
132 | - 'autoCloseBrackets' => true, |
|
133 | - 'matchBrackets' => true, |
|
134 | - ] |
|
135 | - ); |
|
136 | - } |
|
137 | - } |
|
138 | - return $args; |
|
139 | - } |
|
127 | + if ( 'text/x-scss' === $args['editor_settings']['codemirror']['mode'] ) { |
|
128 | + $args['editor_settings']['codemirror'] = array_merge( |
|
129 | + $args['editor_settings']['codemirror'], |
|
130 | + [ |
|
131 | + 'lint' => false, |
|
132 | + 'autoCloseBrackets' => true, |
|
133 | + 'matchBrackets' => true, |
|
134 | + ] |
|
135 | + ); |
|
136 | + } |
|
137 | + } |
|
138 | + return $args; |
|
139 | + } |
|
140 | 140 | } |