1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
<?php
/**
* Astra Theme Customizer Configuration Builder.
*
* @package astra-builder
* @author Astra
* @copyright Copyright (c) 2020, Astra
* @link https://wpastra.com/
* @since 3.0.0
*/
// No direct access, please.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Register Builder Customizer Configurations.
*
* @since 3.0.0
*/
class Astra_Html_Component_Configs {
/**
* Register Builder Customizer Configurations.
*
* @param Array $configurations Configurations.
* @param string $builder_type Builder Type.
* @param string $section Section.
*
* @since 3.0.0
* @return Array Astra Customizer Configurations with updated configurations.
*/
public static function register_configuration( $configurations, $builder_type = 'header', $section = 'section-hb-html-' ) {
$html_config = array();
if ( 'footer' === $builder_type ) {
$class_obj = Astra_Builder_Footer::get_instance();
$component_limit = defined( 'ASTRA_EXT_VER' ) ? Astra_Builder_Helper::$component_limit : Astra_Builder_Helper::$num_of_footer_html;
} else {
$class_obj = Astra_Builder_Header::get_instance();
$component_limit = defined( 'ASTRA_EXT_VER' ) ? Astra_Builder_Helper::$component_limit : Astra_Builder_Helper::$num_of_header_html;
}
for ( $index = 1; $index <= $component_limit; $index++ ) {
$_section = $section . $index;
$_configs = array(
/**
* Option: Builder Tabs
*/
array(
'name' => $_section . '-ast-context-tabs',
'section' => $_section,
'type' => 'control',
'control' => 'ast-builder-header-control',
'priority' => 0,
'description' => '',
),
/*
* Builder section
*/
array(
'name' => $_section,
'type' => 'section',
'priority' => 60,
/* translators: %s Index */
'title' => sprintf( __( 'HTML %s', 'astra' ), $index ),
'panel' => 'panel-' . $builder_type . '-builder-group',
'clone_index' => $index,
'clone_type' => $builder_type . '-html',
),
/**
* Option: Html Editor.
*/
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $builder_type . '-html-' . $index . ']',
'type' => 'control',
'control' => 'ast-html-editor',
'section' => $_section,
'transport' => 'postMessage',
'priority' => 4,
'default' => astra_get_option( $builder_type . '-html-' . $index ),
'input_attrs' => array(
'id' => $builder_type . '-html-' . $index,
),
'partial' => array(
'selector' => '.ast-' . $builder_type . '-html-' . $index,
'render_callback' => array( $class_obj, $builder_type . '_html_' . $index ),
'fallback_refresh' => false,
),
'context' => Astra_Builder_Helper::$general_tab,
),
/**
* Option: HTML Color.
*/
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $builder_type . '-html-' . $index . 'color]',
'default' => astra_get_option( $builder_type . '-html-' . $index . 'color' ),
'type' => 'control',
'section' => $_section,
'priority' => 8,
'transport' => 'postMessage',
'control' => 'ast-responsive-color',
'responsive' => true,
'rgba' => true,
'title' => __( 'Text Color', 'astra' ),
'context' => Astra_Builder_Helper::$design_tab,
),
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $builder_type . '-html-' . $index . '-link-group]',
'default' => astra_get_option( $builder_type . '-html-' . $index . '-color-group' ),
'type' => 'control',
'control' => 'ast-color-group',
'title' => __( 'Link Color', 'astra' ),
'section' => $_section,
'transport' => 'postMessage',
'priority' => 8,
'context' => Astra_Builder_Helper::$design_tab,
'responsive' => true,
'divider' => array( 'ast_class' => 'ast-bottom-divider' ),
),
/**
* Option: Link Color.
*/
array(
'name' => $builder_type . '-html-' . $index . 'link-color',
'default' => astra_get_option( $builder_type . '-html-' . $index . 'link-color' ),
'type' => 'sub-control',
'section' => $_section,
'priority' => 9,
'transport' => 'postMessage',
'control' => 'ast-responsive-color',
'responsive' => true,
'rgba' => true,
'parent' => ASTRA_THEME_SETTINGS . '[' . $builder_type . '-html-' . $index . '-link-group]',
'title' => __( 'Normal', 'astra' ),
'context' => Astra_Builder_Helper::$design_tab,
),
/**
* Option: Link Hover Color.
*/
array(
'name' => $builder_type . '-html-' . $index . 'link-h-color',
'default' => astra_get_option( $builder_type . '-html-' . $index . 'link-h-color' ),
'type' => 'sub-control',
'section' => $_section,
'priority' => 10,
'transport' => 'postMessage',
'control' => 'ast-responsive-color',
'responsive' => true,
'rgba' => true,
'parent' => ASTRA_THEME_SETTINGS . '[' . $builder_type . '-html-' . $index . '-link-group]',
'title' => __( 'Hover', 'astra' ),
'context' => Astra_Builder_Helper::$design_tab,
),
/**
* Option: Margin Space
*/
array(
'name' => ASTRA_THEME_SETTINGS . '[' . $_section . '-margin]',
'default' => astra_get_option( $_section . '-margin' ),
'type' => 'control',
'transport' => 'postMessage',
'control' => 'ast-responsive-spacing',
'sanitize_callback' => array( 'Astra_Customizer_Sanitizes', 'sanitize_responsive_spacing' ),
'section' => $_section,
'priority' => 220,
'title' => __( 'Margin', 'astra' ),
'divider' => array( 'ast_class' => 'ast-top-divider' ),
'linked_choices' => true,
'unit_choices' => array( 'px', 'em', '%' ),
'choices' => array(
'top' => __( 'Top', 'astra' ),
'right' => __( 'Right', 'astra' ),
'bottom' => __( 'Bottom', 'astra' ),
'left' => __( 'Left', 'astra' ),
),
'context' => Astra_Builder_Helper::$design_tab,
),
);
if ( 'footer' === $builder_type ) {
$_configs[] = array(
'name' => ASTRA_THEME_SETTINGS . '[footer-html-' . $index . '-alignment]',
'default' => astra_get_option( 'footer-html-' . $index . '-alignment' ),
'type' => 'control',
'control' => 'ast-selector',
'section' => $_section,
'priority' => 6,
'title' => __( 'Alignment', 'astra' ),
'context' => Astra_Builder_Helper::$general_tab,
'transport' => 'postMessage',
'choices' => array(
'left' => 'align-left',
'center' => 'align-center',
'right' => 'align-right',
),
'divider' => array( 'ast_class' => 'ast-top-divider' ),
);
}
$html_config[] = Astra_Builder_Base_Configuration::prepare_visibility_tab( $_section, $builder_type );
$html_config[] = Astra_Builder_Base_Configuration::prepare_typography_options( $_section );
$html_config[] = $_configs;
}
$html_config = call_user_func_array( 'array_merge', $html_config + array( array() ) );
$configurations = array_merge( $configurations, $html_config );
return $configurations;
}
}
/**
* Kicking this off by creating object of this class.
*/
new Astra_Html_Component_Configs();
|