PluginProbe
Hello Plus / 1.4.0
Hello Plus v1.4.0
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7.0 1.7.1 1.7.2 1.7.3 All 30 releases
hello-plus / modules / content / widgets / hero.php

hero.php in Hello Plus 1.4.0, at modules/content/widgets/hero.php

509 lines 11.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace HelloPlus\Modules\Content\Widgets;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit; // Exit if accessed directly.
7 }
8
9 use Elementor\Controls_Manager;
10 use Elementor\Group_Control_Background;
11 use Elementor\Group_Control_Typography;
12 use Elementor\Widget_Base;
13 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
14 use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
15
16 use HelloPlus\Includes\Utils;
17 use HelloPlus\Modules\Content\Base\Traits\Shared_Content_Traits;
18 use HelloPlus\Modules\Content\Classes\Render\Widget_Hero_Render;
19 use HelloPlus\Modules\Theme\Module as Theme_Module;
20 use HelloPlus\Classes\{
21 Ehp_Button,
22 Ehp_Image,
23 Ehp_Padding,
24 };
25
26 /**
27 * @deprecated 1.3.0 Use `Flex Hero` widget instead.
28 */
29 class Hero extends Widget_Base {
30
31 use Shared_Content_Traits;
32
33 public function get_name(): string {
34 return 'hero';
35 }
36
37 public function get_title(): string {
38 return esc_html__( 'Hero', 'hello-plus' );
39 }
40
41 public function get_categories(): array {
42 return [ Theme_Module::HELLOPLUS_EDITOR_CATEGORY_SLUG ];
43 }
44
45 public function get_keywords(): array {
46 return [ 'hero' ];
47 }
48
49 public function get_icon(): string {
50 return 'eicon-ehp-hero';
51 }
52
53 /* Deprecated Widget */
54 public function show_in_panel() {
55 return false;
56 }
57
58 public function get_style_depends(): array {
59 return [ 'helloplus-hero', 'helloplus-button', 'helloplus-image' ];
60 }
61
62 protected function render(): void {
63 $render_strategy = new Widget_Hero_Render( $this );
64
65 $render_strategy->render();
66 }
67
68 protected function register_controls() {
69 $this->deprecated_notice( Utils::plugin_title(), '1.3.0', '', esc_html__( 'Flex Hero', 'hello-plus' ) );
70
71 $this->add_content_section();
72 $this->add_style_section();
73 }
74
75 protected function add_content_section() {
76 $this->add_content_text_section();
77 $this->add_content_cta_section();
78 $this->add_content_image_section();
79 }
80
81 protected function add_style_section() {
82 $this->add_style_content_section();
83 $this->add_style_cta_section();
84 $this->add_style_image_section();
85 $this->add_style_box_section();
86 }
87
88 protected function add_content_text_section() {
89 $this->start_controls_section(
90 'content_text',
91 [
92 'label' => esc_html__( 'Text', 'hello-plus' ),
93 'tab' => Controls_Manager::TAB_CONTENT,
94 ]
95 );
96
97 $this->add_control(
98 'heading_text',
99 [
100 'label' => esc_html__( 'Heading', 'hello-plus' ),
101 'type' => Controls_Manager::TEXTAREA,
102 'rows' => 6,
103 'default' => esc_html__( '360 digital marketing agency that gets results', 'hello-plus' ),
104 'placeholder' => esc_html__( 'Type your description here', 'hello-plus' ),
105 'dynamic' => [
106 'active' => true,
107 ],
108 ]
109 );
110
111 $this->add_control(
112 'heading_tag',
113 [
114 'label' => esc_html__( 'HTML Tag', 'hello-plus' ),
115 'type' => Controls_Manager::SELECT,
116 'options' => [
117 'h1' => 'H1',
118 'h2' => 'H2',
119 'h3' => 'H3',
120 'h4' => 'H4',
121 'h5' => 'H5',
122 'h6' => 'H6',
123 'div' => 'div',
124 'span' => 'span',
125 'p' => 'p',
126 ],
127 'default' => 'h2',
128 ]
129 );
130
131 $this->add_control(
132 'subheading_text',
133 [
134 'label' => esc_html__( 'Subheading', 'hello-plus' ),
135 'type' => Controls_Manager::TEXTAREA,
136 'rows' => 6,
137 'default' => esc_html__( 'Schedule a free consultation with our team and let’s make things happen!', 'hello-plus' ),
138 'placeholder' => esc_html__( 'Type your description here', 'hello-plus' ),
139 'dynamic' => [
140 'active' => true,
141 ],
142 ]
143 );
144
145 $this->add_control(
146 'subheading_tag',
147 [
148 'label' => esc_html__( 'HTML Tag', 'hello-plus' ),
149 'type' => Controls_Manager::SELECT,
150 'options' => [
151 'h2' => 'H2',
152 'h3' => 'H3',
153 'h4' => 'H4',
154 'h5' => 'H5',
155 'h6' => 'H6',
156 'div' => 'div',
157 'span' => 'span',
158 'p' => 'p',
159 ],
160 'default' => 'h3',
161 ]
162 );
163
164 $this->end_controls_section();
165 }
166
167 protected function add_content_cta_section() {
168 $defaults = [
169 'has_secondary_cta' => false,
170 'primary_cta_button_text_placeholder' => esc_html__( 'Contact us', 'hello-plus' ),
171 ];
172
173 $button = new Ehp_Button( $this, [ 'widget_name' => $this->get_name() ], $defaults );
174 $button->add_content_section();
175 }
176
177 protected function add_content_image_section() {
178 $this->start_controls_section(
179 'content_image',
180 [
181 'label' => esc_html__( 'Image', 'hello-plus' ),
182 'tab' => Controls_Manager::TAB_CONTENT,
183 ]
184 );
185
186 $image = new Ehp_Image( $this, [ 'widget_name' => $this->get_name() ] );
187 $image->add_content_section();
188
189 $this->end_controls_section();
190 }
191
192 protected function add_style_content_section() {
193 $this->start_controls_section(
194 'style_content',
195 [
196 'label' => esc_html__( 'Content', 'hello-plus' ),
197 'tab' => Controls_Manager::TAB_STYLE,
198 ]
199 );
200
201 $this->add_responsive_control(
202 'content_position',
203 [
204 'label' => esc_html__( 'Content Position', 'hello-plus' ),
205 'type' => Controls_Manager::CHOOSE,
206 'options' => [
207 'start' => [
208 'title' => esc_html__( 'Start', 'hello-plus' ),
209 'icon' => 'eicon-align-start-h',
210 ],
211 'center' => [
212 'title' => esc_html__( 'Center', 'hello-plus' ),
213 'icon' => 'eicon-align-center-h',
214 ],
215 'end' => [
216 'title' => esc_html__( 'End', 'hello-plus' ),
217 'icon' => 'eicon-align-end-h',
218 ],
219 ],
220 'default' => 'center',
221 'tablet_default' => 'center',
222 'mobile_default' => 'center',
223 'selectors' => [
224 '{{WRAPPER}} .ehp-hero' => '--hero-content-position: {{VALUE}}; --hero-content-text-align: {{VALUE}};',
225 ],
226 ]
227 );
228
229 $this->add_control(
230 'heading_label',
231 [
232 'label' => esc_html__( 'Heading', 'hello-plus' ),
233 'type' => Controls_Manager::HEADING,
234 ]
235 );
236
237 $this->add_control(
238 'heading_color',
239 [
240 'label' => esc_html__( 'Text Color', 'hello-plus' ),
241 'type' => Controls_Manager::COLOR,
242 'global' => [
243 'default' => Global_Colors::COLOR_PRIMARY,
244 ],
245 'selectors' => [
246 '{{WRAPPER}} .ehp-hero' => '--hero-heading-color: {{VALUE}}',
247 ],
248 ]
249 );
250
251 $this->add_group_control(
252 Group_Control_Typography::get_type(),
253 [
254 'name' => 'heading_typography',
255 'selector' => '{{WRAPPER}} .ehp-hero__heading',
256 'global' => [
257 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
258 ],
259 ]
260 );
261
262 $this->add_responsive_control(
263 'text_width_heading',
264 [
265 'label' => esc_html__( 'Text Width', 'hello-plus' ),
266 'type' => Controls_Manager::SLIDER,
267 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
268 'range' => [
269 'px' => [
270 'max' => 1200,
271 ],
272 '%' => [
273 'max' => 100,
274 ],
275 ],
276 'default' => [
277 'size' => 800,
278 'unit' => 'px',
279 ],
280 'tablet_default' => [
281 'size' => 800,
282 'unit' => 'px',
283 ],
284 'mobile_default' => [
285 'size' => 800,
286 'unit' => 'px',
287 ],
288 'selectors' => [
289 '{{WRAPPER}} .ehp-hero' => '--hero-text-width-heading: {{SIZE}}{{UNIT}};',
290 ],
291 ]
292 );
293
294 $this->add_control(
295 'subheading_label',
296 [
297 'label' => esc_html__( 'Subheading', 'hello-plus' ),
298 'type' => Controls_Manager::HEADING,
299 'separator' => 'before',
300 ]
301 );
302
303 $this->add_control(
304 'subheading_color',
305 [
306 'label' => esc_html__( 'Text Color', 'hello-plus' ),
307 'type' => Controls_Manager::COLOR,
308 'global' => [
309 'default' => Global_Colors::COLOR_SECONDARY,
310 ],
311 'selectors' => [
312 '{{WRAPPER}} .ehp-hero' => '--hero-subheading-color: {{VALUE}}',
313 ],
314 ]
315 );
316
317 $this->add_group_control(
318 Group_Control_Typography::get_type(),
319 [
320 'name' => 'subheading_typography',
321 'selector' => '{{WRAPPER}} .ehp-hero__subheading',
322 'global' => [
323 'default' => Global_Typography::TYPOGRAPHY_SECONDARY,
324 ],
325 ]
326 );
327
328 $this->add_responsive_control(
329 'text_width_subheading',
330 [
331 'label' => esc_html__( 'Text Width', 'hello-plus' ),
332 'type' => Controls_Manager::SLIDER,
333 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
334 'range' => [
335 'px' => [
336 'max' => 1200,
337 ],
338 '%' => [
339 'max' => 100,
340 ],
341 ],
342 'default' => [
343 'size' => 440,
344 'unit' => 'px',
345 ],
346 'tablet_default' => [
347 'size' => 440,
348 'unit' => 'px',
349 ],
350 'mobile_default' => [
351 'size' => 440,
352 'unit' => 'px',
353 ],
354 'selectors' => [
355 '{{WRAPPER}} .ehp-hero' => '--hero-text-width-subheading: {{SIZE}}{{UNIT}};',
356 ],
357 ]
358 );
359
360 $this->end_controls_section();
361 }
362
363 protected function add_style_cta_section() {
364 $this->start_controls_section(
365 'style_cta',
366 [
367 'label' => esc_html__( 'CTA Button', 'hello-plus' ),
368 'tab' => Controls_Manager::TAB_STYLE,
369 ]
370 );
371
372 $defaults = [
373 'has_secondary_cta' => false,
374 ];
375
376 $button = new Ehp_Button( $this, [ 'widget_name' => $this->get_name() ], $defaults );
377 $button->add_style_controls();
378
379 $this->end_controls_section();
380 }
381
382 protected function add_style_image_section() {
383 $this->start_controls_section(
384 'style_image_section',
385 [
386 'label' => esc_html__( 'Image', 'hello-plus' ),
387 'tab' => Controls_Manager::TAB_STYLE,
388 ]
389 );
390
391 $image = new Ehp_Image( $this, [ 'widget_name' => $this->get_name() ] );
392 $image->add_style_controls();
393
394 $this->end_controls_section();
395 }
396
397 protected function add_style_box_section() {
398 $this->start_controls_section(
399 'style_box_section',
400 [
401 'label' => esc_html__( 'Box', 'hello-plus' ),
402 'tab' => Controls_Manager::TAB_STYLE,
403 ]
404 );
405
406 $this->add_control(
407 'box_background_label',
408 [
409 'label' => esc_html__( 'Background', 'hello-plus' ),
410 'type' => Controls_Manager::HEADING,
411 ]
412 );
413
414 $this->add_group_control(
415 Group_Control_Background::get_type(),
416 [
417 'name' => 'background',
418 'types' => [ 'classic', 'gradient' ],
419 'exclude' => [ 'image' ],
420 'selector' => '{{WRAPPER}} .ehp-hero',
421 'fields_options' => [
422 'background' => [
423 'default' => 'classic',
424 ],
425 ],
426 ]
427 );
428
429 $this->add_responsive_control(
430 'content_gap',
431 [
432 'label' => esc_html__( 'Element Spacing', 'hello-plus' ),
433 'type' => Controls_Manager::SLIDER,
434 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
435 'range' => [
436 'px' => [
437 'max' => 100,
438 ],
439 'em' => [
440 'max' => 5,
441 ],
442 'rem' => [
443 'max' => 5,
444 ],
445 '%' => [
446 'max' => 100,
447 ],
448 ],
449 'default' => [
450 'size' => 40,
451 'unit' => 'px',
452 ],
453 'tablet_default' => [
454 'size' => 28,
455 'unit' => 'px',
456 ],
457 'mobile_default' => [
458 'size' => 20,
459 'unit' => 'px',
460 ],
461 'selectors' => [
462 '{{WRAPPER}} .ehp-hero' => '--hero-content-text-gap: {{SIZE}}{{UNIT}};',
463 ],
464 'separator' => 'before',
465 ]
466 );
467
468 $padding = new Ehp_Padding( $this, [
469 'widget_name' => $this->get_name(),
470 'container_prefix' => 'box',
471 ] );
472 $padding->add_style_controls();
473
474 $this->add_control(
475 'box_full_screen_height',
476 [
477 'label' => esc_html__( 'Full Screen Height', 'hello-plus' ),
478 'type' => Controls_Manager::SWITCHER,
479 'label_on' => esc_html__( 'Yes', 'hello-plus' ),
480 'label_off' => esc_html__( 'No', 'hello-plus' ),
481 'return_value' => 'yes',
482 'default' => '',
483 'tablet_default' => '',
484 'mobile_default' => '',
485 'separator' => 'before',
486 ]
487 );
488
489 $configured_breakpoints = $this->get_configured_breakpoints();
490
491 $this->add_control(
492 'box_full_screen_height_controls',
493 [
494 'label' => esc_html__( 'Apply Full Screen Height on', 'hello-plus' ),
495 'type' => Controls_Manager::SELECT2,
496 'label_block' => true,
497 'multiple' => true,
498 'options' => $configured_breakpoints['devices_options'],
499 'default' => $configured_breakpoints['active_devices'],
500 'condition' => [
501 'box_full_screen_height' => 'yes',
502 ],
503 ]
504 );
505
506 $this->end_controls_section();
507 }
508 }
509