| @@ -1,9 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor; |
| 3 | 3 | |
| 4 | -use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager; | |
| 5 | - | |
| 6 | 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | 5 | exit; // Exit if accessed directly. |
| 8 | 6 | } |
| 9 | 7 | |
| @@ -31,8 +29,20 @@ | ||
| 31 | 29 | */ |
| 32 | 30 | private $children; |
| 33 | 31 | |
| 34 | 32 | /** |
| 33 | + * Element render attributes. | |
| 34 | + * | |
| 35 | + * Holds all the render attributes of the element. Used to store data like | |
| 36 | + * the HTML class name and the class value, or HTML element ID name and value. | |
| 37 | + * | |
| 38 | + * @access private | |
| 39 | + * | |
| 40 | + * @var array | |
| 41 | + */ | |
| 42 | + private $render_attributes = []; | |
| 43 | + | |
| 44 | + /** | |
| 35 | 45 | * Element default arguments. |
| 36 | 46 | * |
| 37 | 47 | * Holds all the default arguments of the element. Used to store additional |
| 38 | 48 | * data. For example WordPress widgets use this to store widget names. |
| @@ -119,12 +129,8 @@ | ||
| 119 | 129 | public function get_script_depends() { |
| 120 | 130 | return $this->depended_scripts; |
| 121 | 131 | } |
| 122 | 132 | |
| 123 | - public function get_global_scripts() { | |
| 124 | - return [ 'elementor-frontend' ]; | |
| 125 | - } | |
| 126 | - | |
| 127 | 133 | /** |
| 128 | 134 | * Enqueue scripts. |
| 129 | 135 | * |
| 130 | 136 | * Registers all the scripts defined as element dependencies and enqueues |
| @@ -134,9 +140,12 @@ | ||
| 134 | 140 | * @access public |
| 135 | 141 | */ |
| 136 | 142 | final public function enqueue_scripts() { |
| 137 | 143 | $deprecated_scripts = [ |
| 138 | - // Insert here when you have a deprecated script. | |
| 144 | + 'jquery-slick' => [ | |
| 145 | + 'version' => '2.7.0', | |
| 146 | + 'replacement' => 'Swiper', | |
| 147 | + ], | |
| 139 | 148 | ]; |
| 140 | 149 | |
| 141 | 150 | foreach ( $this->get_script_depends() as $script ) { |
| 142 | 151 | if ( isset( $deprecated_scripts[ $script ] ) ) { |
| @@ -144,16 +153,10 @@ | ||
| 144 | 153 | } |
| 145 | 154 | |
| 146 | 155 | wp_enqueue_script( $script ); |
| 147 | 156 | } |
| 148 | - | |
| 149 | - foreach ( $this->get_global_scripts() as $script ) { | |
| 150 | - wp_enqueue_script( $script ); | |
| 151 | - } | |
| 152 | 157 | } |
| 153 | 158 | |
| 154 | - public function register_frontend_handlers() {} | |
| 155 | - | |
| 156 | 159 | /** |
| 157 | 160 | * Get style dependencies. |
| 158 | 161 | * |
| 159 | 162 | * Retrieve the list of style dependencies the element requires. |
| @@ -295,22 +298,8 @@ | ||
| 295 | 298 | return true; |
| 296 | 299 | } |
| 297 | 300 | |
| 298 | 301 | /** |
| 299 | - * Whether the element returns dynamic content. | |
| 300 | - * | |
| 301 | - * Set to determine whether to cache the element output or not. | |
| 302 | - * | |
| 303 | - * @since 3.22.0 | |
| 304 | - * @access protected | |
| 305 | - * | |
| 306 | - * @return bool Whether to cache the element output. | |
| 307 | - */ | |
| 308 | - protected function is_dynamic_content(): bool { | |
| 309 | - return true; | |
| 310 | - } | |
| 311 | - | |
| 312 | - /** | |
| 313 | 302 | * Get child elements. |
| 314 | 303 | * |
| 315 | 304 | * Retrieve all the child elements of this element. |
| 316 | 305 | * |
| @@ -344,23 +333,8 @@ | ||
| 344 | 333 | return self::get_items( $this->default_args, $item ); |
| 345 | 334 | } |
| 346 | 335 | |
| 347 | 336 | /** |
| 348 | - * Get panel presets. | |
| 349 | - * | |
| 350 | - * Used for displaying the widget in the panel multiple times, but with different defaults values, | |
| 351 | - * icon, title etc. | |
| 352 | - * | |
| 353 | - * @since 3.16.0 | |
| 354 | - * @access public | |
| 355 | - * | |
| 356 | - * @return array | |
| 357 | - */ | |
| 358 | - public function get_panel_presets() { | |
| 359 | - return []; | |
| 360 | - } | |
| 361 | - | |
| 362 | - /** | |
| 363 | 337 | * Add new child element. |
| 364 | 338 | * |
| 365 | 339 | * Register new child element to allow hierarchy. |
| 366 | 340 | * |
| @@ -391,8 +365,66 @@ | ||
| 391 | 365 | return $child; |
| 392 | 366 | } |
| 393 | 367 | |
| 394 | 368 | /** |
| 369 | + * Add render attribute. | |
| 370 | + * | |
| 371 | + * Used to add attributes to a specific HTML element. | |
| 372 | + * | |
| 373 | + * The HTML tag is represented by the element parameter, then you need to | |
| 374 | + * define the attribute key and the attribute key. The final result will be: | |
| 375 | + * `<element attribute_key="attribute_value">`. | |
| 376 | + * | |
| 377 | + * Example usage: | |
| 378 | + * | |
| 379 | + * `$this->add_render_attribute( 'wrapper', 'class', 'custom-widget-wrapper-class' );` | |
| 380 | + * `$this->add_render_attribute( 'widget', 'id', 'custom-widget-id' );` | |
| 381 | + * `$this->add_render_attribute( 'button', [ 'class' => 'custom-button-class', 'id' => 'custom-button-id' ] );` | |
| 382 | + * | |
| 383 | + * @since 1.0.0 | |
| 384 | + * @access public | |
| 385 | + * | |
| 386 | + * @param array|string $element The HTML element. | |
| 387 | + * @param array|string $key Optional. Attribute key. Default is null. | |
| 388 | + * @param array|string $value Optional. Attribute value. Default is null. | |
| 389 | + * @param bool $overwrite Optional. Whether to overwrite existing | |
| 390 | + * attribute. Default is false, not to overwrite. | |
| 391 | + * | |
| 392 | + * @return Element_Base Current instance of the element. | |
| 393 | + */ | |
| 394 | + public function add_render_attribute( $element, $key = null, $value = null, $overwrite = false ) { | |
| 395 | + if ( is_array( $element ) ) { | |
| 396 | + foreach ( $element as $element_key => $attributes ) { | |
| 397 | + $this->add_render_attribute( $element_key, $attributes, null, $overwrite ); | |
| 398 | + } | |
| 399 | + | |
| 400 | + return $this; | |
| 401 | + } | |
| 402 | + | |
| 403 | + if ( is_array( $key ) ) { | |
| 404 | + foreach ( $key as $attribute_key => $attributes ) { | |
| 405 | + $this->add_render_attribute( $element, $attribute_key, $attributes, $overwrite ); | |
| 406 | + } | |
| 407 | + | |
| 408 | + return $this; | |
| 409 | + } | |
| 410 | + | |
| 411 | + if ( empty( $this->render_attributes[ $element ][ $key ] ) ) { | |
| 412 | + $this->render_attributes[ $element ][ $key ] = []; | |
| 413 | + } | |
| 414 | + | |
| 415 | + settype( $value, 'array' ); | |
| 416 | + | |
| 417 | + if ( $overwrite ) { | |
| 418 | + $this->render_attributes[ $element ][ $key ] = $value; | |
| 419 | + } else { | |
| 420 | + $this->render_attributes[ $element ][ $key ] = array_merge( $this->render_attributes[ $element ][ $key ], $value ); | |
| 421 | + } | |
| 422 | + | |
| 423 | + return $this; | |
| 424 | + } | |
| 425 | + | |
| 426 | + /** | |
| 395 | 427 | * Add link render attributes. |
| 396 | 428 | * |
| 397 | 429 | * Used to add link tag attributes to a specific HTML element. |
| 398 | 430 | * |
| @@ -406,14 +438,15 @@ | ||
| 406 | 438 | * @since 2.8.0 |
| 407 | 439 | * @access public |
| 408 | 440 | * |
| 409 | 441 | * @param array|string $element The HTML element. |
| 410 | - * @param array $url_control Array of link settings. | |
| 411 | - * @param bool $overwrite Optional. Whether to overwrite existing | |
| 412 | - * attribute. Default is false, not to overwrite. | |
| 442 | + * @param array $url_control Array of link settings. | |
| 443 | + * @param bool $overwrite Optional. Whether to overwrite existing | |
| 444 | + * attribute. Default is false, not to overwrite. | |
| 413 | 445 | * |
| 414 | 446 | * @return Element_Base Current instance of the element. |
| 415 | 447 | */ |
| 448 | + | |
| 416 | 449 | public function add_link_attributes( $element, array $url_control, $overwrite = false ) { |
| 417 | 450 | $attributes = []; |
| 418 | 451 | |
| 419 | 452 | if ( ! empty( $url_control['url'] ) ) { |
| @@ -430,14 +463,14 @@ | ||
| 430 | 463 | $attributes['rel'] = 'nofollow'; |
| 431 | 464 | } |
| 432 | 465 | |
| 433 | 466 | if ( ! empty( $url_control['custom_attributes'] ) ) { |
| 434 | - // Custom URL attributes should come as a string of comma-delimited key|value pairs. | |
| 467 | + // Custom URL attributes should come as a string of comma-delimited key|value pairs | |
| 435 | 468 | $attributes = array_merge( $attributes, Utils::parse_custom_attributes( $url_control['custom_attributes'] ) ); |
| 436 | 469 | } |
| 437 | 470 | |
| 438 | 471 | if ( $attributes ) { |
| 439 | - $this->add_render_attribute( $element, $attributes, null, $overwrite ); | |
| 472 | + $this->add_render_attribute( $element, $attributes, $overwrite ); | |
| 440 | 473 | } |
| 441 | 474 | |
| 442 | 475 | return $this; |
| 443 | 476 | } |
| @@ -442,8 +475,138 @@ | ||
| 442 | 475 | return $this; |
| 443 | 476 | } |
| 444 | 477 | |
| 445 | 478 | /** |
| 479 | + * Get Render Attributes | |
| 480 | + * | |
| 481 | + * Used to retrieve render attribute. | |
| 482 | + * | |
| 483 | + * The returned array is either all elements and their attributes if no `$element` is specified, an array of all | |
| 484 | + * attributes of a specific element or a specific attribute properties if `$key` is specified. | |
| 485 | + * | |
| 486 | + * Returns null if one of the requested parameters isn't set. | |
| 487 | + * | |
| 488 | + * @since 2.2.6 | |
| 489 | + * @access public | |
| 490 | + * @param string $element | |
| 491 | + * @param string $key | |
| 492 | + * | |
| 493 | + * @return array | |
| 494 | + */ | |
| 495 | + public function get_render_attributes( $element = '', $key = '' ) { | |
| 496 | + $attributes = $this->render_attributes; | |
| 497 | + | |
| 498 | + if ( $element ) { | |
| 499 | + if ( ! isset( $attributes[ $element ] ) ) { | |
| 500 | + return null; | |
| 501 | + } | |
| 502 | + | |
| 503 | + $attributes = $attributes[ $element ]; | |
| 504 | + | |
| 505 | + if ( $key ) { | |
| 506 | + if ( ! isset( $attributes[ $key ] ) ) { | |
| 507 | + return null; | |
| 508 | + } | |
| 509 | + | |
| 510 | + $attributes = $attributes[ $key ]; | |
| 511 | + } | |
| 512 | + } | |
| 513 | + | |
| 514 | + return $attributes; | |
| 515 | + } | |
| 516 | + | |
| 517 | + /** | |
| 518 | + * Set render attribute. | |
| 519 | + * | |
| 520 | + * Used to set the value of the HTML element render attribute or to update | |
| 521 | + * an existing render attribute. | |
| 522 | + * | |
| 523 | + * @since 1.0.0 | |
| 524 | + * @access public | |
| 525 | + * | |
| 526 | + * @param array|string $element The HTML element. | |
| 527 | + * @param array|string $key Optional. Attribute key. Default is null. | |
| 528 | + * @param array|string $value Optional. Attribute value. Default is null. | |
| 529 | + * | |
| 530 | + * @return Element_Base Current instance of the element. | |
| 531 | + */ | |
| 532 | + public function set_render_attribute( $element, $key = null, $value = null ) { | |
| 533 | + return $this->add_render_attribute( $element, $key, $value, true ); | |
| 534 | + } | |
| 535 | + | |
| 536 | + /** | |
| 537 | + * Remove render attribute. | |
| 538 | + * | |
| 539 | + * Used to remove an element (with its keys and their values), key (with its values), | |
| 540 | + * or value/s from an HTML element's render attribute. | |
| 541 | + * | |
| 542 | + * @since 2.7.0 | |
| 543 | + * @access public | |
| 544 | + * | |
| 545 | + * @param string $element The HTML element. | |
| 546 | + * @param string $key Optional. Attribute key. Default is null. | |
| 547 | + * @param array|string $values Optional. Attribute value/s. Default is null. | |
| 548 | + */ | |
| 549 | + public function remove_render_attribute( $element, $key = null, $values = null ) { | |
| 550 | + if ( $key && ! isset( $this->render_attributes[ $element ][ $key ] ) ) { | |
| 551 | + return; | |
| 552 | + } | |
| 553 | + | |
| 554 | + if ( $values ) { | |
| 555 | + $values = (array) $values; | |
| 556 | + | |
| 557 | + $this->render_attributes[ $element ][ $key ] = array_diff( $this->render_attributes[ $element ][ $key ], $values ); | |
| 558 | + | |
| 559 | + return; | |
| 560 | + } | |
| 561 | + | |
| 562 | + if ( $key ) { | |
| 563 | + unset( $this->render_attributes[ $element ][ $key ] ); | |
| 564 | + | |
| 565 | + return; | |
| 566 | + } | |
| 567 | + | |
| 568 | + if ( isset( $this->render_attributes[ $element ] ) ) { | |
| 569 | + unset( $this->render_attributes[ $element ] ); | |
| 570 | + } | |
| 571 | + } | |
| 572 | + | |
| 573 | + /** | |
| 574 | + * Get render attribute string. | |
| 575 | + * | |
| 576 | + * Used to retrieve the value of the render attribute. | |
| 577 | + * | |
| 578 | + * @since 1.0.0 | |
| 579 | + * @access public | |
| 580 | + * | |
| 581 | + * @param string $element The element. | |
| 582 | + * | |
| 583 | + * @return string Render attribute string, or an empty string if the attribute | |
| 584 | + * is empty or not exist. | |
| 585 | + */ | |
| 586 | + public function get_render_attribute_string( $element ) { | |
| 587 | + if ( empty( $this->render_attributes[ $element ] ) ) { | |
| 588 | + return ''; | |
| 589 | + } | |
| 590 | + | |
| 591 | + return Utils::render_html_attributes( $this->render_attributes[ $element ] ); | |
| 592 | + } | |
| 593 | + | |
| 594 | + /** | |
| 595 | + * Print render attribute string. | |
| 596 | + * | |
| 597 | + * Used to output the rendered attribute. | |
| 598 | + * | |
| 599 | + * @since 2.0.0 | |
| 600 | + * @access public | |
| 601 | + * | |
| 602 | + * @param array|string $element The element. | |
| 603 | + */ | |
| 604 | + public function print_render_attribute_string( $element ) { | |
| 605 | + echo $this->get_render_attribute_string( $element ); // XSS ok. | |
| 606 | + } | |
| 607 | + | |
| 608 | + /** | |
| 446 | 609 | * Print element. |
| 447 | 610 | * |
| 448 | 611 | * Used to generate the element final HTML on the frontend and the editor. |
| 449 | 612 | * |
| @@ -452,15 +615,8 @@ | ||
| 452 | 615 | */ |
| 453 | 616 | public function print_element() { |
| 454 | 617 | $element_type = $this->get_type(); |
| 455 | 618 | |
| 456 | - if ( $this->should_render_shortcode() ) { | |
| 457 | - $unique_id = apply_filters( 'elementor/element_cache/unique_id', '' ); | |
| 458 | - | |
| 459 | - echo '[elementor-element k="' . esc_attr( $unique_id ) . '" data="' . esc_attr( base64_encode( wp_json_encode( $this->get_raw_data() ) ) ) . '"]'; | |
| 460 | - return; | |
| 461 | - } | |
| 462 | - | |
| 463 | 619 | /** |
| 464 | 620 | * Before frontend element render. |
| 465 | 621 | * |
| 466 | 622 | * Fires before Elementor element is rendered in the frontend. |
| @@ -484,17 +640,9 @@ | ||
| 484 | 640 | */ |
| 485 | 641 | do_action( "elementor/frontend/{$element_type}/before_render", $this ); |
| 486 | 642 | |
| 487 | 643 | ob_start(); |
| 488 | - | |
| 489 | - if ( $this->has_own_method( '_print_content', self::class ) ) { | |
| 490 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_print_content', '3.1.0', __CLASS__ . '::print_content()' ); | |
| 491 | - | |
| 492 | - $this->_print_content(); | |
| 493 | - } else { | |
| 494 | - $this->print_content(); | |
| 495 | - } | |
| 496 | - | |
| 644 | + $this->_print_content(); | |
| 497 | 645 | $content = ob_get_clean(); |
| 498 | 646 | |
| 499 | 647 | $should_render = ( ! empty( $content ) || $this->should_print_empty() ); |
| 500 | 648 | |
| @@ -510,23 +658,14 @@ | ||
| 510 | 658 | */ |
| 511 | 659 | $should_render = apply_filters( "elementor/frontend/{$element_type}/should_render", $should_render, $this ); |
| 512 | 660 | |
| 513 | 661 | if ( $should_render ) { |
| 514 | - if ( $this->has_own_method( '_add_render_attributes', self::class ) ) { | |
| 515 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_add_render_attributes', '3.1.0', __CLASS__ . '::add_render_attributes()' ); | |
| 662 | + $this->_add_render_attributes(); | |
| 516 | 663 | |
| 517 | - $this->_add_render_attributes(); | |
| 518 | - } else { | |
| 519 | - $this->add_render_attributes(); | |
| 520 | - } | |
| 521 | - | |
| 522 | 664 | $this->before_render(); |
| 523 | - // PHPCS - The content has already been escaped by the `render` method. | |
| 524 | - echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 665 | + echo $content; | |
| 525 | 666 | $this->after_render(); |
| 526 | 667 | |
| 527 | - // TODO: Remove this in the future | |
| 528 | - // Since version 3.24.0 page scripts/styles are handled by `page_assets`. | |
| 529 | 668 | $this->enqueue_scripts(); |
| 530 | 669 | $this->enqueue_styles(); |
| 531 | 670 | } |
| 532 | 671 | |
| @@ -554,54 +693,8 @@ | ||
| 554 | 693 | */ |
| 555 | 694 | do_action( 'elementor/frontend/after_render', $this ); |
| 556 | 695 | } |
| 557 | 696 | |
| 558 | - protected function should_render_shortcode() { | |
| 559 | - $should_render_shortcode = apply_filters( 'elementor/element/should_render_shortcode', false ); | |
| 560 | - | |
| 561 | - if ( ! $should_render_shortcode ) { | |
| 562 | - return false; | |
| 563 | - } | |
| 564 | - | |
| 565 | - $raw_data = $this->get_raw_data(); | |
| 566 | - | |
| 567 | - if ( ! empty( $raw_data['settings']['_element_cache'] ) ) { | |
| 568 | - return 'yes' === $raw_data['settings']['_element_cache']; | |
| 569 | - } | |
| 570 | - | |
| 571 | - if ( $this->is_dynamic_content() ) { | |
| 572 | - return true; | |
| 573 | - } | |
| 574 | - | |
| 575 | - $is_dynamic_content = apply_filters( 'elementor/element/is_dynamic_content', false, $raw_data, $this ); | |
| 576 | - | |
| 577 | - $has_dynamic_tag = $this->has_element_dynamic_tag( $raw_data['settings'] ); | |
| 578 | - | |
| 579 | - if ( $is_dynamic_content || $has_dynamic_tag ) { | |
| 580 | - return true; | |
| 581 | - } | |
| 582 | - | |
| 583 | - return false; | |
| 584 | - } | |
| 585 | - | |
| 586 | - private function has_element_dynamic_tag( $element_settings ): bool { | |
| 587 | - if ( is_array( $element_settings ) ) { | |
| 588 | - if ( ! empty( $element_settings['__dynamic__'] ) ) { | |
| 589 | - return true; | |
| 590 | - } | |
| 591 | - | |
| 592 | - foreach ( $element_settings as $value ) { | |
| 593 | - $has_dynamic = $this->has_element_dynamic_tag( $value ); | |
| 594 | - | |
| 595 | - if ( $has_dynamic ) { | |
| 596 | - return true; | |
| 597 | - } | |
| 598 | - } | |
| 599 | - } | |
| 600 | - | |
| 601 | - return false; | |
| 602 | - } | |
| 603 | - | |
| 604 | 697 | /** |
| 605 | 698 | * Get the element raw data. |
| 606 | 699 | * |
| 607 | 700 | * Retrieve the raw element data, including the id, type, settings, child |
| @@ -628,9 +721,9 @@ | ||
| 628 | 721 | foreach ( $this->get_children() as $child ) { |
| 629 | 722 | $elements[] = $child->get_raw_data( $with_html_content ); |
| 630 | 723 | } |
| 631 | 724 | |
| 632 | - $raw_data = [ | |
| 725 | + return [ | |
| 633 | 726 | 'id' => $this->get_id(), |
| 634 | 727 | 'elType' => $data['elType'], |
| 635 | 728 | 'settings' => $data['settings'], |
| 636 | 729 | 'elements' => $elements, |
| @@ -635,36 +728,10 @@ | ||
| 635 | 728 | 'settings' => $data['settings'], |
| 636 | 729 | 'elements' => $elements, |
| 637 | 730 | 'isInner' => $data['isInner'], |
| 638 | 731 | ]; |
| 639 | - | |
| 640 | - if ( ! empty( $data['isLocked'] ) ) { | |
| 641 | - $raw_data['isLocked'] = $data['isLocked']; | |
| 642 | - } | |
| 643 | - | |
| 644 | - return $raw_data; | |
| 645 | 732 | } |
| 646 | 733 | |
| 647 | - public function get_data_for_save() { | |
| 648 | - $data = $this->get_raw_data(); | |
| 649 | - | |
| 650 | - $elements = []; | |
| 651 | - | |
| 652 | - foreach ( $this->get_children() as $child ) { | |
| 653 | - $elements[] = $child->get_data_for_save(); | |
| 654 | - } | |
| 655 | - | |
| 656 | - if ( ! empty( $elements ) ) { | |
| 657 | - $data['elements'] = $elements; | |
| 658 | - } | |
| 659 | - | |
| 660 | - if ( ! empty( $data['settings'] ) ) { | |
| 661 | - $data['settings'] = $this->on_save( $data['settings'] ); | |
| 662 | - } | |
| 663 | - | |
| 664 | - return $data; | |
| 665 | - } | |
| 666 | - | |
| 667 | 734 | /** |
| 668 | 735 | * Get unique selector. |
| 669 | 736 | * |
| 670 | 737 | * Retrieve the unique selector of the element. Used to set a unique HTML |
| @@ -694,47 +761,8 @@ | ||
| 694 | 761 | return $this->is_type_instance; |
| 695 | 762 | } |
| 696 | 763 | |
| 697 | 764 | /** |
| 698 | - * On import update dynamic content (e.g. post and term IDs). | |
| 699 | - * | |
| 700 | - * @since 3.8.0 | |
| 701 | - * | |
| 702 | - * @param array $config The config of the passed element. | |
| 703 | - * @param array $data The data that requires updating/replacement when imported. | |
| 704 | - * @param array|null $controls The available controls. | |
| 705 | - * | |
| 706 | - * @return array Element data. | |
| 707 | - */ | |
| 708 | - public static function on_import_update_dynamic_content( array $config, array $data, $controls = null ): array { | |
| 709 | - $tags_manager = Plugin::$instance->dynamic_tags; | |
| 710 | - | |
| 711 | - if ( empty( $config['settings'][ $tags_manager::DYNAMIC_SETTING_KEY ] ) ) { | |
| 712 | - return $config; | |
| 713 | - } | |
| 714 | - | |
| 715 | - foreach ( $config['settings'][ $tags_manager::DYNAMIC_SETTING_KEY ] as $dynamic_name => $dynamic_value ) { | |
| 716 | - $tag_config = $tags_manager->tag_text_to_tag_data( $dynamic_value ); | |
| 717 | - $tag_instance = $tags_manager->create_tag( $tag_config['id'], $tag_config['name'], $tag_config['settings'] ); | |
| 718 | - | |
| 719 | - if ( is_null( $tag_instance ) ) { | |
| 720 | - continue; | |
| 721 | - } | |
| 722 | - | |
| 723 | - if ( $tag_instance->has_own_method( 'on_import_replace_dynamic_content' ) ) { | |
| 724 | - // TODO: Remove this check in the future. | |
| 725 | - $tag_config = $tag_instance->on_import_replace_dynamic_content( $tag_config, $data['post_ids'] ); | |
| 726 | - } else { | |
| 727 | - $tag_config = $tag_instance->on_import_update_dynamic_content( $tag_config, $data, $tag_instance->get_controls() ); | |
| 728 | - } | |
| 729 | - | |
| 730 | - $config['settings'][ $tags_manager::DYNAMIC_SETTING_KEY ][ $dynamic_name ] = $tags_manager->tag_data_to_tag_text( $tag_config['id'], $tag_config['name'], $tag_config['settings'] ); | |
| 731 | - } | |
| 732 | - | |
| 733 | - return $config; | |
| 734 | - } | |
| 735 | - | |
| 736 | - /** | |
| 737 | 765 | * Add render attributes. |
| 738 | 766 | * |
| 739 | 767 | * Used to add attributes to the current element wrapper HTML tag. |
| 740 | 768 | * |
| @@ -739,25 +767,10 @@ | ||
| 739 | 767 | * Used to add attributes to the current element wrapper HTML tag. |
| 740 | 768 | * |
| 741 | 769 | * @since 1.3.0 |
| 742 | 770 | * @access protected |
| 743 | - * @deprecated 3.1.0 Use `add_render_attribute()` method instead. | |
| 744 | 771 | */ |
| 745 | 772 | protected function _add_render_attributes() { |
| 746 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0', 'add_render_attributes()' ); | |
| 747 | - | |
| 748 | - return $this->add_render_attributes(); | |
| 749 | - } | |
| 750 | - | |
| 751 | - /** | |
| 752 | - * Add render attributes. | |
| 753 | - * | |
| 754 | - * Used to add attributes to the current element wrapper HTML tag. | |
| 755 | - * | |
| 756 | - * @since 3.1.0 | |
| 757 | - * @access protected | |
| 758 | - */ | |
| 759 | - protected function add_render_attributes() { | |
| 760 | 773 | $id = $this->get_id(); |
| 761 | 774 | |
| 762 | 775 | $settings = $this->get_settings_for_display(); |
| 763 | 776 | $frontend_settings = $this->get_frontend_settings(); |
| @@ -769,9 +782,8 @@ | ||
| 769 | 782 | 'elementor-element-' . $id, |
| 770 | 783 | ], |
| 771 | 784 | 'data-id' => $id, |
| 772 | 785 | 'data-element_type' => $this->get_type(), |
| 773 | - 'data-e-type' => $this->get_type(), | |
| 774 | 786 | ] ); |
| 775 | 787 | |
| 776 | 788 | $class_settings = []; |
| 777 | 789 | |
| @@ -776,15 +788,9 @@ | ||
| 776 | 788 | $class_settings = []; |
| 777 | 789 | |
| 778 | 790 | foreach ( $settings as $setting_key => $setting ) { |
| 779 | 791 | if ( isset( $controls[ $setting_key ]['prefix_class'] ) ) { |
| 780 | - if ( isset( $controls[ $setting_key ]['classes_dictionary'][ $setting ] ) ) { | |
| 781 | - $value = $controls[ $setting_key ]['classes_dictionary'][ $setting ]; | |
| 782 | - } else { | |
| 783 | - $value = $setting; | |
| 784 | - } | |
| 785 | - | |
| 786 | - $class_settings[ $setting_key ] = $value; | |
| 792 | + $class_settings[ $setting_key ] = $setting; | |
| 787 | 793 | } |
| 788 | 794 | } |
| 789 | 795 | |
| 790 | 796 | foreach ( $class_settings as $setting_key => $setting ) { |
| @@ -794,17 +800,13 @@ | ||
| 794 | 800 | |
| 795 | 801 | $this->add_render_attribute( '_wrapper', 'class', $controls[ $setting_key ]['prefix_class'] . $setting ); |
| 796 | 802 | } |
| 797 | 803 | |
| 798 | - $_animation = ! empty( $settings['_animation'] ); | |
| 799 | - $animation = ! empty( $settings['animation'] ); | |
| 800 | - $has_animation = ( $_animation && 'none' !== $settings['_animation'] ) || ( $animation && 'none' !== $settings['animation'] ); | |
| 801 | - | |
| 802 | - if ( $has_animation ) { | |
| 804 | + if ( ! empty( $settings['animation'] ) || ! empty( $settings['_animation'] ) ) { | |
| 803 | 805 | $is_static_render_mode = Plugin::$instance->frontend->is_static_render_mode(); |
| 804 | 806 | |
| 805 | 807 | if ( ! $is_static_render_mode ) { |
| 806 | - // Hide the element until the animation begins. | |
| 808 | + // Hide the element until the animation begins | |
| 807 | 809 | $this->add_render_attribute( '_wrapper', 'class', 'elementor-invisible' ); |
| 808 | 810 | } |
| 809 | 811 | } |
| 810 | 812 | |
| @@ -828,587 +830,8 @@ | ||
| 828 | 830 | do_action( 'elementor/element/after_add_attributes', $this ); |
| 829 | 831 | } |
| 830 | 832 | |
| 831 | 833 | /** |
| 832 | - * Register the Transform controls in the advanced tab of the element. | |
| 833 | - * | |
| 834 | - * Previously registered under the Widget_Common class, but registered a more fundamental level now to enable access from other widgets. | |
| 835 | - * | |
| 836 | - * @param string $element_selector | |
| 837 | - * @param string $transform_selector_class | |
| 838 | - * @return void | |
| 839 | - * @since 3.9.0 | |
| 840 | - * @access protected | |
| 841 | - */ | |
| 842 | - protected function register_transform_section( $element_selector = '', $transform_selector_class = ' > .elementor-widget-container' ) { | |
| 843 | - $default_unit_values_deg = []; | |
| 844 | - $default_unit_values_ms = []; | |
| 845 | - | |
| 846 | - // Set the default unit sizes for all active breakpoints. | |
| 847 | - foreach ( Breakpoints_Manager::get_default_config() as $breakpoint_name => $breakpoint_config ) { | |
| 848 | - $default_unit_values_deg[ $breakpoint_name ] = [ | |
| 849 | - 'default' => [ | |
| 850 | - 'unit' => 'deg', | |
| 851 | - ], | |
| 852 | - ]; | |
| 853 | - | |
| 854 | - $default_unit_values_ms[ $breakpoint_name ] = [ | |
| 855 | - 'default' => [ | |
| 856 | - 'unit' => 'ms', | |
| 857 | - ], | |
| 858 | - ]; | |
| 859 | - } | |
| 860 | - | |
| 861 | - $this->start_controls_section( | |
| 862 | - '_section_transform', | |
| 863 | - [ | |
| 864 | - 'label' => esc_html__( 'Transform', 'elementor' ), | |
| 865 | - 'tab' => Controls_Manager::TAB_ADVANCED, | |
| 866 | - ] | |
| 867 | - ); | |
| 868 | - | |
| 869 | - $this->start_controls_tabs( '_tabs_positioning' ); | |
| 870 | - | |
| 871 | - $transform_prefix_class = 'e-'; | |
| 872 | - $transform_return_value = 'transform'; | |
| 873 | - $transform_css_modifier = ''; | |
| 874 | - | |
| 875 | - if ( 'con' === $element_selector ) { | |
| 876 | - $transform_selector_class = '.e-' . $element_selector; | |
| 877 | - $transform_css_modifier = $element_selector . '-'; | |
| 878 | - } | |
| 879 | - | |
| 880 | - foreach ( [ '', '_hover' ] as $tab ) { | |
| 881 | - $state = '_hover' === $tab ? ':hover' : ''; | |
| 882 | - | |
| 883 | - $this->start_controls_tab( | |
| 884 | - "_tab_positioning{$tab}", | |
| 885 | - [ | |
| 886 | - 'label' => '' === $tab ? esc_html__( 'Normal', 'elementor' ) : esc_html__( 'Hover', 'elementor' ), | |
| 887 | - ] | |
| 888 | - ); | |
| 889 | - | |
| 890 | - $this->add_control( | |
| 891 | - "_transform_rotate_popover{$tab}", | |
| 892 | - [ | |
| 893 | - 'label' => esc_html__( 'Rotate', 'elementor' ), | |
| 894 | - 'type' => Controls_Manager::POPOVER_TOGGLE, | |
| 895 | - 'prefix_class' => $transform_prefix_class, | |
| 896 | - 'return_value' => $transform_return_value, | |
| 897 | - ] | |
| 898 | - ); | |
| 899 | - | |
| 900 | - $this->start_popover(); | |
| 901 | - | |
| 902 | - $this->add_responsive_control( | |
| 903 | - "_transform_rotateZ_effect{$tab}", | |
| 904 | - [ | |
| 905 | - 'label' => esc_html__( 'Rotate', 'elementor' ) . ' (deg)', | |
| 906 | - 'type' => Controls_Manager::SLIDER, | |
| 907 | - 'device_args' => $default_unit_values_deg, | |
| 908 | - 'range' => [ | |
| 909 | - 'px' => [ | |
| 910 | - 'min' => -360, | |
| 911 | - 'max' => 360, | |
| 912 | - ], | |
| 913 | - ], | |
| 914 | - 'selectors' => [ | |
| 915 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-rotateZ: {{SIZE}}deg', | |
| 916 | - ], | |
| 917 | - 'condition' => [ | |
| 918 | - "_transform_rotate_popover{$tab}!" => '', | |
| 919 | - ], | |
| 920 | - 'frontend_available' => true, | |
| 921 | - ] | |
| 922 | - ); | |
| 923 | - | |
| 924 | - $this->add_control( | |
| 925 | - "_transform_rotate_3d{$tab}", | |
| 926 | - [ | |
| 927 | - 'label' => esc_html__( '3D Rotate', 'elementor' ), | |
| 928 | - 'type' => Controls_Manager::SWITCHER, | |
| 929 | - 'label_on' => esc_html__( 'On', 'elementor' ), | |
| 930 | - 'label_off' => esc_html__( 'Off', 'elementor' ), | |
| 931 | - 'selectors' => [ | |
| 932 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-rotateX: 1{{UNIT}}; --e-' . $transform_css_modifier . 'transform-perspective: 20px;', | |
| 933 | - ], | |
| 934 | - 'condition' => [ | |
| 935 | - "_transform_rotate_popover{$tab}!" => '', | |
| 936 | - ], | |
| 937 | - 'frontend_available' => true, | |
| 938 | - ] | |
| 939 | - ); | |
| 940 | - | |
| 941 | - $this->add_responsive_control( | |
| 942 | - "_transform_rotateX_effect{$tab}", | |
| 943 | - [ | |
| 944 | - 'label' => esc_html__( 'Rotate X', 'elementor' ) . ' (deg)', | |
| 945 | - 'type' => Controls_Manager::SLIDER, | |
| 946 | - 'device_args' => $default_unit_values_deg, | |
| 947 | - 'range' => [ | |
| 948 | - 'px' => [ | |
| 949 | - 'min' => -360, | |
| 950 | - 'max' => 360, | |
| 951 | - ], | |
| 952 | - ], | |
| 953 | - 'condition' => [ | |
| 954 | - "_transform_rotate_3d{$tab}!" => '', | |
| 955 | - "_transform_rotate_popover{$tab}!" => '', | |
| 956 | - ], | |
| 957 | - 'selectors' => [ | |
| 958 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-rotateX: {{SIZE}}deg;', | |
| 959 | - ], | |
| 960 | - 'frontend_available' => true, | |
| 961 | - ] | |
| 962 | - ); | |
| 963 | - | |
| 964 | - $this->add_responsive_control( | |
| 965 | - "_transform_rotateY_effect{$tab}", | |
| 966 | - [ | |
| 967 | - 'label' => esc_html__( 'Rotate Y', 'elementor' ) . ' (deg)', | |
| 968 | - 'type' => Controls_Manager::SLIDER, | |
| 969 | - 'device_args' => $default_unit_values_deg, | |
| 970 | - 'range' => [ | |
| 971 | - 'px' => [ | |
| 972 | - 'min' => -360, | |
| 973 | - 'max' => 360, | |
| 974 | - ], | |
| 975 | - ], | |
| 976 | - 'condition' => [ | |
| 977 | - "_transform_rotate_3d{$tab}!" => '', | |
| 978 | - "_transform_rotate_popover{$tab}!" => '', | |
| 979 | - ], | |
| 980 | - 'selectors' => [ | |
| 981 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-rotateY: {{SIZE}}deg;', | |
| 982 | - ], | |
| 983 | - 'frontend_available' => true, | |
| 984 | - ] | |
| 985 | - ); | |
| 986 | - | |
| 987 | - $this->add_responsive_control( | |
| 988 | - "_transform_perspective_effect{$tab}", | |
| 989 | - [ | |
| 990 | - 'label' => esc_html__( 'Perspective', 'elementor' ) . ' (px)', | |
| 991 | - 'type' => Controls_Manager::SLIDER, | |
| 992 | - 'range' => [ | |
| 993 | - 'px' => [ | |
| 994 | - 'max' => 1000, | |
| 995 | - ], | |
| 996 | - ], | |
| 997 | - 'condition' => [ | |
| 998 | - "_transform_rotate_popover{$tab}!" => '', | |
| 999 | - "_transform_rotate_3d{$tab}!" => '', | |
| 1000 | - ], | |
| 1001 | - 'selectors' => [ | |
| 1002 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-perspective: {{SIZE}}px', | |
| 1003 | - ], | |
| 1004 | - 'frontend_available' => true, | |
| 1005 | - ] | |
| 1006 | - ); | |
| 1007 | - | |
| 1008 | - $this->end_popover(); | |
| 1009 | - | |
| 1010 | - $this->add_control( | |
| 1011 | - "_transform_translate_popover{$tab}", | |
| 1012 | - [ | |
| 1013 | - 'label' => esc_html__( 'Offset', 'elementor' ), | |
| 1014 | - 'type' => Controls_Manager::POPOVER_TOGGLE, | |
| 1015 | - 'prefix_class' => $transform_prefix_class, | |
| 1016 | - 'return_value' => $transform_return_value, | |
| 1017 | - ] | |
| 1018 | - ); | |
| 1019 | - | |
| 1020 | - $this->start_popover(); | |
| 1021 | - | |
| 1022 | - $this->add_responsive_control( | |
| 1023 | - "_transform_translateX_effect{$tab}", | |
| 1024 | - [ | |
| 1025 | - 'label' => esc_html__( 'Offset X', 'elementor' ), | |
| 1026 | - 'type' => Controls_Manager::SLIDER, | |
| 1027 | - 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], | |
| 1028 | - 'range' => [ | |
| 1029 | - '%' => [ | |
| 1030 | - 'min' => -100, | |
| 1031 | - 'max' => 100, | |
| 1032 | - ], | |
| 1033 | - 'px' => [ | |
| 1034 | - 'min' => -1000, | |
| 1035 | - 'max' => 1000, | |
| 1036 | - ], | |
| 1037 | - ], | |
| 1038 | - 'condition' => [ | |
| 1039 | - "_transform_translate_popover{$tab}!" => '', | |
| 1040 | - ], | |
| 1041 | - 'selectors' => [ | |
| 1042 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-translateX: {{SIZE}}{{UNIT}};', | |
| 1043 | - ], | |
| 1044 | - 'frontend_available' => true, | |
| 1045 | - ] | |
| 1046 | - ); | |
| 1047 | - | |
| 1048 | - $this->add_responsive_control( | |
| 1049 | - "_transform_translateY_effect{$tab}", | |
| 1050 | - [ | |
| 1051 | - 'label' => esc_html__( 'Offset Y', 'elementor' ), | |
| 1052 | - 'type' => Controls_Manager::SLIDER, | |
| 1053 | - 'size_units' => [ 'px', '%', 'em', 'rem', 'vh', 'custom' ], | |
| 1054 | - 'range' => [ | |
| 1055 | - '%' => [ | |
| 1056 | - 'min' => -100, | |
| 1057 | - 'max' => 100, | |
| 1058 | - ], | |
| 1059 | - 'px' => [ | |
| 1060 | - 'min' => -1000, | |
| 1061 | - 'max' => 1000, | |
| 1062 | - ], | |
| 1063 | - ], | |
| 1064 | - 'condition' => [ | |
| 1065 | - "_transform_translate_popover{$tab}!" => '', | |
| 1066 | - ], | |
| 1067 | - 'selectors' => [ | |
| 1068 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-translateY: {{SIZE}}{{UNIT}};', | |
| 1069 | - ], | |
| 1070 | - 'frontend_available' => true, | |
| 1071 | - ] | |
| 1072 | - ); | |
| 1073 | - | |
| 1074 | - $this->end_popover(); | |
| 1075 | - | |
| 1076 | - $this->add_control( | |
| 1077 | - "_transform_scale_popover{$tab}", | |
| 1078 | - [ | |
| 1079 | - 'label' => esc_html__( 'Scale', 'elementor' ), | |
| 1080 | - 'type' => Controls_Manager::POPOVER_TOGGLE, | |
| 1081 | - 'prefix_class' => $transform_prefix_class, | |
| 1082 | - 'return_value' => $transform_return_value, | |
| 1083 | - ] | |
| 1084 | - ); | |
| 1085 | - | |
| 1086 | - $this->start_popover(); | |
| 1087 | - | |
| 1088 | - $this->add_control( | |
| 1089 | - "_transform_keep_proportions{$tab}", | |
| 1090 | - [ | |
| 1091 | - 'label' => esc_html__( 'Keep Proportions', 'elementor' ), | |
| 1092 | - 'type' => Controls_Manager::SWITCHER, | |
| 1093 | - 'label_on' => esc_html__( 'On', 'elementor' ), | |
| 1094 | - 'label_off' => esc_html__( 'Off', 'elementor' ), | |
| 1095 | - 'default' => 'yes', | |
| 1096 | - ] | |
| 1097 | - ); | |
| 1098 | - | |
| 1099 | - $this->add_responsive_control( | |
| 1100 | - "_transform_scale_effect{$tab}", | |
| 1101 | - [ | |
| 1102 | - 'label' => esc_html__( 'Scale', 'elementor' ), | |
| 1103 | - 'type' => Controls_Manager::SLIDER, | |
| 1104 | - 'range' => [ | |
| 1105 | - 'px' => [ | |
| 1106 | - 'max' => 2, | |
| 1107 | - 'step' => 0.1, | |
| 1108 | - ], | |
| 1109 | - ], | |
| 1110 | - 'condition' => [ | |
| 1111 | - "_transform_scale_popover{$tab}!" => '', | |
| 1112 | - "_transform_keep_proportions{$tab}!" => '', | |
| 1113 | - ], | |
| 1114 | - 'selectors' => [ | |
| 1115 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-scale: {{SIZE}};', | |
| 1116 | - ], | |
| 1117 | - 'frontend_available' => true, | |
| 1118 | - ] | |
| 1119 | - ); | |
| 1120 | - | |
| 1121 | - $this->add_responsive_control( | |
| 1122 | - "_transform_scaleX_effect{$tab}", | |
| 1123 | - [ | |
| 1124 | - 'label' => esc_html__( 'Scale X', 'elementor' ), | |
| 1125 | - 'type' => Controls_Manager::SLIDER, | |
| 1126 | - 'range' => [ | |
| 1127 | - 'px' => [ | |
| 1128 | - 'max' => 2, | |
| 1129 | - 'step' => 0.1, | |
| 1130 | - ], | |
| 1131 | - ], | |
| 1132 | - 'condition' => [ | |
| 1133 | - "_transform_scale_popover{$tab}!" => '', | |
| 1134 | - "_transform_keep_proportions{$tab}" => '', | |
| 1135 | - ], | |
| 1136 | - 'selectors' => [ | |
| 1137 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-scaleX: {{SIZE}};', | |
| 1138 | - ], | |
| 1139 | - 'frontend_available' => true, | |
| 1140 | - ] | |
| 1141 | - ); | |
| 1142 | - | |
| 1143 | - $this->add_responsive_control( | |
| 1144 | - "_transform_scaleY_effect{$tab}", | |
| 1145 | - [ | |
| 1146 | - 'label' => esc_html__( 'Scale Y', 'elementor' ), | |
| 1147 | - 'type' => Controls_Manager::SLIDER, | |
| 1148 | - 'range' => [ | |
| 1149 | - 'px' => [ | |
| 1150 | - 'max' => 2, | |
| 1151 | - 'step' => 0.1, | |
| 1152 | - ], | |
| 1153 | - ], | |
| 1154 | - 'condition' => [ | |
| 1155 | - "_transform_scale_popover{$tab}!" => '', | |
| 1156 | - "_transform_keep_proportions{$tab}" => '', | |
| 1157 | - ], | |
| 1158 | - 'selectors' => [ | |
| 1159 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-scaleY: {{SIZE}};', | |
| 1160 | - ], | |
| 1161 | - 'frontend_available' => true, | |
| 1162 | - ] | |
| 1163 | - ); | |
| 1164 | - | |
| 1165 | - $this->end_popover(); | |
| 1166 | - | |
| 1167 | - $this->add_control( | |
| 1168 | - "_transform_skew_popover{$tab}", | |
| 1169 | - [ | |
| 1170 | - 'label' => esc_html__( 'Skew', 'elementor' ), | |
| 1171 | - 'type' => Controls_Manager::POPOVER_TOGGLE, | |
| 1172 | - 'prefix_class' => $transform_prefix_class, | |
| 1173 | - 'return_value' => $transform_return_value, | |
| 1174 | - ] | |
| 1175 | - ); | |
| 1176 | - | |
| 1177 | - $this->start_popover(); | |
| 1178 | - | |
| 1179 | - $this->add_responsive_control( | |
| 1180 | - "_transform_skewX_effect{$tab}", | |
| 1181 | - [ | |
| 1182 | - 'label' => esc_html__( 'Skew X', 'elementor' ) . ' (deg)', | |
| 1183 | - 'type' => Controls_Manager::SLIDER, | |
| 1184 | - 'device_args' => $default_unit_values_deg, | |
| 1185 | - 'range' => [ | |
| 1186 | - 'px' => [ | |
| 1187 | - 'min' => -360, | |
| 1188 | - 'max' => 360, | |
| 1189 | - ], | |
| 1190 | - ], | |
| 1191 | - 'condition' => [ | |
| 1192 | - "_transform_skew_popover{$tab}!" => '', | |
| 1193 | - ], | |
| 1194 | - 'selectors' => [ | |
| 1195 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-skewX: {{SIZE}}deg;', | |
| 1196 | - ], | |
| 1197 | - 'frontend_available' => true, | |
| 1198 | - ] | |
| 1199 | - ); | |
| 1200 | - | |
| 1201 | - $this->add_responsive_control( | |
| 1202 | - "_transform_skewY_effect{$tab}", | |
| 1203 | - [ | |
| 1204 | - 'label' => esc_html__( 'Skew Y', 'elementor' ) . ' (deg)', | |
| 1205 | - 'type' => Controls_Manager::SLIDER, | |
| 1206 | - 'device_args' => $default_unit_values_deg, | |
| 1207 | - 'range' => [ | |
| 1208 | - 'px' => [ | |
| 1209 | - 'min' => -360, | |
| 1210 | - 'max' => 360, | |
| 1211 | - ], | |
| 1212 | - ], | |
| 1213 | - 'condition' => [ | |
| 1214 | - "_transform_skew_popover{$tab}!" => '', | |
| 1215 | - ], | |
| 1216 | - 'selectors' => [ | |
| 1217 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-skewY: {{SIZE}}deg;', | |
| 1218 | - ], | |
| 1219 | - 'frontend_available' => true, | |
| 1220 | - ] | |
| 1221 | - ); | |
| 1222 | - | |
| 1223 | - $this->end_popover(); | |
| 1224 | - | |
| 1225 | - $this->add_control( | |
| 1226 | - "_transform_flipX_effect{$tab}", | |
| 1227 | - [ | |
| 1228 | - 'label' => esc_html__( 'Flip Horizontal', 'elementor' ), | |
| 1229 | - 'type' => Controls_Manager::CHOOSE, | |
| 1230 | - 'options' => [ | |
| 1231 | - 'transform' => [ | |
| 1232 | - 'title' => esc_html__( 'Flip Horizontal', 'elementor' ), | |
| 1233 | - 'icon' => 'eicon-flip eicon-tilted', | |
| 1234 | - ], | |
| 1235 | - ], | |
| 1236 | - 'prefix_class' => $transform_prefix_class, | |
| 1237 | - 'selectors' => [ | |
| 1238 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-flipX: -1', | |
| 1239 | - ], | |
| 1240 | - 'frontend_available' => true, | |
| 1241 | - ] | |
| 1242 | - ); | |
| 1243 | - | |
| 1244 | - $this->add_control( | |
| 1245 | - "_transform_flipY_effect{$tab}", | |
| 1246 | - [ | |
| 1247 | - 'label' => esc_html__( 'Flip Vertical', 'elementor' ), | |
| 1248 | - 'type' => Controls_Manager::CHOOSE, | |
| 1249 | - 'options' => [ | |
| 1250 | - 'transform' => [ | |
| 1251 | - 'title' => esc_html__( 'Flip Vertical', 'elementor' ), | |
| 1252 | - 'icon' => 'eicon-flip', | |
| 1253 | - ], | |
| 1254 | - ], | |
| 1255 | - 'prefix_class' => $transform_prefix_class, | |
| 1256 | - 'selectors' => [ | |
| 1257 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-flipY: -1', | |
| 1258 | - ], | |
| 1259 | - 'frontend_available' => true, | |
| 1260 | - ] | |
| 1261 | - ); | |
| 1262 | - | |
| 1263 | - if ( '_hover' === $tab ) { | |
| 1264 | - $this->add_control( | |
| 1265 | - '_transform_transition_hover', | |
| 1266 | - [ | |
| 1267 | - 'label' => esc_html__( 'Transition Duration', 'elementor' ) . ' (ms)', | |
| 1268 | - 'type' => Controls_Manager::SLIDER, | |
| 1269 | - 'device_args' => $default_unit_values_ms, | |
| 1270 | - 'range' => [ | |
| 1271 | - 'px' => [ | |
| 1272 | - 'min' => 0, | |
| 1273 | - 'max' => 10000, | |
| 1274 | - 'step' => 100, | |
| 1275 | - ], | |
| 1276 | - ], | |
| 1277 | - 'selectors' => [ | |
| 1278 | - '{{WRAPPER}}' => '--e-' . $transform_css_modifier . 'transform-transition-duration: {{SIZE}}ms', | |
| 1279 | - ], | |
| 1280 | - ] | |
| 1281 | - ); | |
| 1282 | - } | |
| 1283 | - | |
| 1284 | - ${"transform_origin_conditions{$tab}"} = [ | |
| 1285 | - [ | |
| 1286 | - 'name' => "_transform_scale_popover{$tab}", | |
| 1287 | - 'operator' => '!=', | |
| 1288 | - 'value' => '', | |
| 1289 | - ], | |
| 1290 | - [ | |
| 1291 | - 'name' => "_transform_rotate_popover{$tab}", | |
| 1292 | - 'operator' => '!=', | |
| 1293 | - 'value' => '', | |
| 1294 | - ], | |
| 1295 | - [ | |
| 1296 | - 'name' => "_transform_flipX_effect{$tab}", | |
| 1297 | - 'operator' => '!=', | |
| 1298 | - 'value' => '', | |
| 1299 | - ], | |
| 1300 | - [ | |
| 1301 | - 'name' => "_transform_flipY_effect{$tab}", | |
| 1302 | - 'operator' => '!=', | |
| 1303 | - 'value' => '', | |
| 1304 | - ], | |
| 1305 | - ]; | |
| 1306 | - | |
| 1307 | - $this->end_controls_tab(); | |
| 1308 | - } | |
| 1309 | - | |
| 1310 | - $this->end_controls_tabs(); | |
| 1311 | - | |
| 1312 | - $transform_origin_conditions = [ | |
| 1313 | - 'relation' => 'or', | |
| 1314 | - 'terms' => array_merge( $transform_origin_conditions, $transform_origin_conditions_hover ), | |
| 1315 | - ]; | |
| 1316 | - | |
| 1317 | - // Will override motion effect transform-origin. | |
| 1318 | - $this->add_responsive_control( | |
| 1319 | - 'motion_fx_transform_x_anchor_point', | |
| 1320 | - [ | |
| 1321 | - 'label' => esc_html__( 'X Anchor Point', 'elementor' ), | |
| 1322 | - 'type' => Controls_Manager::CHOOSE, | |
| 1323 | - 'options' => [ | |
| 1324 | - 'left' => [ | |
| 1325 | - 'title' => esc_html__( 'Left', 'elementor' ), | |
| 1326 | - 'icon' => 'eicon-h-align-left', | |
| 1327 | - ], | |
| 1328 | - 'center' => [ | |
| 1329 | - 'title' => esc_html__( 'Center', 'elementor' ), | |
| 1330 | - 'icon' => 'eicon-h-align-center', | |
| 1331 | - ], | |
| 1332 | - 'right' => [ | |
| 1333 | - 'title' => esc_html__( 'Right', 'elementor' ), | |
| 1334 | - 'icon' => 'eicon-h-align-right', | |
| 1335 | - ], | |
| 1336 | - ], | |
| 1337 | - 'conditions' => $transform_origin_conditions, | |
| 1338 | - 'separator' => 'before', | |
| 1339 | - 'selectors' => [ | |
| 1340 | - '{{WRAPPER}}' => '--e-' . $transform_css_modifier . 'transform-origin-x: {{VALUE}}', | |
| 1341 | - ], | |
| 1342 | - ] | |
| 1343 | - ); | |
| 1344 | - | |
| 1345 | - // Will override motion effect transform-origin. | |
| 1346 | - $this->add_responsive_control( | |
| 1347 | - 'motion_fx_transform_y_anchor_point', | |
| 1348 | - [ | |
| 1349 | - 'label' => esc_html__( 'Y Anchor Point', 'elementor' ), | |
| 1350 | - 'type' => Controls_Manager::CHOOSE, | |
| 1351 | - 'options' => [ | |
| 1352 | - 'top' => [ | |
| 1353 | - 'title' => esc_html__( 'Top', 'elementor' ), | |
| 1354 | - 'icon' => 'eicon-v-align-top', | |
| 1355 | - ], | |
| 1356 | - 'center' => [ | |
| 1357 | - 'title' => esc_html__( 'Center', 'elementor' ), | |
| 1358 | - 'icon' => 'eicon-v-align-middle', | |
| 1359 | - ], | |
| 1360 | - 'bottom' => [ | |
| 1361 | - 'title' => esc_html__( 'Bottom', 'elementor' ), | |
| 1362 | - 'icon' => 'eicon-v-align-bottom', | |
| 1363 | - ], | |
| 1364 | - ], | |
| 1365 | - 'conditions' => $transform_origin_conditions, | |
| 1366 | - 'selectors' => [ | |
| 1367 | - '{{WRAPPER}}' => '--e-' . $transform_css_modifier . 'transform-origin-y: {{VALUE}}', | |
| 1368 | - ], | |
| 1369 | - ] | |
| 1370 | - ); | |
| 1371 | - | |
| 1372 | - $this->end_controls_section(); | |
| 1373 | - } | |
| 1374 | - | |
| 1375 | - /** | |
| 1376 | - * Add Hidden Device Controls | |
| 1377 | - * | |
| 1378 | - * Adds controls for hiding elements within certain devices' viewport widths. Adds a control for each active device. | |
| 1379 | - * | |
| 1380 | - * @since 3.4.0 | |
| 1381 | - * @access protected | |
| 1382 | - */ | |
| 1383 | - protected function add_hidden_device_controls() { | |
| 1384 | - // The 'Hide On X' controls are displayed from largest to smallest, while the method returns smallest to largest. | |
| 1385 | - $active_devices = Plugin::$instance->breakpoints->get_active_devices_list( [ 'reverse' => true ] ); | |
| 1386 | - $active_breakpoints = Plugin::$instance->breakpoints->get_active_breakpoints(); | |
| 1387 | - | |
| 1388 | - foreach ( $active_devices as $breakpoint_key ) { | |
| 1389 | - $label = 'desktop' === $breakpoint_key ? esc_html__( 'Desktop', 'elementor' ) : $active_breakpoints[ $breakpoint_key ]->get_label(); | |
| 1390 | - | |
| 1391 | - $this->add_control( | |
| 1392 | - 'hide_' . $breakpoint_key, | |
| 1393 | - [ | |
| 1394 | - 'label' => sprintf( | |
| 1395 | - /* translators: %s: Device name. */ | |
| 1396 | - esc_html__( 'Hide On %s', 'elementor' ), | |
| 1397 | - $label | |
| 1398 | - ), | |
| 1399 | - 'type' => Controls_Manager::SWITCHER, | |
| 1400 | - 'default' => '', | |
| 1401 | - 'prefix_class' => 'elementor-', | |
| 1402 | - 'label_on' => esc_html__( 'Hide', 'elementor' ), | |
| 1403 | - 'label_off' => esc_html__( 'Show', 'elementor' ), | |
| 1404 | - 'return_value' => 'hidden-' . $breakpoint_key, | |
| 1405 | - ] | |
| 1406 | - ); | |
| 1407 | - } | |
| 1408 | - } | |
| 1409 | - | |
| 1410 | - /** | |
| 1411 | 834 | * Get default data. |
| 1412 | 835 | * |
| 1413 | 836 | * Retrieve the default element data. Used to reset the data on initialization. |
| 1414 | 837 | * |
| @@ -1434,25 +857,10 @@ | ||
| 1434 | 857 | * Output the element final HTML on the frontend. |
| 1435 | 858 | * |
| 1436 | 859 | * @since 1.0.0 |
| 1437 | 860 | * @access protected |
| 1438 | - * @deprecated 3.1.0 Use `print_content()` method instead. | |
| 1439 | 861 | */ |
| 1440 | 862 | protected function _print_content() { |
| 1441 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0', 'print_content()' ); | |
| 1442 | - | |
| 1443 | - $this->print_content(); | |
| 1444 | - } | |
| 1445 | - | |
| 1446 | - /** | |
| 1447 | - * Print element content. | |
| 1448 | - * | |
| 1449 | - * Output the element final HTML on the frontend. | |
| 1450 | - * | |
| 1451 | - * @since 3.1.0 | |
| 1452 | - * @access protected | |
| 1453 | - */ | |
| 1454 | - protected function print_content() { | |
| 1455 | 863 | foreach ( $this->get_children() as $child ) { |
| 1456 | 864 | $child->print_element(); |
| 1457 | 865 | } |
| 1458 | 866 | } |
| @@ -1492,19 +900,8 @@ | ||
| 1492 | 900 | return $config; |
| 1493 | 901 | } |
| 1494 | 902 | |
| 1495 | 903 | /** |
| 1496 | - * A Base method for sanitizing the settings before save. | |
| 1497 | - * This method is meant to be overridden by the element. | |
| 1498 | - * | |
| 1499 | - * @param array $settings | |
| 1500 | - * @return array | |
| 1501 | - */ | |
| 1502 | - protected function on_save( array $settings ) { | |
| 1503 | - return $settings; | |
| 1504 | - } | |
| 1505 | - | |
| 1506 | - /** | |
| 1507 | 904 | * Get child type. |
| 1508 | 905 | * |
| 1509 | 906 | * Retrieve the element child type based on element data. |
| 1510 | 907 | * |
| @@ -1517,9 +914,9 @@ | ||
| 1517 | 914 | */ |
| 1518 | 915 | private function get_child_type( $element_data ) { |
| 1519 | 916 | $child_type = $this->_get_default_child_type( $element_data ); |
| 1520 | 917 | |
| 1521 | - // If it's not a valid widget ( like a deactivated plugin ). | |
| 918 | + // If it's not a valid widget ( like a deactivated plugin ) | |
| 1522 | 919 | if ( ! $child_type ) { |
| 1523 | 920 | return false; |
| 1524 | 921 | } |
| 1525 | 922 | |
| @@ -1564,12 +961,8 @@ | ||
| 1564 | 961 | $this->add_child( $child_data ); |
| 1565 | 962 | } |
| 1566 | 963 | } |
| 1567 | 964 | |
| 1568 | - public function has_widget_inner_wrapper(): bool { | |
| 1569 | - return true; | |
| 1570 | - } | |
| 1571 | - | |
| 1572 | 965 | /** |
| 1573 | 966 | * Element base constructor. |
| 1574 | 967 | * |
| 1575 | 968 | * Initializing the element base class using `$data` and `$args`. |
| @@ -1582,9 +975,9 @@ | ||
| 1582 | 975 | * |
| 1583 | 976 | * @param array $data Optional. Element data. Default is an empty array. |
| 1584 | 977 | * @param array|null $args Optional. Element default arguments. Default is null. |
| 1585 | 978 | **/ |
| 1586 | - public function __construct( array $data = [], ?array $args = null ) { | |
| 979 | + public function __construct( array $data = [], array $args = null ) { | |
| 1587 | 980 | if ( $data ) { |
| 1588 | 981 | $this->is_type_instance = false; |
| 1589 | 982 | } elseif ( $args ) { |
| 1590 | 983 | $this->default_args = $args; |