| @@ -6,9 +6,8 @@ | ||
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | use Elementor\Core\Kits\Documents\Tabs\Global_Colors; |
| 9 | 9 | use Elementor\Core\Kits\Documents\Tabs\Global_Typography; |
| 10 | -use Elementor\Modules\Promotions\Controls\Promotion_Control; | |
| 11 | 10 | |
| 12 | 11 | /** |
| 13 | 12 | * Elementor testimonial widget. |
| 14 | 13 | * |
| @@ -73,48 +72,12 @@ | ||
| 73 | 72 | public function get_keywords() { |
| 74 | 73 | return [ 'testimonial', 'blockquote' ]; |
| 75 | 74 | } |
| 76 | 75 | |
| 77 | - protected function is_dynamic_content(): bool { | |
| 78 | - return false; | |
| 79 | - } | |
| 80 | - | |
| 81 | - /** | |
| 82 | - * Get style dependencies. | |
| 83 | - * | |
| 84 | - * Retrieve the list of style dependencies the widget requires. | |
| 85 | - * | |
| 86 | - * @since 3.24.0 | |
| 87 | - * @access public | |
| 88 | - * | |
| 89 | - * @return array Widget style dependencies. | |
| 90 | - */ | |
| 91 | - public function get_style_depends(): array { | |
| 92 | - return [ 'widget-testimonial' ]; | |
| 93 | - } | |
| 94 | - | |
| 95 | - public function has_widget_inner_wrapper(): bool { | |
| 96 | - return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); | |
| 97 | - } | |
| 98 | - | |
| 99 | - /** | |
| 100 | - * Get widget upsale data. | |
| 101 | - * | |
| 102 | - * Retrieve the widget promotion data. | |
| 103 | - * | |
| 104 | - * @since 3.18.0 | |
| 105 | - * @access protected | |
| 106 | - * | |
| 107 | - * @return array Widget promotion data. | |
| 108 | - */ | |
| 109 | 76 | protected function get_upsale_data() { |
| 110 | 77 | return [ |
| 111 | - 'condition' => ! Utils::has_pro(), | |
| 112 | - 'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ), | |
| 113 | - 'image_alt' => esc_attr__( 'Upgrade', 'elementor' ), | |
| 114 | 78 | 'description' => esc_html__( 'Use interesting masonry layouts and other overlay features with Elementor\'s Pro Gallery widget.', 'elementor' ), |
| 115 | - 'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-testimonial-widget/' ), | |
| 116 | - 'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ), | |
| 79 | + 'upgrade_url' => 'https://go.elementor.com/go-pro-testimonial-widget/', | |
| 117 | 80 | ]; |
| 118 | 81 | } |
| 119 | 82 | |
| 120 | 83 | /** |
| @@ -164,8 +127,9 @@ | ||
| 164 | 127 | Group_Control_Image_Size::get_type(), |
| 165 | 128 | [ |
| 166 | 129 | 'name' => 'testimonial_image', // Usage: `{name}_size` and `{name}_custom_dimension`, in this case `testimonial_image_size` and `testimonial_image_custom_dimension`. |
| 167 | 130 | 'default' => 'full', |
| 131 | + 'separator' => 'none', | |
| 168 | 132 | ] |
| 169 | 133 | ); |
| 170 | 134 | |
| 171 | 135 | $this->add_control( |
| @@ -175,12 +139,9 @@ | ||
| 175 | 139 | 'type' => Controls_Manager::TEXT, |
| 176 | 140 | 'dynamic' => [ |
| 177 | 141 | 'active' => true, |
| 178 | 142 | ], |
| 179 | - 'ai' => [ | |
| 180 | - 'active' => false, | |
| 181 | - ], | |
| 182 | - 'default' => esc_html__( 'John Doe', 'elementor' ), | |
| 143 | + 'default' => 'John Doe', | |
| 183 | 144 | ] |
| 184 | 145 | ); |
| 185 | 146 | |
| 186 | 147 | $this->add_control( |
| @@ -190,12 +151,9 @@ | ||
| 190 | 151 | 'type' => Controls_Manager::TEXT, |
| 191 | 152 | 'dynamic' => [ |
| 192 | 153 | 'active' => true, |
| 193 | 154 | ], |
| 194 | - 'ai' => [ | |
| 195 | - 'active' => false, | |
| 196 | - ], | |
| 197 | - 'default' => esc_html__( 'Designer', 'elementor' ), | |
| 155 | + 'default' => 'Designer', | |
| 198 | 156 | ] |
| 199 | 157 | ); |
| 200 | 158 | |
| 201 | 159 | $this->add_control( |
| @@ -212,26 +170,18 @@ | ||
| 212 | 170 | $this->add_control( |
| 213 | 171 | 'testimonial_image_position', |
| 214 | 172 | [ |
| 215 | 173 | 'label' => esc_html__( 'Image Position', 'elementor' ), |
| 216 | - 'type' => Controls_Manager::CHOOSE, | |
| 174 | + 'type' => Controls_Manager::SELECT, | |
| 217 | 175 | 'default' => 'aside', |
| 218 | 176 | 'options' => [ |
| 219 | - 'aside' => [ | |
| 220 | - 'title' => esc_html__( 'Aside', 'elementor' ), | |
| 221 | - 'icon' => 'eicon-h-align-left', | |
| 222 | - ], | |
| 223 | - 'top' => [ | |
| 224 | - 'title' => esc_html__( 'Top', 'elementor' ), | |
| 225 | - 'icon' => 'eicon-v-align-top', | |
| 226 | - ], | |
| 177 | + 'aside' => esc_html__( 'Aside', 'elementor' ), | |
| 178 | + 'top' => esc_html__( 'Top', 'elementor' ), | |
| 227 | 179 | ], |
| 228 | - 'toggle' => false, | |
| 229 | 180 | 'condition' => [ |
| 230 | 181 | 'testimonial_image[url]!' => '', |
| 231 | 182 | ], |
| 232 | 183 | 'separator' => 'before', |
| 233 | - 'classes' => 'elementor-control-start-end', | |
| 234 | 184 | 'style_transfer' => true, |
| 235 | 185 | ] |
| 236 | 186 | ); |
| 237 | 187 | |
| @@ -241,10 +191,10 @@ | ||
| 241 | 191 | 'label' => esc_html__( 'Alignment', 'elementor' ), |
| 242 | 192 | 'type' => Controls_Manager::CHOOSE, |
| 243 | 193 | 'default' => 'center', |
| 244 | 194 | 'options' => [ |
| 245 | - 'start' => [ | |
| 246 | - 'title' => esc_html__( 'Start', 'elementor' ), | |
| 195 | + 'left' => [ | |
| 196 | + 'title' => esc_html__( 'Left', 'elementor' ), | |
| 247 | 197 | 'icon' => 'eicon-text-align-left', |
| 248 | 198 | ], |
| 249 | 199 | 'center' => [ |
| 250 | 200 | 'title' => esc_html__( 'Center', 'elementor' ), |
| @@ -249,18 +199,13 @@ | ||
| 249 | 199 | 'center' => [ |
| 250 | 200 | 'title' => esc_html__( 'Center', 'elementor' ), |
| 251 | 201 | 'icon' => 'eicon-text-align-center', |
| 252 | 202 | ], |
| 253 | - 'end' => [ | |
| 254 | - 'title' => esc_html__( 'End', 'elementor' ), | |
| 203 | + 'right' => [ | |
| 204 | + 'title' => esc_html__( 'Right', 'elementor' ), | |
| 255 | 205 | 'icon' => 'eicon-text-align-right', |
| 256 | 206 | ], |
| 257 | 207 | ], |
| 258 | - 'classes' => 'elementor-control-start-end', | |
| 259 | - 'selectors_dictionary' => [ | |
| 260 | - 'left' => is_rtl() ? 'end' : 'start', | |
| 261 | - 'right' => is_rtl() ? 'start' : 'end', | |
| 262 | - ], | |
| 263 | 208 | 'selectors' => [ |
| 264 | 209 | '{{WRAPPER}} .elementor-testimonial-wrapper' => 'text-align: {{VALUE}}', |
| 265 | 210 | ], |
| 266 | 211 | 'style_transfer' => true, |
| @@ -266,8 +211,17 @@ | ||
| 266 | 211 | 'style_transfer' => true, |
| 267 | 212 | ] |
| 268 | 213 | ); |
| 269 | 214 | |
| 215 | + $this->add_control( | |
| 216 | + 'view', | |
| 217 | + [ | |
| 218 | + 'label' => esc_html__( 'View', 'elementor' ), | |
| 219 | + 'type' => Controls_Manager::HIDDEN, | |
| 220 | + 'default' => 'traditional', | |
| 221 | + ] | |
| 222 | + ); | |
| 223 | + | |
| 270 | 224 | $this->end_controls_section(); |
| 271 | 225 | |
| 272 | 226 | // Content. |
| 273 | 227 | $this->start_controls_section( |
| @@ -325,9 +279,9 @@ | ||
| 325 | 279 | ], |
| 326 | 280 | ] |
| 327 | 281 | ); |
| 328 | 282 | |
| 329 | - $this->add_responsive_control( | |
| 283 | + $this->add_control( | |
| 330 | 284 | 'image_size', |
| 331 | 285 | [ |
| 332 | 286 | 'label' => esc_html__( 'Image Resolution', 'elementor' ), |
| 333 | 287 | 'type' => Controls_Manager::SLIDER, |
| @@ -468,17 +422,8 @@ | ||
| 468 | 422 | */ |
| 469 | 423 | protected function render() { |
| 470 | 424 | $settings = $this->get_settings_for_display(); |
| 471 | 425 | |
| 472 | - $has_content = ! empty( $settings['testimonial_content'] ); | |
| 473 | - $has_image = ! empty( $settings['testimonial_image']['url'] ); | |
| 474 | - $has_name = ! empty( $settings['testimonial_name'] ); | |
| 475 | - $has_job = ! empty( $settings['testimonial_job'] ); | |
| 476 | - | |
| 477 | - if ( ! $has_content && ! $has_image && ! $has_name && ! $has_job ) { | |
| 478 | - return; | |
| 479 | - } | |
| 480 | - | |
| 481 | 426 | $this->add_render_attribute( 'wrapper', 'class', 'elementor-testimonial-wrapper' ); |
| 482 | 427 | |
| 483 | 428 | $this->add_render_attribute( 'meta', 'class', 'elementor-testimonial-meta' ); |
| 484 | 429 | |
| @@ -489,8 +434,17 @@ | ||
| 489 | 434 | if ( $settings['testimonial_image_position'] ) { |
| 490 | 435 | $this->add_render_attribute( 'meta', 'class', 'elementor-testimonial-image-position-' . $settings['testimonial_image_position'] ); |
| 491 | 436 | } |
| 492 | 437 | |
| 438 | + $has_content = ! ! $settings['testimonial_content']; | |
| 439 | + $has_image = ! ! $settings['testimonial_image']['url']; | |
| 440 | + $has_name = ! ! $settings['testimonial_name']; | |
| 441 | + $has_job = ! ! $settings['testimonial_job']; | |
| 442 | + | |
| 443 | + if ( ! $has_content && ! $has_image && ! $has_name && ! $has_job ) { | |
| 444 | + return; | |
| 445 | + } | |
| 446 | + | |
| 493 | 447 | if ( ! empty( $settings['link']['url'] ) ) { |
| 494 | 448 | $this->add_link_attributes( 'link', $settings['link'] ); |
| 495 | 449 | } |
| 496 | 450 | ?> |
| @@ -499,9 +453,9 @@ | ||
| 499 | 453 | if ( $has_content ) : |
| 500 | 454 | $this->add_render_attribute( 'testimonial_content', 'class', 'elementor-testimonial-content' ); |
| 501 | 455 | $this->add_inline_editing_attributes( 'testimonial_content' ); |
| 502 | 456 | ?> |
| 503 | - <div <?php $this->print_render_attribute_string( 'testimonial_content' ); ?>><?php echo wp_kses_post( $settings['testimonial_content'] ); ?></div> | |
| 457 | + <div <?php $this->print_render_attribute_string( 'testimonial_content' ); ?>><?php $this->print_unescaped_setting( 'testimonial_content' ); ?></div> | |
| 504 | 458 | <?php endif; ?> |
| 505 | 459 | |
| 506 | 460 | <?php if ( $has_image || $has_name || $has_job ) : ?> |
| 507 | 461 | <div <?php $this->print_render_attribute_string( 'meta' ); ?>> |
| @@ -526,13 +480,13 @@ | ||
| 526 | 480 | $this->add_inline_editing_attributes( 'testimonial_name', 'none' ); |
| 527 | 481 | |
| 528 | 482 | if ( ! empty( $settings['link']['url'] ) ) : |
| 529 | 483 | ?> |
| 530 | - <a <?php $this->print_render_attribute_string( 'testimonial_name' ); ?> <?php $this->print_render_attribute_string( 'link' ); ?>><?php echo wp_kses_post( $settings['testimonial_name'] ); ?></a> | |
| 484 | + <a <?php $this->print_render_attribute_string( 'testimonial_name' ); ?> <?php $this->print_render_attribute_string( 'link' ); ?>><?php $this->print_unescaped_setting( 'testimonial_name' ); ?></a> | |
| 531 | 485 | <?php |
| 532 | 486 | else : |
| 533 | 487 | ?> |
| 534 | - <div <?php $this->print_render_attribute_string( 'testimonial_name' ); ?>><?php echo wp_kses_post( $settings['testimonial_name'] ); ?></div> | |
| 488 | + <div <?php $this->print_render_attribute_string( 'testimonial_name' ); ?>><?php $this->print_unescaped_setting( 'testimonial_name' ); ?></div> | |
| 535 | 489 | <?php |
| 536 | 490 | endif; |
| 537 | 491 | endif; ?> |
| 538 | 492 | <?php |
| @@ -542,13 +496,13 @@ | ||
| 542 | 496 | $this->add_inline_editing_attributes( 'testimonial_job', 'none' ); |
| 543 | 497 | |
| 544 | 498 | if ( ! empty( $settings['link']['url'] ) ) : |
| 545 | 499 | ?> |
| 546 | - <a <?php $this->print_render_attribute_string( 'testimonial_job' ); ?> <?php $this->print_render_attribute_string( 'link' ); ?>><?php echo wp_kses_post( $settings['testimonial_job'] ); ?></a> | |
| 500 | + <a <?php $this->print_render_attribute_string( 'testimonial_job' ); ?> <?php $this->print_render_attribute_string( 'link' ); ?>><?php $this->print_unescaped_setting( 'testimonial_job' ); ?></a> | |
| 547 | 501 | <?php |
| 548 | 502 | else : |
| 549 | 503 | ?> |
| 550 | - <div <?php $this->print_render_attribute_string( 'testimonial_job' ); ?>><?php echo wp_kses_post( $settings['testimonial_job'] ); ?></div> | |
| 504 | + <div <?php $this->print_render_attribute_string( 'testimonial_job' ); ?>><?php $this->print_unescaped_setting( 'testimonial_job' ); ?></div> | |
| 551 | 505 | <?php |
| 552 | 506 | endif; |
| 553 | 507 | endif; ?> |
| 554 | 508 | </div> |
| @@ -570,12 +524,8 @@ | ||
| 570 | 524 | */ |
| 571 | 525 | protected function content_template() { |
| 572 | 526 | ?> |
| 573 | 527 | <# |
| 574 | - if ( '' === settings.testimonial_content && '' === settings.testimonial_image.url && '' === settings.testimonial_name && '' === settings.testimonial_job ) { | |
| 575 | - return; | |
| 576 | - } | |
| 577 | - | |
| 578 | 528 | var image = { |
| 579 | 529 | id: settings.testimonial_image.id, |
| 580 | 530 | url: settings.testimonial_image.url, |
| 581 | 531 | size: settings.testimonial_image_size, |
| @@ -588,10 +538,10 @@ | ||
| 588 | 538 | imageUrl = elementor.imagesManager.getImageUrl( image ); |
| 589 | 539 | hasImage = ' elementor-has-image'; |
| 590 | 540 | |
| 591 | 541 | var imageHtml = '<img src="' + _.escape( imageUrl ) + '" alt="testimonial" />'; |
| 592 | - if ( settings.link?.url ) { | |
| 593 | - imageHtml = '<a href="' + elementor.helpers.sanitizeUrl( settings.link?.url ) + '">' + imageHtml + '</a>'; | |
| 542 | + if ( settings.link.url ) { | |
| 543 | + imageHtml = '<a href="' + _.escape( settings.link.url ) + '">' + imageHtml + '</a>'; | |
| 594 | 544 | } |
| 595 | 545 | } |
| 596 | 546 | |
| 597 | 547 | var testimonial_image_position = settings.testimonial_image_position ? ' elementor-testimonial-image-position-' + settings.testimonial_image_position : ''; |
| @@ -600,19 +550,14 @@ | ||
| 600 | 550 | <# if ( '' !== settings.testimonial_content ) { |
| 601 | 551 | view.addRenderAttribute( 'testimonial_content', { |
| 602 | 552 | 'data-binding-type': 'content', |
| 603 | 553 | 'data-binding-setting': 'testimonial_content', |
| 604 | - 'data-binding-config': JSON.stringify({ | |
| 605 | - 'testimonial_content': { | |
| 606 | - editType: "text" | |
| 607 | - } | |
| 608 | - }) | |
| 609 | 554 | } ); |
| 610 | 555 | view.addRenderAttribute( 'testimonial_content', 'class', 'elementor-testimonial-content' ); |
| 611 | 556 | |
| 612 | 557 | view.addInlineEditingAttributes( 'testimonial_content' ); |
| 613 | 558 | #> |
| 614 | - <div {{{ view.getRenderAttributeString( 'testimonial_content' ) }}}>{{ settings.testimonial_content }}</div> | |
| 559 | + <div {{{ view.getRenderAttributeString( 'testimonial_content' ) }}}>{{{ settings.testimonial_content }}}</div> | |
| 615 | 560 | <# } #> |
| 616 | 561 | <div class="elementor-testimonial-meta{{ hasImage }}{{ testimonial_image_position }}"> |
| 617 | 562 | <div class="elementor-testimonial-meta-inner"> |
| 618 | 563 | <# if ( imageUrl ) { #> |
| @@ -634,15 +579,15 @@ | ||
| 634 | 579 | view.addRenderAttribute( 'testimonial_name', 'class', 'elementor-testimonial-name' ); |
| 635 | 580 | |
| 636 | 581 | view.addInlineEditingAttributes( 'testimonial_name', 'none' ); |
| 637 | 582 | |
| 638 | - if ( settings.link?.url ) { | |
| 583 | + if ( settings.link.url ) { | |
| 639 | 584 | #> |
| 640 | - <a href="{{ elementor.helpers.sanitizeUrl( settings.link?.url ) }}" {{{ view.getRenderAttributeString( 'testimonial_name' ) }}}>{{ settings.testimonial_name }}</a> | |
| 585 | + <a href="{{ settings.link.url }}" {{{ view.getRenderAttributeString( 'testimonial_name' ) }}}>{{{ settings.testimonial_name }}}</a> | |
| 641 | 586 | <# |
| 642 | 587 | } else { |
| 643 | 588 | #> |
| 644 | - <div {{{ view.getRenderAttributeString( 'testimonial_name' ) }}}>{{ settings.testimonial_name }}</div> | |
| 589 | + <div {{{ view.getRenderAttributeString( 'testimonial_name' ) }}}>{{{ settings.testimonial_name }}}</div> | |
| 645 | 590 | <# |
| 646 | 591 | } |
| 647 | 592 | } |
| 648 | 593 | |
| @@ -650,15 +595,15 @@ | ||
| 650 | 595 | view.addRenderAttribute( 'testimonial_job', 'class', 'elementor-testimonial-job' ); |
| 651 | 596 | |
| 652 | 597 | view.addInlineEditingAttributes( 'testimonial_job', 'none' ); |
| 653 | 598 | |
| 654 | - if ( settings.link?.url ) { | |
| 599 | + if ( settings.link.url ) { | |
| 655 | 600 | #> |
| 656 | - <a href="{{ elementor.helpers.sanitizeUrl( settings.link?.url ) }}" {{{ view.getRenderAttributeString( 'testimonial_job' ) }}}>{{ settings.testimonial_job }}</a> | |
| 601 | + <a href="{{ settings.link.url }}" {{{ view.getRenderAttributeString( 'testimonial_job' ) }}}>{{{ settings.testimonial_job }}}</a> | |
| 657 | 602 | <# |
| 658 | 603 | } else { |
| 659 | 604 | #> |
| 660 | - <div {{{ view.getRenderAttributeString( 'testimonial_job' ) }}}>{{ settings.testimonial_job }}</div> | |
| 605 | + <div {{{ view.getRenderAttributeString( 'testimonial_job' ) }}}>{{{ settings.testimonial_job }}}</div> | |
| 661 | 606 | <# |
| 662 | 607 | } |
| 663 | 608 | } |
| 664 | 609 | #> |