| @@ -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 | * |
| @@ -326,28 +315,8 @@ | ||
| 326 | 315 | |
| 327 | 316 | return $this->children; |
| 328 | 317 | } |
| 329 | 318 | |
| 330 | - public function render_markdown(): string { | |
| 331 | - $children = $this->get_children(); | |
| 332 | - | |
| 333 | - if ( empty( $children ) ) { | |
| 334 | - return ''; | |
| 335 | - } | |
| 336 | - | |
| 337 | - $parts = []; | |
| 338 | - | |
| 339 | - foreach ( $children as $child ) { | |
| 340 | - $md = $child->render_markdown(); | |
| 341 | - | |
| 342 | - if ( ! empty( trim( $md ) ) ) { | |
| 343 | - $parts[] = $md; | |
| 344 | - } | |
| 345 | - } | |
| 346 | - | |
| 347 | - return implode( "\n\n", $parts ); | |
| 348 | - } | |
| 349 | - | |
| 350 | 319 | /** |
| 351 | 320 | * Get default arguments. |
| 352 | 321 | * |
| 353 | 322 | * Retrieve the element default arguments. Used to return all the default |
| @@ -364,23 +333,8 @@ | ||
| 364 | 333 | return self::get_items( $this->default_args, $item ); |
| 365 | 334 | } |
| 366 | 335 | |
| 367 | 336 | /** |
| 368 | - * Get panel presets. | |
| 369 | - * | |
| 370 | - * Used for displaying the widget in the panel multiple times, but with different defaults values, | |
| 371 | - * icon, title etc. | |
| 372 | - * | |
| 373 | - * @since 3.16.0 | |
| 374 | - * @access public | |
| 375 | - * | |
| 376 | - * @return array | |
| 377 | - */ | |
| 378 | - public function get_panel_presets() { | |
| 379 | - return []; | |
| 380 | - } | |
| 381 | - | |
| 382 | - /** | |
| 383 | 337 | * Add new child element. |
| 384 | 338 | * |
| 385 | 339 | * Register new child element to allow hierarchy. |
| 386 | 340 | * |
| @@ -411,8 +365,66 @@ | ||
| 411 | 365 | return $child; |
| 412 | 366 | } |
| 413 | 367 | |
| 414 | 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 | + /** | |
| 415 | 427 | * Add link render attributes. |
| 416 | 428 | * |
| 417 | 429 | * Used to add link tag attributes to a specific HTML element. |
| 418 | 430 | * |
| @@ -426,14 +438,15 @@ | ||
| 426 | 438 | * @since 2.8.0 |
| 427 | 439 | * @access public |
| 428 | 440 | * |
| 429 | 441 | * @param array|string $element The HTML element. |
| 430 | - * @param array $url_control Array of link settings. | |
| 431 | - * @param bool $overwrite Optional. Whether to overwrite existing | |
| 432 | - * 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. | |
| 433 | 445 | * |
| 434 | 446 | * @return Element_Base Current instance of the element. |
| 435 | 447 | */ |
| 448 | + | |
| 436 | 449 | public function add_link_attributes( $element, array $url_control, $overwrite = false ) { |
| 437 | 450 | $attributes = []; |
| 438 | 451 | |
| 439 | 452 | if ( ! empty( $url_control['url'] ) ) { |
| @@ -450,28 +463,150 @@ | ||
| 450 | 463 | $attributes['rel'] = 'nofollow'; |
| 451 | 464 | } |
| 452 | 465 | |
| 453 | 466 | if ( ! empty( $url_control['custom_attributes'] ) ) { |
| 454 | - // 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 | |
| 455 | 468 | $attributes = array_merge( $attributes, Utils::parse_custom_attributes( $url_control['custom_attributes'] ) ); |
| 456 | 469 | } |
| 457 | 470 | |
| 458 | 471 | if ( $attributes ) { |
| 459 | - $this->add_render_attribute( $element, $attributes, null, $overwrite ); | |
| 472 | + $this->add_render_attribute( $element, $attributes, $overwrite ); | |
| 460 | 473 | } |
| 461 | 474 | |
| 462 | 475 | return $this; |
| 463 | 476 | } |
| 464 | 477 | |
| 465 | - public function reset_descendant_render_state(): void { | |
| 466 | - $this->reset_render_state(); | |
| 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; | |
| 467 | 497 | |
| 468 | - foreach ( $this->get_children() as $child ) { | |
| 469 | - $child->reset_descendant_render_state(); | |
| 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 | + } | |
| 470 | 512 | } |
| 513 | + | |
| 514 | + return $attributes; | |
| 471 | 515 | } |
| 472 | 516 | |
| 473 | 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 | + /** | |
| 474 | 609 | * Print element. |
| 475 | 610 | * |
| 476 | 611 | * Used to generate the element final HTML on the frontend and the editor. |
| 477 | 612 | * |
| @@ -480,15 +615,8 @@ | ||
| 480 | 615 | */ |
| 481 | 616 | public function print_element() { |
| 482 | 617 | $element_type = $this->get_type(); |
| 483 | 618 | |
| 484 | - if ( $this->should_render_shortcode() ) { | |
| 485 | - $unique_id = apply_filters( 'elementor/element_cache/unique_id', '' ); | |
| 486 | - | |
| 487 | - echo '[elementor-element k="' . esc_attr( $unique_id ) . '" data="' . esc_attr( base64_encode( wp_json_encode( $this->get_raw_data() ) ) ) . '"]'; | |
| 488 | - return; | |
| 489 | - } | |
| 490 | - | |
| 491 | 619 | /** |
| 492 | 620 | * Before frontend element render. |
| 493 | 621 | * |
| 494 | 622 | * Fires before Elementor element is rendered in the frontend. |
| @@ -547,14 +675,11 @@ | ||
| 547 | 675 | $this->add_render_attributes(); |
| 548 | 676 | } |
| 549 | 677 | |
| 550 | 678 | $this->before_render(); |
| 551 | - // PHPCS - The content has already been escaped by the `render` method. | |
| 552 | - echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 679 | + echo $content; | |
| 553 | 680 | $this->after_render(); |
| 554 | 681 | |
| 555 | - // TODO: Remove this in the future | |
| 556 | - // Since version 3.24.0 page scripts/styles are handled by `page_assets`. | |
| 557 | 682 | $this->enqueue_scripts(); |
| 558 | 683 | $this->enqueue_styles(); |
| 559 | 684 | } |
| 560 | 685 | |
| @@ -582,54 +707,8 @@ | ||
| 582 | 707 | */ |
| 583 | 708 | do_action( 'elementor/frontend/after_render', $this ); |
| 584 | 709 | } |
| 585 | 710 | |
| 586 | - protected function should_render_shortcode() { | |
| 587 | - $should_render_shortcode = apply_filters( 'elementor/element/should_render_shortcode', false ); | |
| 588 | - | |
| 589 | - if ( ! $should_render_shortcode ) { | |
| 590 | - return false; | |
| 591 | - } | |
| 592 | - | |
| 593 | - $raw_data = $this->get_raw_data(); | |
| 594 | - | |
| 595 | - if ( ! empty( $raw_data['settings']['_element_cache'] ) ) { | |
| 596 | - return 'yes' === $raw_data['settings']['_element_cache']; | |
| 597 | - } | |
| 598 | - | |
| 599 | - if ( $this->is_dynamic_content() ) { | |
| 600 | - return true; | |
| 601 | - } | |
| 602 | - | |
| 603 | - $is_dynamic_content = apply_filters( 'elementor/element/is_dynamic_content', false, $raw_data, $this ); | |
| 604 | - | |
| 605 | - $has_dynamic_tag = $this->has_element_dynamic_tag( $raw_data['settings'] ); | |
| 606 | - | |
| 607 | - if ( $is_dynamic_content || $has_dynamic_tag ) { | |
| 608 | - return true; | |
| 609 | - } | |
| 610 | - | |
| 611 | - return false; | |
| 612 | - } | |
| 613 | - | |
| 614 | - private function has_element_dynamic_tag( $element_settings ): bool { | |
| 615 | - if ( is_array( $element_settings ) ) { | |
| 616 | - if ( ! empty( $element_settings['__dynamic__'] ) ) { | |
| 617 | - return true; | |
| 618 | - } | |
| 619 | - | |
| 620 | - foreach ( $element_settings as $value ) { | |
| 621 | - $has_dynamic = $this->has_element_dynamic_tag( $value ); | |
| 622 | - | |
| 623 | - if ( $has_dynamic ) { | |
| 624 | - return true; | |
| 625 | - } | |
| 626 | - } | |
| 627 | - } | |
| 628 | - | |
| 629 | - return false; | |
| 630 | - } | |
| 631 | - | |
| 632 | 711 | /** |
| 633 | 712 | * Get the element raw data. |
| 634 | 713 | * |
| 635 | 714 | * Retrieve the raw element data, including the id, type, settings, child |
| @@ -656,9 +735,9 @@ | ||
| 656 | 735 | foreach ( $this->get_children() as $child ) { |
| 657 | 736 | $elements[] = $child->get_raw_data( $with_html_content ); |
| 658 | 737 | } |
| 659 | 738 | |
| 660 | - $raw_data = [ | |
| 739 | + return [ | |
| 661 | 740 | 'id' => $this->get_id(), |
| 662 | 741 | 'elType' => $data['elType'], |
| 663 | 742 | 'settings' => $data['settings'], |
| 664 | 743 | 'elements' => $elements, |
| @@ -663,36 +742,10 @@ | ||
| 663 | 742 | 'settings' => $data['settings'], |
| 664 | 743 | 'elements' => $elements, |
| 665 | 744 | 'isInner' => $data['isInner'], |
| 666 | 745 | ]; |
| 667 | - | |
| 668 | - if ( ! empty( $data['isLocked'] ) ) { | |
| 669 | - $raw_data['isLocked'] = $data['isLocked']; | |
| 670 | - } | |
| 671 | - | |
| 672 | - return $raw_data; | |
| 673 | 746 | } |
| 674 | 747 | |
| 675 | - public function get_data_for_save() { | |
| 676 | - $data = $this->get_raw_data(); | |
| 677 | - | |
| 678 | - $elements = []; | |
| 679 | - | |
| 680 | - foreach ( $this->get_children() as $child ) { | |
| 681 | - $elements[] = $child->get_data_for_save(); | |
| 682 | - } | |
| 683 | - | |
| 684 | - if ( ! empty( $elements ) ) { | |
| 685 | - $data['elements'] = $elements; | |
| 686 | - } | |
| 687 | - | |
| 688 | - if ( ! empty( $data['settings'] ) ) { | |
| 689 | - $data['settings'] = $this->on_save( $data['settings'] ); | |
| 690 | - } | |
| 691 | - | |
| 692 | - return $data; | |
| 693 | - } | |
| 694 | - | |
| 695 | 748 | /** |
| 696 | 749 | * Get unique selector. |
| 697 | 750 | * |
| 698 | 751 | * Retrieve the unique selector of the element. Used to set a unique HTML |
| @@ -722,47 +775,8 @@ | ||
| 722 | 775 | return $this->is_type_instance; |
| 723 | 776 | } |
| 724 | 777 | |
| 725 | 778 | /** |
| 726 | - * On import update dynamic content (e.g. post and term IDs). | |
| 727 | - * | |
| 728 | - * @since 3.8.0 | |
| 729 | - * | |
| 730 | - * @param array $config The config of the passed element. | |
| 731 | - * @param array $data The data that requires updating/replacement when imported. | |
| 732 | - * @param array|null $controls The available controls. | |
| 733 | - * | |
| 734 | - * @return array Element data. | |
| 735 | - */ | |
| 736 | - public static function on_import_update_dynamic_content( array $config, array $data, $controls = null ): array { | |
| 737 | - $tags_manager = Plugin::$instance->dynamic_tags; | |
| 738 | - | |
| 739 | - if ( empty( $config['settings'][ $tags_manager::DYNAMIC_SETTING_KEY ] ) ) { | |
| 740 | - return $config; | |
| 741 | - } | |
| 742 | - | |
| 743 | - foreach ( $config['settings'][ $tags_manager::DYNAMIC_SETTING_KEY ] as $dynamic_name => $dynamic_value ) { | |
| 744 | - $tag_config = $tags_manager->tag_text_to_tag_data( $dynamic_value ); | |
| 745 | - $tag_instance = $tags_manager->create_tag( $tag_config['id'], $tag_config['name'], $tag_config['settings'] ); | |
| 746 | - | |
| 747 | - if ( is_null( $tag_instance ) ) { | |
| 748 | - continue; | |
| 749 | - } | |
| 750 | - | |
| 751 | - if ( $tag_instance->has_own_method( 'on_import_replace_dynamic_content' ) ) { | |
| 752 | - // TODO: Remove this check in the future. | |
| 753 | - $tag_config = $tag_instance->on_import_replace_dynamic_content( $tag_config, $data['post_ids'] ); | |
| 754 | - } else { | |
| 755 | - $tag_config = $tag_instance->on_import_update_dynamic_content( $tag_config, $data, $tag_instance->get_controls() ); | |
| 756 | - } | |
| 757 | - | |
| 758 | - $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'] ); | |
| 759 | - } | |
| 760 | - | |
| 761 | - return $config; | |
| 762 | - } | |
| 763 | - | |
| 764 | - /** | |
| 765 | 779 | * Add render attributes. |
| 766 | 780 | * |
| 767 | 781 | * Used to add attributes to the current element wrapper HTML tag. |
| 768 | 782 | * |
| @@ -767,12 +781,12 @@ | ||
| 767 | 781 | * Used to add attributes to the current element wrapper HTML tag. |
| 768 | 782 | * |
| 769 | 783 | * @since 1.3.0 |
| 770 | 784 | * @access protected |
| 771 | - * @deprecated 3.1.0 Use `add_render_attribute()` method instead. | |
| 785 | + * @deprecated 3.1.0 | |
| 772 | 786 | */ |
| 773 | 787 | protected function _add_render_attributes() { |
| 774 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0', 'add_render_attributes()' ); | |
| 788 | + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0', __CLASS__ . '::add_render_attributes()' ); | |
| 775 | 789 | |
| 776 | 790 | return $this->add_render_attributes(); |
| 777 | 791 | } |
| 778 | 792 | |
| @@ -797,9 +811,8 @@ | ||
| 797 | 811 | 'elementor-element-' . $id, |
| 798 | 812 | ], |
| 799 | 813 | 'data-id' => $id, |
| 800 | 814 | 'data-element_type' => $this->get_type(), |
| 801 | - 'data-e-type' => $this->get_type(), | |
| 802 | 815 | ] ); |
| 803 | 816 | |
| 804 | 817 | $class_settings = []; |
| 805 | 818 | |
| @@ -804,15 +817,9 @@ | ||
| 804 | 817 | $class_settings = []; |
| 805 | 818 | |
| 806 | 819 | foreach ( $settings as $setting_key => $setting ) { |
| 807 | 820 | if ( isset( $controls[ $setting_key ]['prefix_class'] ) ) { |
| 808 | - if ( isset( $controls[ $setting_key ]['classes_dictionary'][ $setting ] ) ) { | |
| 809 | - $value = $controls[ $setting_key ]['classes_dictionary'][ $setting ]; | |
| 810 | - } else { | |
| 811 | - $value = $setting; | |
| 812 | - } | |
| 813 | - | |
| 814 | - $class_settings[ $setting_key ] = $value; | |
| 821 | + $class_settings[ $setting_key ] = $setting; | |
| 815 | 822 | } |
| 816 | 823 | } |
| 817 | 824 | |
| 818 | 825 | foreach ( $class_settings as $setting_key => $setting ) { |
| @@ -824,15 +831,15 @@ | ||
| 824 | 831 | } |
| 825 | 832 | |
| 826 | 833 | $_animation = ! empty( $settings['_animation'] ); |
| 827 | 834 | $animation = ! empty( $settings['animation'] ); |
| 828 | - $has_animation = ( $_animation && 'none' !== $settings['_animation'] ) || ( $animation && 'none' !== $settings['animation'] ); | |
| 835 | + $has_animation = $_animation && 'none' !== $settings['_animation'] || $animation && 'none' !== $settings['animation']; | |
| 829 | 836 | |
| 830 | 837 | if ( $has_animation ) { |
| 831 | 838 | $is_static_render_mode = Plugin::$instance->frontend->is_static_render_mode(); |
| 832 | 839 | |
| 833 | 840 | if ( ! $is_static_render_mode ) { |
| 834 | - // Hide the element until the animation begins. | |
| 841 | + // Hide the element until the animation begins | |
| 835 | 842 | $this->add_render_attribute( '_wrapper', 'class', 'elementor-invisible' ); |
| 836 | 843 | } |
| 837 | 844 | } |
| 838 | 845 | |
| @@ -856,587 +863,8 @@ | ||
| 856 | 863 | do_action( 'elementor/element/after_add_attributes', $this ); |
| 857 | 864 | } |
| 858 | 865 | |
| 859 | 866 | /** |
| 860 | - * Register the Transform controls in the advanced tab of the element. | |
| 861 | - * | |
| 862 | - * Previously registered under the Widget_Common class, but registered a more fundamental level now to enable access from other widgets. | |
| 863 | - * | |
| 864 | - * @param string $element_selector | |
| 865 | - * @param string $transform_selector_class | |
| 866 | - * @return void | |
| 867 | - * @since 3.9.0 | |
| 868 | - * @access protected | |
| 869 | - */ | |
| 870 | - protected function register_transform_section( $element_selector = '', $transform_selector_class = ' > .elementor-widget-container' ) { | |
| 871 | - $default_unit_values_deg = []; | |
| 872 | - $default_unit_values_ms = []; | |
| 873 | - | |
| 874 | - // Set the default unit sizes for all active breakpoints. | |
| 875 | - foreach ( Breakpoints_Manager::get_default_config() as $breakpoint_name => $breakpoint_config ) { | |
| 876 | - $default_unit_values_deg[ $breakpoint_name ] = [ | |
| 877 | - 'default' => [ | |
| 878 | - 'unit' => 'deg', | |
| 879 | - ], | |
| 880 | - ]; | |
| 881 | - | |
| 882 | - $default_unit_values_ms[ $breakpoint_name ] = [ | |
| 883 | - 'default' => [ | |
| 884 | - 'unit' => 'ms', | |
| 885 | - ], | |
| 886 | - ]; | |
| 887 | - } | |
| 888 | - | |
| 889 | - $this->start_controls_section( | |
| 890 | - '_section_transform', | |
| 891 | - [ | |
| 892 | - 'label' => esc_html__( 'Transform', 'elementor' ), | |
| 893 | - 'tab' => Controls_Manager::TAB_ADVANCED, | |
| 894 | - ] | |
| 895 | - ); | |
| 896 | - | |
| 897 | - $this->start_controls_tabs( '_tabs_positioning' ); | |
| 898 | - | |
| 899 | - $transform_prefix_class = 'e-'; | |
| 900 | - $transform_return_value = 'transform'; | |
| 901 | - $transform_css_modifier = ''; | |
| 902 | - | |
| 903 | - if ( 'con' === $element_selector ) { | |
| 904 | - $transform_selector_class = '.e-' . $element_selector; | |
| 905 | - $transform_css_modifier = $element_selector . '-'; | |
| 906 | - } | |
| 907 | - | |
| 908 | - foreach ( [ '', '_hover' ] as $tab ) { | |
| 909 | - $state = '_hover' === $tab ? ':hover' : ''; | |
| 910 | - | |
| 911 | - $this->start_controls_tab( | |
| 912 | - "_tab_positioning{$tab}", | |
| 913 | - [ | |
| 914 | - 'label' => '' === $tab ? esc_html__( 'Normal', 'elementor' ) : esc_html__( 'Hover', 'elementor' ), | |
| 915 | - ] | |
| 916 | - ); | |
| 917 | - | |
| 918 | - $this->add_control( | |
| 919 | - "_transform_rotate_popover{$tab}", | |
| 920 | - [ | |
| 921 | - 'label' => esc_html__( 'Rotate', 'elementor' ), | |
| 922 | - 'type' => Controls_Manager::POPOVER_TOGGLE, | |
| 923 | - 'prefix_class' => $transform_prefix_class, | |
| 924 | - 'return_value' => $transform_return_value, | |
| 925 | - ] | |
| 926 | - ); | |
| 927 | - | |
| 928 | - $this->start_popover(); | |
| 929 | - | |
| 930 | - $this->add_responsive_control( | |
| 931 | - "_transform_rotateZ_effect{$tab}", | |
| 932 | - [ | |
| 933 | - 'label' => esc_html__( 'Rotate', 'elementor' ) . ' (deg)', | |
| 934 | - 'type' => Controls_Manager::SLIDER, | |
| 935 | - 'device_args' => $default_unit_values_deg, | |
| 936 | - 'range' => [ | |
| 937 | - 'px' => [ | |
| 938 | - 'min' => -360, | |
| 939 | - 'max' => 360, | |
| 940 | - ], | |
| 941 | - ], | |
| 942 | - 'selectors' => [ | |
| 943 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-rotateZ: {{SIZE}}deg', | |
| 944 | - ], | |
| 945 | - 'condition' => [ | |
| 946 | - "_transform_rotate_popover{$tab}!" => '', | |
| 947 | - ], | |
| 948 | - 'frontend_available' => true, | |
| 949 | - ] | |
| 950 | - ); | |
| 951 | - | |
| 952 | - $this->add_control( | |
| 953 | - "_transform_rotate_3d{$tab}", | |
| 954 | - [ | |
| 955 | - 'label' => esc_html__( '3D Rotate', 'elementor' ), | |
| 956 | - 'type' => Controls_Manager::SWITCHER, | |
| 957 | - 'label_on' => esc_html__( 'On', 'elementor' ), | |
| 958 | - 'label_off' => esc_html__( 'Off', 'elementor' ), | |
| 959 | - 'selectors' => [ | |
| 960 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-rotateX: 1{{UNIT}}; --e-' . $transform_css_modifier . 'transform-perspective: 20px;', | |
| 961 | - ], | |
| 962 | - 'condition' => [ | |
| 963 | - "_transform_rotate_popover{$tab}!" => '', | |
| 964 | - ], | |
| 965 | - 'frontend_available' => true, | |
| 966 | - ] | |
| 967 | - ); | |
| 968 | - | |
| 969 | - $this->add_responsive_control( | |
| 970 | - "_transform_rotateX_effect{$tab}", | |
| 971 | - [ | |
| 972 | - 'label' => esc_html__( 'Rotate X', 'elementor' ) . ' (deg)', | |
| 973 | - 'type' => Controls_Manager::SLIDER, | |
| 974 | - 'device_args' => $default_unit_values_deg, | |
| 975 | - 'range' => [ | |
| 976 | - 'px' => [ | |
| 977 | - 'min' => -360, | |
| 978 | - 'max' => 360, | |
| 979 | - ], | |
| 980 | - ], | |
| 981 | - 'condition' => [ | |
| 982 | - "_transform_rotate_3d{$tab}!" => '', | |
| 983 | - "_transform_rotate_popover{$tab}!" => '', | |
| 984 | - ], | |
| 985 | - 'selectors' => [ | |
| 986 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-rotateX: {{SIZE}}deg;', | |
| 987 | - ], | |
| 988 | - 'frontend_available' => true, | |
| 989 | - ] | |
| 990 | - ); | |
| 991 | - | |
| 992 | - $this->add_responsive_control( | |
| 993 | - "_transform_rotateY_effect{$tab}", | |
| 994 | - [ | |
| 995 | - 'label' => esc_html__( 'Rotate Y', 'elementor' ) . ' (deg)', | |
| 996 | - 'type' => Controls_Manager::SLIDER, | |
| 997 | - 'device_args' => $default_unit_values_deg, | |
| 998 | - 'range' => [ | |
| 999 | - 'px' => [ | |
| 1000 | - 'min' => -360, | |
| 1001 | - 'max' => 360, | |
| 1002 | - ], | |
| 1003 | - ], | |
| 1004 | - 'condition' => [ | |
| 1005 | - "_transform_rotate_3d{$tab}!" => '', | |
| 1006 | - "_transform_rotate_popover{$tab}!" => '', | |
| 1007 | - ], | |
| 1008 | - 'selectors' => [ | |
| 1009 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-rotateY: {{SIZE}}deg;', | |
| 1010 | - ], | |
| 1011 | - 'frontend_available' => true, | |
| 1012 | - ] | |
| 1013 | - ); | |
| 1014 | - | |
| 1015 | - $this->add_responsive_control( | |
| 1016 | - "_transform_perspective_effect{$tab}", | |
| 1017 | - [ | |
| 1018 | - 'label' => esc_html__( 'Perspective', 'elementor' ) . ' (px)', | |
| 1019 | - 'type' => Controls_Manager::SLIDER, | |
| 1020 | - 'range' => [ | |
| 1021 | - 'px' => [ | |
| 1022 | - 'max' => 1000, | |
| 1023 | - ], | |
| 1024 | - ], | |
| 1025 | - 'condition' => [ | |
| 1026 | - "_transform_rotate_popover{$tab}!" => '', | |
| 1027 | - "_transform_rotate_3d{$tab}!" => '', | |
| 1028 | - ], | |
| 1029 | - 'selectors' => [ | |
| 1030 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-perspective: {{SIZE}}px', | |
| 1031 | - ], | |
| 1032 | - 'frontend_available' => true, | |
| 1033 | - ] | |
| 1034 | - ); | |
| 1035 | - | |
| 1036 | - $this->end_popover(); | |
| 1037 | - | |
| 1038 | - $this->add_control( | |
| 1039 | - "_transform_translate_popover{$tab}", | |
| 1040 | - [ | |
| 1041 | - 'label' => esc_html__( 'Offset', 'elementor' ), | |
| 1042 | - 'type' => Controls_Manager::POPOVER_TOGGLE, | |
| 1043 | - 'prefix_class' => $transform_prefix_class, | |
| 1044 | - 'return_value' => $transform_return_value, | |
| 1045 | - ] | |
| 1046 | - ); | |
| 1047 | - | |
| 1048 | - $this->start_popover(); | |
| 1049 | - | |
| 1050 | - $this->add_responsive_control( | |
| 1051 | - "_transform_translateX_effect{$tab}", | |
| 1052 | - [ | |
| 1053 | - 'label' => esc_html__( 'Offset X', 'elementor' ), | |
| 1054 | - 'type' => Controls_Manager::SLIDER, | |
| 1055 | - 'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], | |
| 1056 | - 'range' => [ | |
| 1057 | - '%' => [ | |
| 1058 | - 'min' => -100, | |
| 1059 | - 'max' => 100, | |
| 1060 | - ], | |
| 1061 | - 'px' => [ | |
| 1062 | - 'min' => -1000, | |
| 1063 | - 'max' => 1000, | |
| 1064 | - ], | |
| 1065 | - ], | |
| 1066 | - 'condition' => [ | |
| 1067 | - "_transform_translate_popover{$tab}!" => '', | |
| 1068 | - ], | |
| 1069 | - 'selectors' => [ | |
| 1070 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-translateX: {{SIZE}}{{UNIT}};', | |
| 1071 | - ], | |
| 1072 | - 'frontend_available' => true, | |
| 1073 | - ] | |
| 1074 | - ); | |
| 1075 | - | |
| 1076 | - $this->add_responsive_control( | |
| 1077 | - "_transform_translateY_effect{$tab}", | |
| 1078 | - [ | |
| 1079 | - 'label' => esc_html__( 'Offset Y', 'elementor' ), | |
| 1080 | - 'type' => Controls_Manager::SLIDER, | |
| 1081 | - 'size_units' => [ 'px', '%', 'em', 'rem', 'vh', 'custom' ], | |
| 1082 | - 'range' => [ | |
| 1083 | - '%' => [ | |
| 1084 | - 'min' => -100, | |
| 1085 | - 'max' => 100, | |
| 1086 | - ], | |
| 1087 | - 'px' => [ | |
| 1088 | - 'min' => -1000, | |
| 1089 | - 'max' => 1000, | |
| 1090 | - ], | |
| 1091 | - ], | |
| 1092 | - 'condition' => [ | |
| 1093 | - "_transform_translate_popover{$tab}!" => '', | |
| 1094 | - ], | |
| 1095 | - 'selectors' => [ | |
| 1096 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-translateY: {{SIZE}}{{UNIT}};', | |
| 1097 | - ], | |
| 1098 | - 'frontend_available' => true, | |
| 1099 | - ] | |
| 1100 | - ); | |
| 1101 | - | |
| 1102 | - $this->end_popover(); | |
| 1103 | - | |
| 1104 | - $this->add_control( | |
| 1105 | - "_transform_scale_popover{$tab}", | |
| 1106 | - [ | |
| 1107 | - 'label' => esc_html__( 'Scale', 'elementor' ), | |
| 1108 | - 'type' => Controls_Manager::POPOVER_TOGGLE, | |
| 1109 | - 'prefix_class' => $transform_prefix_class, | |
| 1110 | - 'return_value' => $transform_return_value, | |
| 1111 | - ] | |
| 1112 | - ); | |
| 1113 | - | |
| 1114 | - $this->start_popover(); | |
| 1115 | - | |
| 1116 | - $this->add_control( | |
| 1117 | - "_transform_keep_proportions{$tab}", | |
| 1118 | - [ | |
| 1119 | - 'label' => esc_html__( 'Keep Proportions', 'elementor' ), | |
| 1120 | - 'type' => Controls_Manager::SWITCHER, | |
| 1121 | - 'label_on' => esc_html__( 'On', 'elementor' ), | |
| 1122 | - 'label_off' => esc_html__( 'Off', 'elementor' ), | |
| 1123 | - 'default' => 'yes', | |
| 1124 | - ] | |
| 1125 | - ); | |
| 1126 | - | |
| 1127 | - $this->add_responsive_control( | |
| 1128 | - "_transform_scale_effect{$tab}", | |
| 1129 | - [ | |
| 1130 | - 'label' => esc_html__( 'Scale', 'elementor' ), | |
| 1131 | - 'type' => Controls_Manager::SLIDER, | |
| 1132 | - 'range' => [ | |
| 1133 | - 'px' => [ | |
| 1134 | - 'max' => 2, | |
| 1135 | - 'step' => 0.1, | |
| 1136 | - ], | |
| 1137 | - ], | |
| 1138 | - 'condition' => [ | |
| 1139 | - "_transform_scale_popover{$tab}!" => '', | |
| 1140 | - "_transform_keep_proportions{$tab}!" => '', | |
| 1141 | - ], | |
| 1142 | - 'selectors' => [ | |
| 1143 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-scale: {{SIZE}};', | |
| 1144 | - ], | |
| 1145 | - 'frontend_available' => true, | |
| 1146 | - ] | |
| 1147 | - ); | |
| 1148 | - | |
| 1149 | - $this->add_responsive_control( | |
| 1150 | - "_transform_scaleX_effect{$tab}", | |
| 1151 | - [ | |
| 1152 | - 'label' => esc_html__( 'Scale X', 'elementor' ), | |
| 1153 | - 'type' => Controls_Manager::SLIDER, | |
| 1154 | - 'range' => [ | |
| 1155 | - 'px' => [ | |
| 1156 | - 'max' => 2, | |
| 1157 | - 'step' => 0.1, | |
| 1158 | - ], | |
| 1159 | - ], | |
| 1160 | - 'condition' => [ | |
| 1161 | - "_transform_scale_popover{$tab}!" => '', | |
| 1162 | - "_transform_keep_proportions{$tab}" => '', | |
| 1163 | - ], | |
| 1164 | - 'selectors' => [ | |
| 1165 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-scaleX: {{SIZE}};', | |
| 1166 | - ], | |
| 1167 | - 'frontend_available' => true, | |
| 1168 | - ] | |
| 1169 | - ); | |
| 1170 | - | |
| 1171 | - $this->add_responsive_control( | |
| 1172 | - "_transform_scaleY_effect{$tab}", | |
| 1173 | - [ | |
| 1174 | - 'label' => esc_html__( 'Scale Y', 'elementor' ), | |
| 1175 | - 'type' => Controls_Manager::SLIDER, | |
| 1176 | - 'range' => [ | |
| 1177 | - 'px' => [ | |
| 1178 | - 'max' => 2, | |
| 1179 | - 'step' => 0.1, | |
| 1180 | - ], | |
| 1181 | - ], | |
| 1182 | - 'condition' => [ | |
| 1183 | - "_transform_scale_popover{$tab}!" => '', | |
| 1184 | - "_transform_keep_proportions{$tab}" => '', | |
| 1185 | - ], | |
| 1186 | - 'selectors' => [ | |
| 1187 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-scaleY: {{SIZE}};', | |
| 1188 | - ], | |
| 1189 | - 'frontend_available' => true, | |
| 1190 | - ] | |
| 1191 | - ); | |
| 1192 | - | |
| 1193 | - $this->end_popover(); | |
| 1194 | - | |
| 1195 | - $this->add_control( | |
| 1196 | - "_transform_skew_popover{$tab}", | |
| 1197 | - [ | |
| 1198 | - 'label' => esc_html__( 'Skew', 'elementor' ), | |
| 1199 | - 'type' => Controls_Manager::POPOVER_TOGGLE, | |
| 1200 | - 'prefix_class' => $transform_prefix_class, | |
| 1201 | - 'return_value' => $transform_return_value, | |
| 1202 | - ] | |
| 1203 | - ); | |
| 1204 | - | |
| 1205 | - $this->start_popover(); | |
| 1206 | - | |
| 1207 | - $this->add_responsive_control( | |
| 1208 | - "_transform_skewX_effect{$tab}", | |
| 1209 | - [ | |
| 1210 | - 'label' => esc_html__( 'Skew X', 'elementor' ) . ' (deg)', | |
| 1211 | - 'type' => Controls_Manager::SLIDER, | |
| 1212 | - 'device_args' => $default_unit_values_deg, | |
| 1213 | - 'range' => [ | |
| 1214 | - 'px' => [ | |
| 1215 | - 'min' => -360, | |
| 1216 | - 'max' => 360, | |
| 1217 | - ], | |
| 1218 | - ], | |
| 1219 | - 'condition' => [ | |
| 1220 | - "_transform_skew_popover{$tab}!" => '', | |
| 1221 | - ], | |
| 1222 | - 'selectors' => [ | |
| 1223 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-skewX: {{SIZE}}deg;', | |
| 1224 | - ], | |
| 1225 | - 'frontend_available' => true, | |
| 1226 | - ] | |
| 1227 | - ); | |
| 1228 | - | |
| 1229 | - $this->add_responsive_control( | |
| 1230 | - "_transform_skewY_effect{$tab}", | |
| 1231 | - [ | |
| 1232 | - 'label' => esc_html__( 'Skew Y', 'elementor' ) . ' (deg)', | |
| 1233 | - 'type' => Controls_Manager::SLIDER, | |
| 1234 | - 'device_args' => $default_unit_values_deg, | |
| 1235 | - 'range' => [ | |
| 1236 | - 'px' => [ | |
| 1237 | - 'min' => -360, | |
| 1238 | - 'max' => 360, | |
| 1239 | - ], | |
| 1240 | - ], | |
| 1241 | - 'condition' => [ | |
| 1242 | - "_transform_skew_popover{$tab}!" => '', | |
| 1243 | - ], | |
| 1244 | - 'selectors' => [ | |
| 1245 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-skewY: {{SIZE}}deg;', | |
| 1246 | - ], | |
| 1247 | - 'frontend_available' => true, | |
| 1248 | - ] | |
| 1249 | - ); | |
| 1250 | - | |
| 1251 | - $this->end_popover(); | |
| 1252 | - | |
| 1253 | - $this->add_control( | |
| 1254 | - "_transform_flipX_effect{$tab}", | |
| 1255 | - [ | |
| 1256 | - 'label' => esc_html__( 'Flip Horizontal', 'elementor' ), | |
| 1257 | - 'type' => Controls_Manager::CHOOSE, | |
| 1258 | - 'options' => [ | |
| 1259 | - 'transform' => [ | |
| 1260 | - 'title' => esc_html__( 'Flip Horizontal', 'elementor' ), | |
| 1261 | - 'icon' => 'eicon-flip eicon-tilted', | |
| 1262 | - ], | |
| 1263 | - ], | |
| 1264 | - 'prefix_class' => $transform_prefix_class, | |
| 1265 | - 'selectors' => [ | |
| 1266 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-flipX: -1', | |
| 1267 | - ], | |
| 1268 | - 'frontend_available' => true, | |
| 1269 | - ] | |
| 1270 | - ); | |
| 1271 | - | |
| 1272 | - $this->add_control( | |
| 1273 | - "_transform_flipY_effect{$tab}", | |
| 1274 | - [ | |
| 1275 | - 'label' => esc_html__( 'Flip Vertical', 'elementor' ), | |
| 1276 | - 'type' => Controls_Manager::CHOOSE, | |
| 1277 | - 'options' => [ | |
| 1278 | - 'transform' => [ | |
| 1279 | - 'title' => esc_html__( 'Flip Vertical', 'elementor' ), | |
| 1280 | - 'icon' => 'eicon-flip', | |
| 1281 | - ], | |
| 1282 | - ], | |
| 1283 | - 'prefix_class' => $transform_prefix_class, | |
| 1284 | - 'selectors' => [ | |
| 1285 | - "{{WRAPPER}}{$transform_selector_class}{$state}" => '--e-' . $transform_css_modifier . 'transform-flipY: -1', | |
| 1286 | - ], | |
| 1287 | - 'frontend_available' => true, | |
| 1288 | - ] | |
| 1289 | - ); | |
| 1290 | - | |
| 1291 | - if ( '_hover' === $tab ) { | |
| 1292 | - $this->add_control( | |
| 1293 | - '_transform_transition_hover', | |
| 1294 | - [ | |
| 1295 | - 'label' => esc_html__( 'Transition Duration', 'elementor' ) . ' (ms)', | |
| 1296 | - 'type' => Controls_Manager::SLIDER, | |
| 1297 | - 'device_args' => $default_unit_values_ms, | |
| 1298 | - 'range' => [ | |
| 1299 | - 'px' => [ | |
| 1300 | - 'min' => 0, | |
| 1301 | - 'max' => 10000, | |
| 1302 | - 'step' => 100, | |
| 1303 | - ], | |
| 1304 | - ], | |
| 1305 | - 'selectors' => [ | |
| 1306 | - '{{WRAPPER}}' => '--e-' . $transform_css_modifier . 'transform-transition-duration: {{SIZE}}ms', | |
| 1307 | - ], | |
| 1308 | - ] | |
| 1309 | - ); | |
| 1310 | - } | |
| 1311 | - | |
| 1312 | - ${"transform_origin_conditions{$tab}"} = [ | |
| 1313 | - [ | |
| 1314 | - 'name' => "_transform_scale_popover{$tab}", | |
| 1315 | - 'operator' => '!=', | |
| 1316 | - 'value' => '', | |
| 1317 | - ], | |
| 1318 | - [ | |
| 1319 | - 'name' => "_transform_rotate_popover{$tab}", | |
| 1320 | - 'operator' => '!=', | |
| 1321 | - 'value' => '', | |
| 1322 | - ], | |
| 1323 | - [ | |
| 1324 | - 'name' => "_transform_flipX_effect{$tab}", | |
| 1325 | - 'operator' => '!=', | |
| 1326 | - 'value' => '', | |
| 1327 | - ], | |
| 1328 | - [ | |
| 1329 | - 'name' => "_transform_flipY_effect{$tab}", | |
| 1330 | - 'operator' => '!=', | |
| 1331 | - 'value' => '', | |
| 1332 | - ], | |
| 1333 | - ]; | |
| 1334 | - | |
| 1335 | - $this->end_controls_tab(); | |
| 1336 | - } | |
| 1337 | - | |
| 1338 | - $this->end_controls_tabs(); | |
| 1339 | - | |
| 1340 | - $transform_origin_conditions = [ | |
| 1341 | - 'relation' => 'or', | |
| 1342 | - 'terms' => array_merge( $transform_origin_conditions, $transform_origin_conditions_hover ), | |
| 1343 | - ]; | |
| 1344 | - | |
| 1345 | - // Will override motion effect transform-origin. | |
| 1346 | - $this->add_responsive_control( | |
| 1347 | - 'motion_fx_transform_x_anchor_point', | |
| 1348 | - [ | |
| 1349 | - 'label' => esc_html__( 'X Anchor Point', 'elementor' ), | |
| 1350 | - 'type' => Controls_Manager::CHOOSE, | |
| 1351 | - 'options' => [ | |
| 1352 | - 'left' => [ | |
| 1353 | - 'title' => esc_html__( 'Left', 'elementor' ), | |
| 1354 | - 'icon' => 'eicon-h-align-left', | |
| 1355 | - ], | |
| 1356 | - 'center' => [ | |
| 1357 | - 'title' => esc_html__( 'Center', 'elementor' ), | |
| 1358 | - 'icon' => 'eicon-h-align-center', | |
| 1359 | - ], | |
| 1360 | - 'right' => [ | |
| 1361 | - 'title' => esc_html__( 'Right', 'elementor' ), | |
| 1362 | - 'icon' => 'eicon-h-align-right', | |
| 1363 | - ], | |
| 1364 | - ], | |
| 1365 | - 'conditions' => $transform_origin_conditions, | |
| 1366 | - 'separator' => 'before', | |
| 1367 | - 'selectors' => [ | |
| 1368 | - '{{WRAPPER}}' => '--e-' . $transform_css_modifier . 'transform-origin-x: {{VALUE}}', | |
| 1369 | - ], | |
| 1370 | - ] | |
| 1371 | - ); | |
| 1372 | - | |
| 1373 | - // Will override motion effect transform-origin. | |
| 1374 | - $this->add_responsive_control( | |
| 1375 | - 'motion_fx_transform_y_anchor_point', | |
| 1376 | - [ | |
| 1377 | - 'label' => esc_html__( 'Y Anchor Point', 'elementor' ), | |
| 1378 | - 'type' => Controls_Manager::CHOOSE, | |
| 1379 | - 'options' => [ | |
| 1380 | - 'top' => [ | |
| 1381 | - 'title' => esc_html__( 'Top', 'elementor' ), | |
| 1382 | - 'icon' => 'eicon-v-align-top', | |
| 1383 | - ], | |
| 1384 | - 'center' => [ | |
| 1385 | - 'title' => esc_html__( 'Center', 'elementor' ), | |
| 1386 | - 'icon' => 'eicon-v-align-middle', | |
| 1387 | - ], | |
| 1388 | - 'bottom' => [ | |
| 1389 | - 'title' => esc_html__( 'Bottom', 'elementor' ), | |
| 1390 | - 'icon' => 'eicon-v-align-bottom', | |
| 1391 | - ], | |
| 1392 | - ], | |
| 1393 | - 'conditions' => $transform_origin_conditions, | |
| 1394 | - 'selectors' => [ | |
| 1395 | - '{{WRAPPER}}' => '--e-' . $transform_css_modifier . 'transform-origin-y: {{VALUE}}', | |
| 1396 | - ], | |
| 1397 | - ] | |
| 1398 | - ); | |
| 1399 | - | |
| 1400 | - $this->end_controls_section(); | |
| 1401 | - } | |
| 1402 | - | |
| 1403 | - /** | |
| 1404 | - * Add Hidden Device Controls | |
| 1405 | - * | |
| 1406 | - * Adds controls for hiding elements within certain devices' viewport widths. Adds a control for each active device. | |
| 1407 | - * | |
| 1408 | - * @since 3.4.0 | |
| 1409 | - * @access protected | |
| 1410 | - */ | |
| 1411 | - protected function add_hidden_device_controls() { | |
| 1412 | - // The 'Hide On X' controls are displayed from largest to smallest, while the method returns smallest to largest. | |
| 1413 | - $active_devices = Plugin::$instance->breakpoints->get_active_devices_list( [ 'reverse' => true ] ); | |
| 1414 | - $active_breakpoints = Plugin::$instance->breakpoints->get_active_breakpoints(); | |
| 1415 | - | |
| 1416 | - foreach ( $active_devices as $breakpoint_key ) { | |
| 1417 | - $label = 'desktop' === $breakpoint_key ? esc_html__( 'Desktop', 'elementor' ) : $active_breakpoints[ $breakpoint_key ]->get_label(); | |
| 1418 | - | |
| 1419 | - $this->add_control( | |
| 1420 | - 'hide_' . $breakpoint_key, | |
| 1421 | - [ | |
| 1422 | - 'label' => sprintf( | |
| 1423 | - /* translators: %s: Device name. */ | |
| 1424 | - esc_html__( 'Hide On %s', 'elementor' ), | |
| 1425 | - $label | |
| 1426 | - ), | |
| 1427 | - 'type' => Controls_Manager::SWITCHER, | |
| 1428 | - 'default' => '', | |
| 1429 | - 'prefix_class' => 'elementor-', | |
| 1430 | - 'label_on' => esc_html__( 'Hide', 'elementor' ), | |
| 1431 | - 'label_off' => esc_html__( 'Show', 'elementor' ), | |
| 1432 | - 'return_value' => 'hidden-' . $breakpoint_key, | |
| 1433 | - ] | |
| 1434 | - ); | |
| 1435 | - } | |
| 1436 | - } | |
| 1437 | - | |
| 1438 | - /** | |
| 1439 | 867 | * Get default data. |
| 1440 | 868 | * |
| 1441 | 869 | * Retrieve the default element data. Used to reset the data on initialization. |
| 1442 | 870 | * |
| @@ -1462,12 +890,11 @@ | ||
| 1462 | 890 | * Output the element final HTML on the frontend. |
| 1463 | 891 | * |
| 1464 | 892 | * @since 1.0.0 |
| 1465 | 893 | * @access protected |
| 1466 | - * @deprecated 3.1.0 Use `print_content()` method instead. | |
| 1467 | 894 | */ |
| 1468 | 895 | protected function _print_content() { |
| 1469 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0', 'print_content()' ); | |
| 896 | + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0', __CLASS__ . '::print_content()' ); | |
| 1470 | 897 | |
| 1471 | 898 | $this->print_content(); |
| 1472 | 899 | } |
| 1473 | 900 | |
| @@ -1520,19 +947,8 @@ | ||
| 1520 | 947 | return $config; |
| 1521 | 948 | } |
| 1522 | 949 | |
| 1523 | 950 | /** |
| 1524 | - * A Base method for sanitizing the settings before save. | |
| 1525 | - * This method is meant to be overridden by the element. | |
| 1526 | - * | |
| 1527 | - * @param array $settings | |
| 1528 | - * @return array | |
| 1529 | - */ | |
| 1530 | - protected function on_save( array $settings ) { | |
| 1531 | - return $settings; | |
| 1532 | - } | |
| 1533 | - | |
| 1534 | - /** | |
| 1535 | 951 | * Get child type. |
| 1536 | 952 | * |
| 1537 | 953 | * Retrieve the element child type based on element data. |
| 1538 | 954 | * |
| @@ -1545,9 +961,9 @@ | ||
| 1545 | 961 | */ |
| 1546 | 962 | private function get_child_type( $element_data ) { |
| 1547 | 963 | $child_type = $this->_get_default_child_type( $element_data ); |
| 1548 | 964 | |
| 1549 | - // If it's not a valid widget ( like a deactivated plugin ). | |
| 965 | + // If it's not a valid widget ( like a deactivated plugin ) | |
| 1550 | 966 | if ( ! $child_type ) { |
| 1551 | 967 | return false; |
| 1552 | 968 | } |
| 1553 | 969 | |
| @@ -1592,12 +1008,8 @@ | ||
| 1592 | 1008 | $this->add_child( $child_data ); |
| 1593 | 1009 | } |
| 1594 | 1010 | } |
| 1595 | 1011 | |
| 1596 | - public function has_widget_inner_wrapper(): bool { | |
| 1597 | - return true; | |
| 1598 | - } | |
| 1599 | - | |
| 1600 | 1012 | /** |
| 1601 | 1013 | * Element base constructor. |
| 1602 | 1014 | * |
| 1603 | 1015 | * Initializing the element base class using `$data` and `$args`. |
| @@ -1610,9 +1022,9 @@ | ||
| 1610 | 1022 | * |
| 1611 | 1023 | * @param array $data Optional. Element data. Default is an empty array. |
| 1612 | 1024 | * @param array|null $args Optional. Element default arguments. Default is null. |
| 1613 | 1025 | **/ |
| 1614 | - public function __construct( array $data = [], ?array $args = null ) { | |
| 1026 | + public function __construct( array $data = [], array $args = null ) { | |
| 1615 | 1027 | if ( $data ) { |
| 1616 | 1028 | $this->is_type_instance = false; |
| 1617 | 1029 | } elseif ( $args ) { |
| 1618 | 1030 | $this->default_args = $args; |