if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use Elementor\Modules\Promotions\Controls\Promotion_Control;
* Elementor testimonial widget.
* Elementor widget that displays customer testimonials that show social proof.
class Widget_Testimonial extends Widget_Base {
* Retrieve testimonial widget name.
* @return string Widget name.
public function get_name() {
* Retrieve testimonial widget title.
* @return string Widget title.
public function get_title() {
return esc_html__( 'Testimonial', 'elementor' );
* Retrieve testimonial widget icon.
* @return string Widget icon.
public function get_icon() {
return 'eicon-testimonial';
* Retrieve the list of keywords the widget belongs to.
* @return array Widget keywords.
public function get_keywords() {
return [ 'testimonial', 'blockquote' ];
protected function is_dynamic_content(): bool {
* Get style dependencies.
* Retrieve the list of style dependencies the widget requires.
* @return array Widget style dependencies.
public function get_style_depends(): array {
return [ 'widget-testimonial' ];
public function has_widget_inner_wrapper(): bool {
return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
* Get widget upsale data.
* Retrieve the widget promotion data.
* @return array Widget promotion data.
protected function get_upsale_data() {
'condition' => ! Utils::has_pro(),
'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ),
'image_alt' => esc_attr__( 'Upgrade', 'elementor' ),
'description' => esc_html__( 'Use interesting masonry layouts and other overlay features with Elementor\'s Pro Gallery widget.', 'elementor' ),
'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-testimonial-widget/' ),
'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ),
* Register testimonial widget controls.
* Adds different input fields to allow the user to change and customize the widget settings.
protected function register_controls() {
$this->start_controls_section(
'label' => esc_html__( 'Testimonial', 'elementor' ),
'label' => esc_html__( 'Content', 'elementor' ),
'type' => Controls_Manager::TEXTAREA,
'default' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.', 'elementor' ),
'label' => esc_html__( 'Choose Image', 'elementor' ),
'type' => Controls_Manager::MEDIA,
'url' => Utils::get_placeholder_image_src(),
$this->add_group_control(
Group_Control_Image_Size::get_type(),
'name' => 'testimonial_image', // Usage: `{name}_size` and `{name}_custom_dimension`, in this case `testimonial_image_size` and `testimonial_image_custom_dimension`.
'label' => esc_html__( 'Name', 'elementor' ),
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'John Doe', 'elementor' ),
'label' => esc_html__( 'Title', 'elementor' ),
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Designer', 'elementor' ),
'label' => esc_html__( 'Link', 'elementor' ),
'type' => Controls_Manager::URL,
'testimonial_image_position',
'label' => esc_html__( 'Image Position', 'elementor' ),
'type' => Controls_Manager::CHOOSE,
'title' => esc_html__( 'Aside', 'elementor' ),
'icon' => 'eicon-h-align-left',
'title' => esc_html__( 'Top', 'elementor' ),
'icon' => 'eicon-v-align-top',
'testimonial_image[url]!' => '',
'classes' => 'elementor-control-start-end',
'style_transfer' => true,
$this->add_responsive_control(
'label' => esc_html__( 'Alignment', 'elementor' ),
'type' => Controls_Manager::CHOOSE,
'title' => esc_html__( 'Start', 'elementor' ),
'icon' => 'eicon-text-align-left',
'title' => esc_html__( 'Center', 'elementor' ),
'icon' => 'eicon-text-align-center',
'title' => esc_html__( 'End', 'elementor' ),
'icon' => 'eicon-text-align-right',
'classes' => 'elementor-control-start-end',
'selectors_dictionary' => [
'left' => is_rtl() ? 'end' : 'start',
'right' => is_rtl() ? 'start' : 'end',
'{{WRAPPER}} .elementor-testimonial-wrapper' => 'text-align: {{VALUE}}',
'style_transfer' => true,
$this->end_controls_section();
$this->start_controls_section(
'section_style_testimonial_content',
'label' => esc_html__( 'Content', 'elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
'label' => esc_html__( 'Text Color', 'elementor' ),
'type' => Controls_Manager::COLOR,
'default' => Global_Colors::COLOR_TEXT,
'{{WRAPPER}} .elementor-testimonial-content' => 'color: {{VALUE}};',
$this->add_group_control(
Group_Control_Typography::get_type(),
'name' => 'content_typography',
'default' => Global_Typography::TYPOGRAPHY_TEXT,
'selector' => '{{WRAPPER}} .elementor-testimonial-content',
$this->add_group_control(
Group_Control_Text_Shadow::get_type(),
'name' => 'content_shadow',
'selector' => '{{WRAPPER}} .elementor-testimonial-content',
$this->end_controls_section();
$this->start_controls_section(
'section_style_testimonial_image',
'label' => esc_html__( 'Image', 'elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
'testimonial_image[url]!' => '',
$this->add_responsive_control(
'label' => esc_html__( 'Image Resolution', 'elementor' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
'{{WRAPPER}} .elementor-testimonial-wrapper .elementor-testimonial-image img' => 'width: {{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}};',
$this->add_group_control(
Group_Control_Border::get_type(),
'name' => 'image_border',
'selector' => '{{WRAPPER}} .elementor-testimonial-wrapper .elementor-testimonial-image img',
$this->add_responsive_control(
'label' => esc_html__( 'Border Radius', 'elementor' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
'{{WRAPPER}} .elementor-testimonial-wrapper .elementor-testimonial-image img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
$this->end_controls_section();
$this->start_controls_section(
'section_style_testimonial_name',
'label' => esc_html__( 'Name', 'elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
'label' => esc_html__( 'Text Color', 'elementor' ),
'type' => Controls_Manager::COLOR,
'default' => Global_Colors::COLOR_PRIMARY,
'{{WRAPPER}} .elementor-testimonial-name' => 'color: {{VALUE}};',
$this->add_group_control(
Group_Control_Typography::get_type(),
'name' => 'name_typography',
'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
'selector' => '{{WRAPPER}} .elementor-testimonial-name',
$this->add_group_control(
Group_Control_Text_Shadow::get_type(),
'selector' => '{{WRAPPER}} .elementor-testimonial-name',
$this->end_controls_section();
$this->start_controls_section(
'section_style_testimonial_job',
'label' => esc_html__( 'Title', 'elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
'label' => esc_html__( 'Text Color', 'elementor' ),
'type' => Controls_Manager::COLOR,
'default' => Global_Colors::COLOR_SECONDARY,
'{{WRAPPER}} .elementor-testimonial-job' => 'color: {{VALUE}};',
$this->add_group_control(
Group_Control_Typography::get_type(),
'name' => 'job_typography',
'default' => Global_Typography::TYPOGRAPHY_SECONDARY,
'selector' => '{{WRAPPER}} .elementor-testimonial-job',
$this->add_group_control(
Group_Control_Text_Shadow::get_type(),
'selector' => '{{WRAPPER}} .elementor-testimonial-job',
$this->end_controls_section();
* Render testimonial widget output on the frontend.
* Written in PHP and used to generate the final HTML.
protected function render() {
$settings = $this->get_settings_for_display();
$has_content = ! empty( $settings['testimonial_content'] );
$has_image = ! empty( $settings['testimonial_image']['url'] );
$has_name = ! empty( $settings['testimonial_name'] );
$has_job = ! empty( $settings['testimonial_job'] );
if ( ! $has_content && ! $has_image && ! $has_name && ! $has_job ) {
$this->add_render_attribute( 'wrapper', 'class', 'elementor-testimonial-wrapper' );
$this->add_render_attribute( 'meta', 'class', 'elementor-testimonial-meta' );
if ( $settings['testimonial_image']['url'] ) {
$this->add_render_attribute( 'meta', 'class', 'elementor-has-image' );
if ( $settings['testimonial_image_position'] ) {
$this->add_render_attribute( 'meta', 'class', 'elementor-testimonial-image-position-' . $settings['testimonial_image_position'] );
if ( ! empty( $settings['link']['url'] ) ) {
$this->add_link_attributes( 'link', $settings['link'] );
<div <?php $this->print_render_attribute_string( 'wrapper' ); ?>>
$this->add_render_attribute( 'testimonial_content', 'class', 'elementor-testimonial-content' );