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