column.php
1055 lines
| 1 | <?php |
| 2 | namespace Elementor; |
| 3 | |
| 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | exit; // Exit if accessed directly. |
| 6 | } |
| 7 | |
| 8 | /** |
| 9 | * Elementor column element. |
| 10 | * |
| 11 | * Elementor column handler class is responsible for initializing the column |
| 12 | * element. |
| 13 | * |
| 14 | * @since 1.0.0 |
| 15 | */ |
| 16 | class Element_Column extends Element_Base { |
| 17 | |
| 18 | /** |
| 19 | * Get column name. |
| 20 | * |
| 21 | * Retrieve the column name. |
| 22 | * |
| 23 | * @since 1.0.0 |
| 24 | * @access public |
| 25 | * |
| 26 | * @return string Column name. |
| 27 | */ |
| 28 | public function get_name() { |
| 29 | return 'column'; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Get element type. |
| 34 | * |
| 35 | * Retrieve the element type, in this case `column`. |
| 36 | * |
| 37 | * @since 2.1.0 |
| 38 | * @access public |
| 39 | * @static |
| 40 | * |
| 41 | * @return string The type. |
| 42 | */ |
| 43 | public static function get_type() { |
| 44 | return 'column'; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Get column title. |
| 49 | * |
| 50 | * Retrieve the column title. |
| 51 | * |
| 52 | * @since 1.0.0 |
| 53 | * @access public |
| 54 | * |
| 55 | * @return string Column title. |
| 56 | */ |
| 57 | public function get_title() { |
| 58 | return __( 'Column', 'elementor' ); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Get column icon. |
| 63 | * |
| 64 | * Retrieve the column icon. |
| 65 | * |
| 66 | * @since 1.0.0 |
| 67 | * @access public |
| 68 | * |
| 69 | * @return string Column icon. |
| 70 | */ |
| 71 | public function get_icon() { |
| 72 | return 'eicon-column'; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Get initial config. |
| 77 | * |
| 78 | * Retrieve the current section initial configuration. |
| 79 | * |
| 80 | * Adds more configuration on top of the controls list, the tabs assigned to |
| 81 | * the control, element name, type, icon and more. This method also adds |
| 82 | * section presets. |
| 83 | * |
| 84 | * @since 2.9.0 |
| 85 | * @access protected |
| 86 | * |
| 87 | * @return array The initial config. |
| 88 | */ |
| 89 | protected function get_initial_config() { |
| 90 | $config = parent::get_initial_config(); |
| 91 | |
| 92 | $config['controls'] = $this->get_controls(); |
| 93 | $config['tabs_controls'] = $this->get_tabs_controls(); |
| 94 | |
| 95 | return $config; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Register column controls. |
| 100 | * |
| 101 | * Used to add new controls to the column element. |
| 102 | * |
| 103 | * @since 1.0.0 |
| 104 | * @access protected |
| 105 | */ |
| 106 | protected function _register_controls() { |
| 107 | // Section Layout. |
| 108 | $this->start_controls_section( |
| 109 | 'layout', |
| 110 | [ |
| 111 | 'label' => __( 'Layout', 'elementor' ), |
| 112 | 'tab' => Controls_Manager::TAB_LAYOUT, |
| 113 | ] |
| 114 | ); |
| 115 | |
| 116 | // Element Name for the Navigator |
| 117 | $this->add_control( |
| 118 | '_title', |
| 119 | [ |
| 120 | 'label' => __( 'Title', 'elementor' ), |
| 121 | 'type' => Controls_Manager::HIDDEN, |
| 122 | 'render_type' => 'none', |
| 123 | ] |
| 124 | ); |
| 125 | |
| 126 | $this->add_responsive_control( |
| 127 | '_inline_size', |
| 128 | [ |
| 129 | 'label' => __( 'Column Width', 'elementor' ) . ' (%)', |
| 130 | 'type' => Controls_Manager::NUMBER, |
| 131 | 'min' => 2, |
| 132 | 'max' => 98, |
| 133 | 'required' => true, |
| 134 | 'device_args' => [ |
| 135 | Controls_Stack::RESPONSIVE_TABLET => [ |
| 136 | 'max' => 100, |
| 137 | 'required' => false, |
| 138 | ], |
| 139 | Controls_Stack::RESPONSIVE_MOBILE => [ |
| 140 | 'max' => 100, |
| 141 | 'required' => false, |
| 142 | ], |
| 143 | ], |
| 144 | 'min_affected_device' => [ |
| 145 | Controls_Stack::RESPONSIVE_DESKTOP => Controls_Stack::RESPONSIVE_TABLET, |
| 146 | Controls_Stack::RESPONSIVE_TABLET => Controls_Stack::RESPONSIVE_TABLET, |
| 147 | ], |
| 148 | 'selectors' => [ |
| 149 | '{{WRAPPER}}' => 'width: {{VALUE}}%', |
| 150 | ], |
| 151 | ] |
| 152 | ); |
| 153 | |
| 154 | $is_legacy_mode_active = Plugin::instance()->get_legacy_mode( 'elementWrappers' ); |
| 155 | $main_selector_element = $is_legacy_mode_active ? 'column' : 'widget'; |
| 156 | $widget_wrap_child = $is_legacy_mode_active ? ' > .elementor-widget-wrap' : ''; |
| 157 | $column_wrap_child = $is_legacy_mode_active ? ' > .elementor-column-wrap' : ''; |
| 158 | |
| 159 | $this->add_responsive_control( |
| 160 | 'content_position', |
| 161 | [ |
| 162 | 'label' => __( 'Vertical Align', 'elementor' ), |
| 163 | 'type' => Controls_Manager::SELECT, |
| 164 | 'default' => '', |
| 165 | 'options' => [ |
| 166 | '' => __( 'Default', 'elementor' ), |
| 167 | 'top' => __( 'Top', 'elementor' ), |
| 168 | 'center' => __( 'Middle', 'elementor' ), |
| 169 | 'bottom' => __( 'Bottom', 'elementor' ), |
| 170 | 'space-between' => __( 'Space Between', 'elementor' ), |
| 171 | 'space-around' => __( 'Space Around', 'elementor' ), |
| 172 | 'space-evenly' => __( 'Space Evenly', 'elementor' ), |
| 173 | ], |
| 174 | 'selectors_dictionary' => [ |
| 175 | 'top' => 'flex-start', |
| 176 | 'bottom' => 'flex-end', |
| 177 | ], |
| 178 | 'selectors' => [ |
| 179 | // TODO: The following line is for BC since 2.7.0 |
| 180 | '.elementor-bc-flex-widget {{WRAPPER}}.elementor-column .elementor-' . $main_selector_element . '-wrap' => 'align-items: {{VALUE}}', |
| 181 | // This specificity is intended to make sure column css overwrites section css on vertical alignment (content_position) |
| 182 | '{{WRAPPER}}.elementor-column.elementor-element[data-element_type="column"] > .elementor-' . $main_selector_element . '-wrap.elementor-element-populated' . $widget_wrap_child => 'align-content: {{VALUE}}; align-items: {{VALUE}};', |
| 183 | ], |
| 184 | ] |
| 185 | ); |
| 186 | |
| 187 | $this->add_responsive_control( |
| 188 | 'align', |
| 189 | [ |
| 190 | 'label' => __( 'Horizontal Align', 'elementor' ), |
| 191 | 'type' => Controls_Manager::SELECT, |
| 192 | 'default' => '', |
| 193 | 'options' => [ |
| 194 | '' => __( 'Default', 'elementor' ), |
| 195 | 'flex-start' => __( 'Start', 'elementor' ), |
| 196 | 'center' => __( 'Center', 'elementor' ), |
| 197 | 'flex-end' => __( 'End', 'elementor' ), |
| 198 | 'space-between' => __( 'Space Between', 'elementor' ), |
| 199 | 'space-around' => __( 'Space Around', 'elementor' ), |
| 200 | 'space-evenly' => __( 'Space Evenly', 'elementor' ), |
| 201 | ], |
| 202 | 'selectors' => [ |
| 203 | '{{WRAPPER}}.elementor-column' . $column_wrap_child . ' > .elementor-widget-wrap' => 'justify-content: {{VALUE}}', |
| 204 | ], |
| 205 | ] |
| 206 | ); |
| 207 | |
| 208 | $space_between_widgets_selector = $is_legacy_mode_active ? '> .elementor-column-wrap ' : ''; |
| 209 | |
| 210 | $this->add_responsive_control( |
| 211 | 'space_between_widgets', |
| 212 | [ |
| 213 | 'label' => __( 'Widgets Space', 'elementor' ) . ' (px)', |
| 214 | 'type' => Controls_Manager::NUMBER, |
| 215 | 'placeholder' => 20, |
| 216 | 'selectors' => [ |
| 217 | '{{WRAPPER}} ' . $space_between_widgets_selector . '> .elementor-widget-wrap > .elementor-widget:not(.elementor-widget__width-auto):not(.elementor-widget__width-initial):not(:last-child):not(.elementor-absolute)' => 'margin-bottom: {{VALUE}}px', //Need the full path for exclude the inner section |
| 218 | ], |
| 219 | ] |
| 220 | ); |
| 221 | |
| 222 | $possible_tags = [ |
| 223 | 'div', |
| 224 | 'header', |
| 225 | 'footer', |
| 226 | 'main', |
| 227 | 'article', |
| 228 | 'section', |
| 229 | 'aside', |
| 230 | 'nav', |
| 231 | ]; |
| 232 | |
| 233 | $options = [ |
| 234 | '' => __( 'Default', 'elementor' ), |
| 235 | ] + array_combine( $possible_tags, $possible_tags ); |
| 236 | |
| 237 | $this->add_control( |
| 238 | 'html_tag', |
| 239 | [ |
| 240 | 'label' => __( 'HTML Tag', 'elementor' ), |
| 241 | 'type' => Controls_Manager::SELECT, |
| 242 | 'options' => $options, |
| 243 | 'render_type' => 'none', |
| 244 | ] |
| 245 | ); |
| 246 | |
| 247 | $this->end_controls_section(); |
| 248 | |
| 249 | $this->start_controls_section( |
| 250 | 'section_style', |
| 251 | [ |
| 252 | 'label' => __( 'Background', 'elementor' ), |
| 253 | 'tab' => Controls_Manager::TAB_STYLE, |
| 254 | ] |
| 255 | ); |
| 256 | |
| 257 | $this->start_controls_tabs( 'tabs_background' ); |
| 258 | |
| 259 | $this->start_controls_tab( |
| 260 | 'tab_background_normal', |
| 261 | [ |
| 262 | 'label' => __( 'Normal', 'elementor' ), |
| 263 | ] |
| 264 | ); |
| 265 | |
| 266 | $this->add_group_control( |
| 267 | Group_Control_Background::get_type(), |
| 268 | [ |
| 269 | 'name' => 'background', |
| 270 | 'types' => [ 'classic', 'gradient', 'slideshow' ], |
| 271 | 'selector' => '{{WRAPPER}}:not(.elementor-motion-effects-element-type-background) > .elementor-' . $main_selector_element . '-wrap, {{WRAPPER}} > .elementor-' . $main_selector_element . '-wrap > .elementor-motion-effects-container > .elementor-motion-effects-layer', |
| 272 | 'fields_options' => [ |
| 273 | 'background' => [ |
| 274 | 'frontend_available' => true, |
| 275 | ], |
| 276 | ], |
| 277 | ] |
| 278 | ); |
| 279 | |
| 280 | $this->end_controls_tab(); |
| 281 | |
| 282 | $this->start_controls_tab( |
| 283 | 'tab_background_hover', |
| 284 | [ |
| 285 | 'label' => __( 'Hover', 'elementor' ), |
| 286 | ] |
| 287 | ); |
| 288 | |
| 289 | $this->add_group_control( |
| 290 | Group_Control_Background::get_type(), |
| 291 | [ |
| 292 | 'name' => 'background_hover', |
| 293 | 'selector' => '{{WRAPPER}}:hover > .elementor-element-populated', |
| 294 | ] |
| 295 | ); |
| 296 | |
| 297 | $this->add_control( |
| 298 | 'background_hover_transition', |
| 299 | [ |
| 300 | 'label' => __( 'Transition Duration', 'elementor' ), |
| 301 | 'type' => Controls_Manager::SLIDER, |
| 302 | 'default' => [ |
| 303 | 'size' => 0.3, |
| 304 | ], |
| 305 | 'range' => [ |
| 306 | 'px' => [ |
| 307 | 'max' => 3, |
| 308 | 'step' => 0.1, |
| 309 | ], |
| 310 | ], |
| 311 | 'render_type' => 'ui', |
| 312 | 'separator' => 'before', |
| 313 | ] |
| 314 | ); |
| 315 | |
| 316 | $this->end_controls_tab(); |
| 317 | |
| 318 | $this->end_controls_tabs(); |
| 319 | |
| 320 | $this->end_controls_section(); |
| 321 | |
| 322 | // Section Column Background Overlay. |
| 323 | $this->start_controls_section( |
| 324 | 'section_background_overlay', |
| 325 | [ |
| 326 | 'label' => __( 'Background Overlay', 'elementor' ), |
| 327 | 'tab' => Controls_Manager::TAB_STYLE, |
| 328 | 'condition' => [ |
| 329 | 'background_background' => [ 'classic', 'gradient' ], |
| 330 | ], |
| 331 | ] |
| 332 | ); |
| 333 | |
| 334 | $this->start_controls_tabs( 'tabs_background_overlay' ); |
| 335 | |
| 336 | $this->start_controls_tab( |
| 337 | 'tab_background_overlay_normal', |
| 338 | [ |
| 339 | 'label' => __( 'Normal', 'elementor' ), |
| 340 | ] |
| 341 | ); |
| 342 | |
| 343 | $this->add_group_control( |
| 344 | Group_Control_Background::get_type(), |
| 345 | [ |
| 346 | 'name' => 'background_overlay', |
| 347 | 'selector' => '{{WRAPPER}} > .elementor-element-populated > .elementor-background-overlay', |
| 348 | ] |
| 349 | ); |
| 350 | |
| 351 | $this->add_control( |
| 352 | 'background_overlay_opacity', |
| 353 | [ |
| 354 | 'label' => __( 'Opacity', 'elementor' ), |
| 355 | 'type' => Controls_Manager::SLIDER, |
| 356 | 'default' => [ |
| 357 | 'size' => .5, |
| 358 | ], |
| 359 | 'range' => [ |
| 360 | 'px' => [ |
| 361 | 'max' => 1, |
| 362 | 'step' => 0.01, |
| 363 | ], |
| 364 | ], |
| 365 | 'selectors' => [ |
| 366 | '{{WRAPPER}} > .elementor-element-populated > .elementor-background-overlay' => 'opacity: {{SIZE}};', |
| 367 | ], |
| 368 | 'condition' => [ |
| 369 | 'background_overlay_background' => [ 'classic', 'gradient' ], |
| 370 | ], |
| 371 | ] |
| 372 | ); |
| 373 | |
| 374 | $this->add_group_control( |
| 375 | Group_Control_Css_Filter::get_type(), |
| 376 | [ |
| 377 | 'name' => 'css_filters', |
| 378 | 'selector' => '{{WRAPPER}} > .elementor-element-populated > .elementor-background-overlay', |
| 379 | ] |
| 380 | ); |
| 381 | |
| 382 | $this->add_control( |
| 383 | 'overlay_blend_mode', |
| 384 | [ |
| 385 | 'label' => __( 'Blend Mode', 'elementor' ), |
| 386 | 'type' => Controls_Manager::SELECT, |
| 387 | 'options' => [ |
| 388 | '' => __( 'Normal', 'elementor' ), |
| 389 | 'multiply' => 'Multiply', |
| 390 | 'screen' => 'Screen', |
| 391 | 'overlay' => 'Overlay', |
| 392 | 'darken' => 'Darken', |
| 393 | 'lighten' => 'Lighten', |
| 394 | 'color-dodge' => 'Color Dodge', |
| 395 | 'saturation' => 'Saturation', |
| 396 | 'color' => 'Color', |
| 397 | 'luminosity' => 'Luminosity', |
| 398 | ], |
| 399 | 'selectors' => [ |
| 400 | '{{WRAPPER}} > .elementor-element-populated > .elementor-background-overlay' => 'mix-blend-mode: {{VALUE}}', |
| 401 | ], |
| 402 | ] |
| 403 | ); |
| 404 | |
| 405 | $this->end_controls_tab(); |
| 406 | |
| 407 | $this->start_controls_tab( |
| 408 | 'tab_background_overlay_hover', |
| 409 | [ |
| 410 | 'label' => __( 'Hover', 'elementor' ), |
| 411 | ] |
| 412 | ); |
| 413 | |
| 414 | $this->add_group_control( |
| 415 | Group_Control_Background::get_type(), |
| 416 | [ |
| 417 | 'name' => 'background_overlay_hover', |
| 418 | 'selector' => '{{WRAPPER}}:hover > .elementor-element-populated > .elementor-background-overlay', |
| 419 | ] |
| 420 | ); |
| 421 | |
| 422 | $this->add_control( |
| 423 | 'background_overlay_hover_opacity', |
| 424 | [ |
| 425 | 'label' => __( 'Opacity', 'elementor' ), |
| 426 | 'type' => Controls_Manager::SLIDER, |
| 427 | 'default' => [ |
| 428 | 'size' => .5, |
| 429 | ], |
| 430 | 'range' => [ |
| 431 | 'px' => [ |
| 432 | 'max' => 1, |
| 433 | 'step' => 0.01, |
| 434 | ], |
| 435 | ], |
| 436 | 'selectors' => [ |
| 437 | '{{WRAPPER}}:hover > .elementor-element-populated > .elementor-background-overlay' => 'opacity: {{SIZE}};', |
| 438 | ], |
| 439 | 'condition' => [ |
| 440 | 'background_overlay_hover_background' => [ 'classic', 'gradient' ], |
| 441 | ], |
| 442 | ] |
| 443 | ); |
| 444 | |
| 445 | $this->add_group_control( |
| 446 | Group_Control_Css_Filter::get_type(), |
| 447 | [ |
| 448 | 'name' => 'css_filters_hover', |
| 449 | 'selector' => '{{WRAPPER}}:hover > .elementor-element-populated > .elementor-background-overlay', |
| 450 | ] |
| 451 | ); |
| 452 | |
| 453 | $this->add_control( |
| 454 | 'background_overlay_hover_transition', |
| 455 | [ |
| 456 | 'label' => __( 'Transition Duration', 'elementor' ), |
| 457 | 'type' => Controls_Manager::SLIDER, |
| 458 | 'default' => [ |
| 459 | 'size' => 0.3, |
| 460 | ], |
| 461 | 'range' => [ |
| 462 | 'px' => [ |
| 463 | 'max' => 3, |
| 464 | 'step' => 0.1, |
| 465 | ], |
| 466 | ], |
| 467 | 'render_type' => 'ui', |
| 468 | 'separator' => 'before', |
| 469 | ] |
| 470 | ); |
| 471 | |
| 472 | $this->end_controls_tab(); |
| 473 | |
| 474 | $this->end_controls_tabs(); |
| 475 | |
| 476 | $this->end_controls_section(); |
| 477 | |
| 478 | $this->start_controls_section( |
| 479 | 'section_border', |
| 480 | [ |
| 481 | 'label' => __( 'Border', 'elementor' ), |
| 482 | 'tab' => Controls_Manager::TAB_STYLE, |
| 483 | ] |
| 484 | ); |
| 485 | |
| 486 | $this->start_controls_tabs( 'tabs_border' ); |
| 487 | |
| 488 | $this->start_controls_tab( |
| 489 | 'tab_border_normal', |
| 490 | [ |
| 491 | 'label' => __( 'Normal', 'elementor' ), |
| 492 | ] |
| 493 | ); |
| 494 | |
| 495 | $this->add_group_control( |
| 496 | Group_Control_Border::get_type(), |
| 497 | [ |
| 498 | 'name' => 'border', |
| 499 | 'selector' => '{{WRAPPER}} > .elementor-element-populated', |
| 500 | ] |
| 501 | ); |
| 502 | |
| 503 | $this->add_responsive_control( |
| 504 | 'border_radius', |
| 505 | [ |
| 506 | 'label' => __( 'Border Radius', 'elementor' ), |
| 507 | 'type' => Controls_Manager::DIMENSIONS, |
| 508 | 'size_units' => [ 'px', '%' ], |
| 509 | 'selectors' => [ |
| 510 | '{{WRAPPER}} > .elementor-element-populated, {{WRAPPER}} > .elementor-element-populated > .elementor-background-overlay, {{WRAPPER}} > .elementor-background-slideshow' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 511 | ], |
| 512 | ] |
| 513 | ); |
| 514 | |
| 515 | $this->add_group_control( |
| 516 | Group_Control_Box_Shadow::get_type(), |
| 517 | [ |
| 518 | 'name' => 'box_shadow', |
| 519 | 'selector' => '{{WRAPPER}} > .elementor-element-populated', |
| 520 | ] |
| 521 | ); |
| 522 | |
| 523 | $this->end_controls_tab(); |
| 524 | |
| 525 | $this->start_controls_tab( |
| 526 | 'tab_border_hover', |
| 527 | [ |
| 528 | 'label' => __( 'Hover', 'elementor' ), |
| 529 | ] |
| 530 | ); |
| 531 | |
| 532 | $this->add_group_control( |
| 533 | Group_Control_Border::get_type(), |
| 534 | [ |
| 535 | 'name' => 'border_hover', |
| 536 | 'selector' => '{{WRAPPER}}:hover > .elementor-element-populated', |
| 537 | ] |
| 538 | ); |
| 539 | |
| 540 | $this->add_responsive_control( |
| 541 | 'border_radius_hover', |
| 542 | [ |
| 543 | 'label' => __( 'Border Radius', 'elementor' ), |
| 544 | 'type' => Controls_Manager::DIMENSIONS, |
| 545 | 'size_units' => [ 'px', '%' ], |
| 546 | 'selectors' => [ |
| 547 | '{{WRAPPER}}:hover > .elementor-element-populated, {{WRAPPER}}:hover > .elementor-element-populated > .elementor-background-overlay' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 548 | ], |
| 549 | ] |
| 550 | ); |
| 551 | |
| 552 | $this->add_group_control( |
| 553 | Group_Control_Box_Shadow::get_type(), |
| 554 | [ |
| 555 | 'name' => 'box_shadow_hover', |
| 556 | 'selector' => '{{WRAPPER}}:hover > .elementor-element-populated', |
| 557 | ] |
| 558 | ); |
| 559 | |
| 560 | $this->add_control( |
| 561 | 'border_hover_transition', |
| 562 | [ |
| 563 | 'label' => __( 'Transition Duration', 'elementor' ), |
| 564 | 'type' => Controls_Manager::SLIDER, |
| 565 | 'separator' => 'before', |
| 566 | 'default' => [ |
| 567 | 'size' => 0.3, |
| 568 | ], |
| 569 | 'range' => [ |
| 570 | 'px' => [ |
| 571 | 'max' => 3, |
| 572 | 'step' => 0.1, |
| 573 | ], |
| 574 | ], |
| 575 | 'conditions' => [ |
| 576 | 'relation' => 'or', |
| 577 | 'terms' => [ |
| 578 | [ |
| 579 | 'name' => 'background_background', |
| 580 | 'operator' => '!==', |
| 581 | 'value' => '', |
| 582 | ], |
| 583 | [ |
| 584 | 'name' => 'border_border', |
| 585 | 'operator' => '!==', |
| 586 | 'value' => '', |
| 587 | ], |
| 588 | ], |
| 589 | ], |
| 590 | 'selectors' => [ |
| 591 | '{{WRAPPER}} > .elementor-element-populated' => 'transition: background {{background_hover_transition.SIZE}}s, border {{SIZE}}s, border-radius {{SIZE}}s, box-shadow {{SIZE}}s', |
| 592 | '{{WRAPPER}} > .elementor-element-populated > .elementor-background-overlay' => 'transition: background {{background_overlay_hover_transition.SIZE}}s, border-radius {{SIZE}}s, opacity {{background_overlay_hover_transition.SIZE}}s', |
| 593 | ], |
| 594 | ] |
| 595 | ); |
| 596 | |
| 597 | $this->end_controls_tab(); |
| 598 | |
| 599 | $this->end_controls_tabs(); |
| 600 | |
| 601 | $this->end_controls_section(); |
| 602 | |
| 603 | // Section Typography. |
| 604 | $this->start_controls_section( |
| 605 | 'section_typo', |
| 606 | [ |
| 607 | 'label' => __( 'Typography', 'elementor' ), |
| 608 | 'type' => Controls_Manager::SECTION, |
| 609 | 'tab' => Controls_Manager::TAB_STYLE, |
| 610 | ] |
| 611 | ); |
| 612 | |
| 613 | $this->add_control( |
| 614 | 'heading_color', |
| 615 | [ |
| 616 | 'label' => __( 'Heading Color', 'elementor' ), |
| 617 | 'type' => Controls_Manager::COLOR, |
| 618 | 'default' => '', |
| 619 | 'selectors' => [ |
| 620 | '{{WRAPPER}} .elementor-element-populated .elementor-heading-title' => 'color: {{VALUE}};', |
| 621 | ], |
| 622 | 'separator' => 'none', |
| 623 | ] |
| 624 | ); |
| 625 | |
| 626 | $this->add_control( |
| 627 | 'color_text', |
| 628 | [ |
| 629 | 'label' => __( 'Text Color', 'elementor' ), |
| 630 | 'type' => Controls_Manager::COLOR, |
| 631 | 'default' => '', |
| 632 | 'selectors' => [ |
| 633 | '{{WRAPPER}} > .elementor-element-populated' => 'color: {{VALUE}};', |
| 634 | ], |
| 635 | ] |
| 636 | ); |
| 637 | |
| 638 | $this->add_control( |
| 639 | 'color_link', |
| 640 | [ |
| 641 | 'label' => __( 'Link Color', 'elementor' ), |
| 642 | 'type' => Controls_Manager::COLOR, |
| 643 | 'default' => '', |
| 644 | 'selectors' => [ |
| 645 | '{{WRAPPER}} .elementor-element-populated a' => 'color: {{VALUE}};', |
| 646 | ], |
| 647 | ] |
| 648 | ); |
| 649 | |
| 650 | $this->add_control( |
| 651 | 'color_link_hover', |
| 652 | [ |
| 653 | 'label' => __( 'Link Hover Color', 'elementor' ), |
| 654 | 'type' => Controls_Manager::COLOR, |
| 655 | 'default' => '', |
| 656 | 'selectors' => [ |
| 657 | '{{WRAPPER}} .elementor-element-populated a:hover' => 'color: {{VALUE}};', |
| 658 | ], |
| 659 | ] |
| 660 | ); |
| 661 | |
| 662 | $this->add_control( |
| 663 | 'text_align', |
| 664 | [ |
| 665 | 'label' => __( 'Text Align', 'elementor' ), |
| 666 | 'type' => Controls_Manager::CHOOSE, |
| 667 | 'options' => [ |
| 668 | 'left' => [ |
| 669 | 'title' => __( 'Left', 'elementor' ), |
| 670 | 'icon' => 'eicon-text-align-left', |
| 671 | ], |
| 672 | 'center' => [ |
| 673 | 'title' => __( 'Center', 'elementor' ), |
| 674 | 'icon' => 'eicon-text-align-center', |
| 675 | ], |
| 676 | 'right' => [ |
| 677 | 'title' => __( 'Right', 'elementor' ), |
| 678 | 'icon' => 'eicon-text-align-right', |
| 679 | ], |
| 680 | ], |
| 681 | 'selectors' => [ |
| 682 | '{{WRAPPER}} > .elementor-element-populated' => 'text-align: {{VALUE}};', |
| 683 | ], |
| 684 | ] |
| 685 | ); |
| 686 | |
| 687 | $this->end_controls_section(); |
| 688 | |
| 689 | // Section Advanced. |
| 690 | $this->start_controls_section( |
| 691 | 'section_advanced', |
| 692 | [ |
| 693 | 'label' => __( 'Advanced', 'elementor' ), |
| 694 | 'type' => Controls_Manager::SECTION, |
| 695 | 'tab' => Controls_Manager::TAB_ADVANCED, |
| 696 | ] |
| 697 | ); |
| 698 | |
| 699 | $this->add_responsive_control( |
| 700 | 'margin', |
| 701 | [ |
| 702 | 'label' => __( 'Margin', 'elementor' ), |
| 703 | 'type' => Controls_Manager::DIMENSIONS, |
| 704 | 'size_units' => [ 'px', 'em', '%', 'rem' ], |
| 705 | 'selectors' => [ |
| 706 | '{{WRAPPER}} > .elementor-element-populated' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 707 | ], |
| 708 | ] |
| 709 | ); |
| 710 | |
| 711 | $this->add_responsive_control( |
| 712 | 'padding', |
| 713 | [ |
| 714 | 'label' => __( 'Padding', 'elementor' ), |
| 715 | 'type' => Controls_Manager::DIMENSIONS, |
| 716 | 'size_units' => [ 'px', 'em', '%', 'rem' ], |
| 717 | 'selectors' => [ |
| 718 | '{{WRAPPER}} > .elementor-element-populated' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 719 | ], |
| 720 | ] |
| 721 | ); |
| 722 | |
| 723 | $this->add_responsive_control( |
| 724 | 'z_index', |
| 725 | [ |
| 726 | 'label' => __( 'Z-Index', 'elementor' ), |
| 727 | 'type' => Controls_Manager::NUMBER, |
| 728 | 'min' => 0, |
| 729 | 'selectors' => [ |
| 730 | '{{WRAPPER}}' => 'z-index: {{VALUE}};', |
| 731 | ], |
| 732 | ] |
| 733 | ); |
| 734 | |
| 735 | $this->add_control( |
| 736 | '_element_id', |
| 737 | [ |
| 738 | 'label' => __( 'CSS ID', 'elementor' ), |
| 739 | 'type' => Controls_Manager::TEXT, |
| 740 | 'default' => '', |
| 741 | 'dynamic' => [ |
| 742 | 'active' => true, |
| 743 | ], |
| 744 | 'title' => __( 'Add your custom id WITHOUT the Pound key. e.g: my-id', 'elementor' ), |
| 745 | 'style_transfer' => false, |
| 746 | 'classes' => 'elementor-control-direction-ltr', |
| 747 | ] |
| 748 | ); |
| 749 | |
| 750 | $this->add_control( |
| 751 | 'css_classes', |
| 752 | [ |
| 753 | 'label' => __( 'CSS Classes', 'elementor' ), |
| 754 | 'type' => Controls_Manager::TEXT, |
| 755 | 'default' => '', |
| 756 | 'dynamic' => [ |
| 757 | 'active' => true, |
| 758 | ], |
| 759 | 'prefix_class' => '', |
| 760 | 'title' => __( 'Add your custom class WITHOUT the dot. e.g: my-class', 'elementor' ), |
| 761 | 'classes' => 'elementor-control-direction-ltr', |
| 762 | ] |
| 763 | ); |
| 764 | |
| 765 | // TODO: Backward comparability for deprecated controls |
| 766 | $this->add_control( |
| 767 | 'screen_sm', |
| 768 | [ |
| 769 | 'type' => Controls_Manager::HIDDEN, |
| 770 | ] |
| 771 | ); |
| 772 | |
| 773 | $this->add_control( |
| 774 | 'screen_sm_width', |
| 775 | [ |
| 776 | 'type' => Controls_Manager::HIDDEN, |
| 777 | 'condition' => [ |
| 778 | 'screen_sm' => [ 'custom' ], |
| 779 | ], |
| 780 | 'prefix_class' => 'elementor-sm-', |
| 781 | ] |
| 782 | ); |
| 783 | // END Backward comparability |
| 784 | |
| 785 | $this->end_controls_section(); |
| 786 | |
| 787 | $this->start_controls_section( |
| 788 | 'section_effects', |
| 789 | [ |
| 790 | 'label' => __( 'Motion Effects', 'elementor' ), |
| 791 | 'tab' => Controls_Manager::TAB_ADVANCED, |
| 792 | ] |
| 793 | ); |
| 794 | |
| 795 | $this->add_responsive_control( |
| 796 | 'animation', |
| 797 | [ |
| 798 | 'label' => __( 'Entrance Animation', 'elementor' ), |
| 799 | 'type' => Controls_Manager::ANIMATION, |
| 800 | 'frontend_available' => true, |
| 801 | ] |
| 802 | ); |
| 803 | |
| 804 | $this->add_control( |
| 805 | 'animation_duration', |
| 806 | [ |
| 807 | 'label' => __( 'Animation Duration', 'elementor' ), |
| 808 | 'type' => Controls_Manager::SELECT, |
| 809 | 'default' => '', |
| 810 | 'options' => [ |
| 811 | 'slow' => __( 'Slow', 'elementor' ), |
| 812 | '' => __( 'Normal', 'elementor' ), |
| 813 | 'fast' => __( 'Fast', 'elementor' ), |
| 814 | ], |
| 815 | 'prefix_class' => 'animated-', |
| 816 | 'condition' => [ |
| 817 | 'animation!' => '', |
| 818 | ], |
| 819 | ] |
| 820 | ); |
| 821 | |
| 822 | $this->add_control( |
| 823 | 'animation_delay', |
| 824 | [ |
| 825 | 'label' => __( 'Animation Delay', 'elementor' ) . ' (ms)', |
| 826 | 'type' => Controls_Manager::NUMBER, |
| 827 | 'default' => '', |
| 828 | 'min' => 0, |
| 829 | 'step' => 100, |
| 830 | 'condition' => [ |
| 831 | 'animation!' => '', |
| 832 | ], |
| 833 | 'render_type' => 'none', |
| 834 | 'frontend_available' => true, |
| 835 | ] |
| 836 | ); |
| 837 | |
| 838 | $this->end_controls_section(); |
| 839 | |
| 840 | $this->start_controls_section( |
| 841 | '_section_responsive', |
| 842 | [ |
| 843 | 'label' => __( 'Responsive', 'elementor' ), |
| 844 | 'tab' => Controls_Manager::TAB_ADVANCED, |
| 845 | ] |
| 846 | ); |
| 847 | |
| 848 | $this->add_control( |
| 849 | 'responsive_description', |
| 850 | [ |
| 851 | 'raw' => __( 'Responsive visibility will take effect only on preview or live page, and not while editing in Elementor.', 'elementor' ), |
| 852 | 'type' => Controls_Manager::RAW_HTML, |
| 853 | 'content_classes' => 'elementor-descriptor', |
| 854 | ] |
| 855 | ); |
| 856 | |
| 857 | $this->add_control( |
| 858 | 'hide_desktop', |
| 859 | [ |
| 860 | 'label' => __( 'Hide On Desktop', 'elementor' ), |
| 861 | 'type' => Controls_Manager::SWITCHER, |
| 862 | 'default' => '', |
| 863 | 'prefix_class' => 'elementor-', |
| 864 | 'label_on' => 'Hide', |
| 865 | 'label_off' => 'Show', |
| 866 | 'return_value' => 'hidden-desktop', |
| 867 | ] |
| 868 | ); |
| 869 | |
| 870 | $this->add_control( |
| 871 | 'hide_tablet', |
| 872 | [ |
| 873 | 'label' => __( 'Hide On Tablet', 'elementor' ), |
| 874 | 'type' => Controls_Manager::SWITCHER, |
| 875 | 'default' => '', |
| 876 | 'prefix_class' => 'elementor-', |
| 877 | 'label_on' => 'Hide', |
| 878 | 'label_off' => 'Show', |
| 879 | 'return_value' => 'hidden-tablet', |
| 880 | ] |
| 881 | ); |
| 882 | |
| 883 | $this->add_control( |
| 884 | 'hide_mobile', |
| 885 | [ |
| 886 | 'label' => __( 'Hide On Mobile', 'elementor' ), |
| 887 | 'type' => Controls_Manager::SWITCHER, |
| 888 | 'default' => '', |
| 889 | 'prefix_class' => 'elementor-', |
| 890 | 'label_on' => 'Hide', |
| 891 | 'label_off' => 'Show', |
| 892 | 'return_value' => 'hidden-phone', |
| 893 | ] |
| 894 | ); |
| 895 | |
| 896 | $this->end_controls_section(); |
| 897 | |
| 898 | Plugin::$instance->controls_manager->add_custom_attributes_controls( $this ); |
| 899 | |
| 900 | Plugin::$instance->controls_manager->add_custom_css_controls( $this ); |
| 901 | } |
| 902 | |
| 903 | /** |
| 904 | * Render column output in the editor. |
| 905 | * |
| 906 | * Used to generate the live preview, using a Backbone JavaScript template. |
| 907 | * |
| 908 | * @since 2.9.0 |
| 909 | * @access protected |
| 910 | */ |
| 911 | protected function content_template() { |
| 912 | $is_legacy_mode_active = Plugin::instance()->get_legacy_mode( 'elementWrappers' ); |
| 913 | $wrapper_element = $is_legacy_mode_active ? 'column' : 'widget'; |
| 914 | |
| 915 | ?> |
| 916 | <div class="elementor-<?php echo $wrapper_element; ?>-wrap"> |
| 917 | <div class="elementor-background-overlay"></div> |
| 918 | <?php if ( $is_legacy_mode_active ) { ?> |
| 919 | <div class="elementor-widget-wrap"></div> |
| 920 | <?php } ?> |
| 921 | </div> |
| 922 | <?php |
| 923 | } |
| 924 | |
| 925 | /** |
| 926 | * Before column rendering. |
| 927 | * |
| 928 | * Used to add stuff before the column element. |
| 929 | * |
| 930 | * @since 1.0.0 |
| 931 | * @access public |
| 932 | */ |
| 933 | public function before_render() { |
| 934 | $settings = $this->get_settings_for_display(); |
| 935 | |
| 936 | $has_background_overlay = in_array( $settings['background_overlay_background'], [ 'classic', 'gradient' ], true ) || |
| 937 | in_array( $settings['background_overlay_hover_background'], [ 'classic', 'gradient' ], true ); |
| 938 | |
| 939 | $is_legacy_mode_active = Plugin::instance()->get_legacy_mode( 'elementWrappers' ); |
| 940 | $wrapper_attribute_string = $is_legacy_mode_active ? '_inner_wrapper' : '_widget_wrapper'; |
| 941 | |
| 942 | $column_wrap_classes = $is_legacy_mode_active ? [ 'elementor-column-wrap' ] : [ 'elementor-widget-wrap' ]; |
| 943 | |
| 944 | if ( $this->get_children() ) { |
| 945 | $column_wrap_classes[] = 'elementor-element-populated'; |
| 946 | } |
| 947 | |
| 948 | $this->add_render_attribute( [ |
| 949 | '_inner_wrapper' => [ |
| 950 | 'class' => $column_wrap_classes, |
| 951 | ], |
| 952 | '_widget_wrapper' => [ |
| 953 | 'class' => $is_legacy_mode_active ? 'elementor-widget-wrap' : $column_wrap_classes, |
| 954 | ], |
| 955 | '_background_overlay' => [ |
| 956 | 'class' => [ 'elementor-background-overlay' ], |
| 957 | ], |
| 958 | ] ); |
| 959 | ?> |
| 960 | <<?php echo $this->get_html_tag() . ' ' . $this->get_render_attribute_string( '_wrapper' ); ?>> |
| 961 | <div <?php echo $this->get_render_attribute_string( $wrapper_attribute_string ); ?>> |
| 962 | <?php if ( $has_background_overlay ) : ?> |
| 963 | <div <?php echo $this->get_render_attribute_string( '_background_overlay' ); ?>></div> |
| 964 | <?php endif; ?> |
| 965 | <?php if ( $is_legacy_mode_active ) : ?> |
| 966 | <div <?php echo $this->get_render_attribute_string( '_widget_wrapper' ); ?>> |
| 967 | <?php endif; ?> |
| 968 | <?php |
| 969 | } |
| 970 | |
| 971 | /** |
| 972 | * After column rendering. |
| 973 | * |
| 974 | * Used to add stuff after the column element. |
| 975 | * |
| 976 | * @since 1.0.0 |
| 977 | * @access public |
| 978 | */ |
| 979 | public function after_render() { |
| 980 | if ( Plugin::instance()->get_legacy_mode( 'elementWrappers' ) ) { ?> |
| 981 | </div> |
| 982 | <?php } ?> |
| 983 | </div> |
| 984 | </<?php echo $this->get_html_tag(); ?>> |
| 985 | <?php |
| 986 | } |
| 987 | |
| 988 | /** |
| 989 | * Add column render attributes. |
| 990 | * |
| 991 | * Used to add attributes to the current column wrapper HTML tag. |
| 992 | * |
| 993 | * @since 1.3.0 |
| 994 | * @access protected |
| 995 | */ |
| 996 | protected function _add_render_attributes() { |
| 997 | |
| 998 | $is_inner = $this->get_data( 'isInner' ); |
| 999 | |
| 1000 | $column_type = ! empty( $is_inner ) ? 'inner' : 'top'; |
| 1001 | |
| 1002 | $settings = $this->get_settings(); |
| 1003 | |
| 1004 | $this->add_render_attribute( |
| 1005 | '_wrapper', 'class', [ |
| 1006 | 'elementor-column', |
| 1007 | 'elementor-col-' . $settings['_column_size'], |
| 1008 | 'elementor-' . $column_type . '-column', |
| 1009 | ] |
| 1010 | ); |
| 1011 | |
| 1012 | parent::_add_render_attributes(); |
| 1013 | } |
| 1014 | |
| 1015 | /** |
| 1016 | * Get default child type. |
| 1017 | * |
| 1018 | * Retrieve the column child type based on element data. |
| 1019 | * |
| 1020 | * @since 1.0.0 |
| 1021 | * @access protected |
| 1022 | * |
| 1023 | * @param array $element_data Element ID. |
| 1024 | * |
| 1025 | * @return Element_Base Column default child type. |
| 1026 | */ |
| 1027 | protected function _get_default_child_type( array $element_data ) { |
| 1028 | if ( 'section' === $element_data['elType'] ) { |
| 1029 | return Plugin::$instance->elements_manager->get_element_types( 'section' ); |
| 1030 | } |
| 1031 | |
| 1032 | return Plugin::$instance->widgets_manager->get_widget_types( $element_data['widgetType'] ); |
| 1033 | } |
| 1034 | |
| 1035 | /** |
| 1036 | * Get HTML tag. |
| 1037 | * |
| 1038 | * Retrieve the column element HTML tag. |
| 1039 | * |
| 1040 | * @since 1.5.3 |
| 1041 | * @access private |
| 1042 | * |
| 1043 | * @return string Column HTML tag. |
| 1044 | */ |
| 1045 | private function get_html_tag() { |
| 1046 | $html_tag = $this->get_settings( 'html_tag' ); |
| 1047 | |
| 1048 | if ( empty( $html_tag ) ) { |
| 1049 | $html_tag = 'div'; |
| 1050 | } |
| 1051 | |
| 1052 | return $html_tag; |
| 1053 | } |
| 1054 | } |
| 1055 |