PluginProbe
Bricksable for Bricks Builder / 1.3.0
Bricksable for Bricks Builder v1.3.0
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 / element-multi-heading.php

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

336 lines 9.5 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 'repeaterSelector' => '.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' => 'slider',
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 render() {
264 $settings = $this->settings;
265
266 $tag = isset( $settings['tag'] ) ? esc_html( $settings['tag'] ) : 'h3';
267
268 $heading_classes = array(
269 'bricks-heading',
270 'bricks-heading-' . $tag,
271 );
272
273 if ( isset( $settings['style'] ) ) {
274 $heading_classes[] = 'bricks-color-' . $settings['style'];
275 }
276
277 if ( isset( $settings['separator'] ) ) {
278 $heading_classes[] = 'has-separator';
279 }
280
281 $this->set_attribute( 'heading', $tag );
282 $this->set_attribute( 'heading', 'class', $heading_classes );
283
284 // Link.
285 if ( isset( $settings['link'] ) ) {
286 $this->set_link_attributes( 'a', $settings['link'] );
287 }
288
289 // Render.
290 //phpcs:ignore
291 $output = '<' . $this->render_attributes( 'heading' ) . '>';
292
293 if ( isset( $settings['link'] ) ) {
294 $output .= '<a ' . $this->render_attributes( 'a' ) . '>';
295 }
296
297 foreach ( $settings['multi_heading_item'] as $index => $item ) {
298 $multi_heading_item_classes = array(
299 'ba-multi-heading-text',
300 );
301
302 $this->set_attribute( "multi-heading-item-$index", 'span' );
303 $this->set_attribute( "multi-heading-item-$index", 'class', $multi_heading_item_classes );
304 $this->set_attribute( "multi-heading-item-text-mask-$index", 'span' );
305 $this->set_attribute( "multi-heading-item-text-mask-$index", 'class', 'ba-multi-heading-text-mask' );
306 // Link.
307 if ( isset( $item['heading_link'] ) ) {
308 $this->set_link_attributes( "multi-heading-link-$index", $item['heading_link'] );
309 $output .= '<a ' . $this->render_attributes( "multi-heading-link-$index" ) . '>';
310 }
311
312 // Heading.
313 if ( isset ( $item['use_background_text_mask'] ) && true === $item['use_background_text_mask'] ) {
314 $output .= '<' . $this->render_attributes( "multi-heading-item-$index" ) . '><' . $this->render_attributes( "multi-heading-item-text-mask-$index" ) . '>' . $item['text'] . '</span></span>';
315 } else {
316 $output .= '<' . $this->render_attributes( "multi-heading-item-$index" ) . '>' . $item['text'] . '</span>';
317 }
318
319 // Link.
320 if ( isset( $item['heading_link'] ) ) {
321 $output .= '</a>';
322 }
323 }
324
325 if ( isset( $settings['link'] ) ) {
326 $output .= '</a>';
327 }
328
329 $output .= '</' . $tag . '>';
330
331 //phpcs:ignore
332 echo $output;
333
334 }
335 }
336