PluginProbe
Bricksable for Bricks Builder / 1.5.3
Bricksable for Bricks Builder v1.5.3
1.2.9 1.3.0 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.31 1.4.32 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 All 132 releases
bricksable / includes / elements / multi-heading / element-multi-heading.php

element-multi-heading.php in Bricksable for Bricks Builder 1.5.3, at includes/elements/multi-heading/element-multi-heading.php

350 lines 10.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Bricks;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 class Bricksable_Multi_Heading extends Element {
9 public $category = 'bricksable';
10 public $name = 'ba-multi-heading';
11 public $icon = 'ti-uppercase';
12
13 public function get_label() {
14 return esc_html__( 'Multi Heading', 'bricksable' );
15 }
16 public function set_control_groups() {
17 $this->control_groups['content'] = array(
18 'title' => esc_html__( 'Heading', 'bricksable' ),
19 'tab' => 'content',
20 );
21
22 $this->control_groups['style'] = array(
23 'title' => esc_html__( 'Heading Styles', 'bricksable' ),
24 'tab' => 'content',
25 );
26 }
27 public function set_controls() {
28 $this->controls['multi_heading_item'] = array(
29 'tab' => 'content',
30 'group' => 'content',
31 'label' => esc_html__( 'Multi Heading Text', 'bricksable' ),
32 'type' => 'repeater',
33 'titleProperty' => 'text',
34 'default' => array(
35 array( 'text' => 'Multi ' ),
36 array( 'text' => 'Heading' ),
37 ),
38 'placeholder' => esc_html__( 'Heading block', 'bricksable' ),
39 'fields' => array(
40 'text' => array(
41 'type' => 'text',
42 'hasDynamicData' => 'text',
43 ),
44 'heading_link' => array(
45 'label' => esc_html__( 'Link to', 'bricksable' ),
46 'type' => 'link',
47 'pasteStyles' => false,
48 ),
49 'heading_typography' => array(
50 'label' => esc_html__( 'Typography', 'bricksable' ),
51 'type' => 'typography',
52 'css' => array(
53 array(
54 'property' => 'typography',
55 'repeaterSelector' => '.ba-multi-heading-text',
56 ),
57 ),
58 'inline' => true,
59 'small' => true,
60 ),
61 'heading_background' => array(
62 'label' => esc_html__( 'Background', 'bricksable' ),
63 'type' => 'background',
64 'css' => array(
65 array(
66 'property' => 'background',
67 'repeaterSelector' => '.ba-multi-heading-text',
68 ),
69 ),
70 'exclude' => array(
71 'videoUrl',
72 'videoScale',
73 ),
74 'inline' => true,
75 'small' => true,
76 ),
77 'use_background_text_mask' => array(
78 'label' => esc_html__( 'Use Background Text Mask', 'bricksable' ),
79 'type' => 'checkbox',
80 'inline' => true,
81 'description' => esc_html__( 'Upload a background below', 'bricksable' ),
82 ),
83 'background_text_mask_image' => array(
84 'label' => esc_html__( 'Text Mask Image', 'bricksable' ),
85 'type' => 'image',
86 'css' => array(
87 array(
88 'property' => 'background-image',
89 'selector' => '.ba-multi-heading-text-mask',
90 ),
91 ),
92 'required' => array( 'use_background_text_mask', '=', true ),
93 ),
94 'use_gradient' => array(
95 'label' => esc_html__( 'Use Gradient / Overlay', 'bricksable' ),
96 'type' => 'checkbox',
97 'inline' => true,
98 ),
99 'heading_gradient' => array(
100 'label' => esc_html__( 'Gradient', 'bricksable' ),
101 'type' => 'gradient',
102 'css' => array(
103 array(
104 'property' => 'background-image',
105 'repeaterSelector' => '.ba-multi-heading-text',
106 ),
107 ),
108 'required' => array( 'use_gradient', '=', true ),
109 ),
110 'heading_border' => array(
111 'label' => esc_html__( 'Border', 'bricksable' ),
112 'type' => 'border',
113 'css' => array(
114 array(
115 'property' => 'border',
116 'repeaterSelector' => '.ba-multi-heading-text',
117 ),
118 ),
119 'inline' => true,
120 'small' => true,
121 ),
122 'heading_box_shadow' => array(
123 'label' => esc_html__( 'Box Shadow', 'bricksable' ),
124 'type' => 'box-shadow',
125 'css' => array(
126 array(
127 'property' => 'box-shadow',
128 ),
129 ),
130 ),
131 'heading_padding' => array(
132 'label' => esc_html__( 'Padding', 'bricksable' ),
133 'type' => 'dimensions',
134 'css' => array(
135 array(
136 'property' => 'padding',
137 'repeaterSelector' => '.ba-multi-heading-text',
138 ),
139 ),
140 ),
141 ),
142 );
143
144 $this->controls['tag'] = array(
145 'tab' => 'content',
146 'group' => 'content',
147 'label' => esc_html__( 'Tag', 'bricksable' ),
148 'type' => 'select',
149 'options' => array(
150 'h1' => esc_html__( 'Heading 1 (h1)', 'bricksable' ),
151 'h2' => esc_html__( 'Heading 2 (h2)', 'bricksable' ),
152 'h3' => esc_html__( 'Heading 3 (h3)', 'bricksable' ),
153 'h4' => esc_html__( 'Heading 4 (h4)', 'bricksable' ),
154 'h5' => esc_html__( 'Heading 5 (h5)', 'bricksable' ),
155 'h6' => esc_html__( 'Heading 6 (h6)', 'bricksable' ),
156 'div' => esc_html__( 'Division (div)', 'bricksable' ),
157 ),
158 'inline' => true,
159 'clearable' => false,
160 'pasteStyles' => false,
161 'default' => 'h3',
162 );
163
164 $this->controls['style'] = array(
165 'tab' => 'content',
166 'group' => 'content',
167 'label' => esc_html__( 'Style', 'bricksable' ),
168 'type' => 'select',
169 'options' => $this->control_options['styles'],
170 'inline' => true,
171 'reset' => true,
172 'placeholder' => esc_html__( 'None', 'bricksable' ),
173 );
174
175 $this->controls['link'] = array(
176 'tab' => 'content',
177 'group' => 'content',
178 'label' => esc_html__( 'Link to', 'bricksable' ),
179 'type' => 'link',
180 'pasteStyles' => false,
181 );
182
183 $this->controls['heading_justifyItems'] = array(
184 'tab' => 'style',
185 'group' => 'style',
186 'label' => esc_html__( 'Vertical', 'bricksable' ),
187 'type' => 'justify-content',
188 'exclude' => array(
189 'space-between',
190 'space-around',
191 'space-evenly',
192 ),
193 'css' => array(
194 array(
195 'property' => 'justify-content',
196 'selector' => '.bricks-heading',
197 ),
198 ),
199 'inline' => true,
200 'required' => array( 'heading_display', '=', 'row' ),
201 );
202 $this->controls['heading_AlignItems'] = array(
203 'tab' => 'style',
204 'group' => 'style',
205 'label' => esc_html__( 'Horizontal', 'bricksable' ),
206 'type' => 'align-items',
207 'exclude' => array( 'stretch' ),
208 'css' => array(
209 array(
210 'property' => 'align-items',
211 'selector' => '.bricks-heading',
212 ),
213 ),
214 'inline' => true,
215 'required' => array( 'heading_display', '=', 'column' ),
216 );
217
218 $this->controls['gap'] = array(
219 'tab' => 'style',
220 'group' => 'style',
221 'label' => esc_html__( 'Gap', 'bricksable' ),
222 'type' => 'number',
223 'css' => array(
224 array(
225 'property' => 'gap',
226 'selector' => '.bricks-heading',
227 ),
228 ),
229 'units' => array(
230 'px' => array(
231 'min' => 0,
232 'max' => 80,
233 'step' => 1,
234 ),
235 'em' => array(
236 'min' => 0,
237 'max' => 10,
238 'step' => 0.1,
239 ),
240 ),
241 'description' => esc_html__( 'Adjust the gap between the headings.', 'bricksable' ),
242 );
243
244 $this->controls['heading_display'] = array(
245 'tab' => 'content',
246 'group' => 'style',
247 'label' => esc_html__( 'Display', 'bricksable' ),
248 'type' => 'select',
249 'default' => 'row',
250 'options' => array(
251 'row' => esc_html__( 'Row', 'bricksable' ),
252 'column' => esc_html__( 'Column', 'bricksable' ),
253 ),
254 'css' => array(
255 array(
256 'property' => 'flex-direction',
257 'selector' => '.bricks-heading',
258 ),
259 ),
260 );
261 }
262
263 public function enqueue_scripts() {
264 wp_enqueue_style( 'ba-multi-heading' );
265 }
266
267 public function render() {
268 $settings = $this->settings;
269
270 $tag = isset( $settings['tag'] ) ? esc_html( $settings['tag'] ) : 'h3';
271
272 $heading_classes = array(
273 'bricks-heading',
274 'bricks-heading-' . $tag,
275 );
276
277 if ( isset( $settings['style'] ) ) {
278 $heading_classes[] = 'bricks-color-' . $settings['style'];
279 }
280
281 if ( isset( $settings['separator'] ) ) {
282 $heading_classes[] = 'has-separator';
283 }
284
285 $this->set_attribute( 'heading', $tag );
286 $this->set_attribute( 'heading', 'class', $heading_classes );
287
288 // Link.
289 if ( isset( $settings['link'] ) ) {
290 $this->set_link_attributes( 'a', $settings['link'] );
291 }
292
293 // Render.
294 //phpcs:ignore
295 $output = '';
296
297 if ( substr( BRICKS_VERSION, 0, 3 ) > '1.3' ) {
298 $output .= "<div {$this->render_attributes( '_root' )}>";
299 }
300 $output .= '<' . $this->render_attributes( 'heading' ) . '>';
301
302 if ( isset( $settings['link'] ) ) {
303 $output .= '<a ' . $this->render_attributes( 'a' ) . '>';
304 }
305
306 foreach ( $settings['multi_heading_item'] as $index => $item ) {
307 $multi_heading_item_classes = array(
308 'ba-multi-heading-text',
309 'repeater-item',
310 );
311
312 $this->set_attribute( "multi-heading-item-$index", 'span' );
313 $this->set_attribute( "multi-heading-item-$index", 'class', $multi_heading_item_classes );
314 $this->set_attribute( "multi-heading-item-text-mask-$index", 'span' );
315 $this->set_attribute( "multi-heading-item-text-mask-$index", 'class', 'ba-multi-heading-text-mask' );
316 // Link.
317 if ( isset( $item['heading_link'] ) ) {
318 $this->set_link_attributes( "multi-heading-link-$index", $item['heading_link'] );
319 $output .= '<a ' . $this->render_attributes( "multi-heading-link-$index" ) . '>';
320 }
321
322 // Heading.
323 if ( isset( $item['use_background_text_mask'] ) ) {
324 $output .= '<' . $this->render_attributes( "multi-heading-item-$index" ) . '><' . $this->render_attributes( "multi-heading-item-text-mask-$index" ) . '>' . $item['text'] . '</span></span>';
325 } else {
326 $output .= '<' . $this->render_attributes( "multi-heading-item-$index" ) . '>' . $item['text'] . '</span>';
327 }
328
329 // Link.
330 if ( isset( $item['heading_link'] ) ) {
331 $output .= '</a>';
332 }
333 }
334
335 if ( isset( $settings['link'] ) ) {
336 $output .= '</a>';
337 }
338
339 $output .= '</' . $tag . '>';
340
341 if ( substr( BRICKS_VERSION, 0, 3 ) > '1.3' ) {
342 $output .= '</div>';
343 }
344
345 //phpcs:ignore
346 echo $output;
347
348 }
349 }
350