2, 'tablet' => 2, 'mobile' => 1, ); } /** * Register controls. */ protected function register_controls() { $this->register_testimonials_section(); $this->register_layout_section(); $this->register_slider_options_section(); $this->register_navigation_section(); $this->register_card_style_section(); $this->register_quote_style_section(); $this->register_person_style_section(); $this->register_rating_style_section(); $this->register_arrows_style_section(); $this->register_pagination_style_section(); } /** * Testimonials repeater. */ private function register_testimonials_section() { $this->start_controls_section( 'aels_section_testimonials', array( 'label' => esc_html__( 'Testimonials', 'advance-elementor-slider' ), 'tab' => Controls_Manager::TAB_CONTENT, ) ); $repeater = new Repeater(); $repeater->add_control( 'content', array( 'label' => esc_html__( 'Testimonial', 'advance-elementor-slider' ), 'type' => Controls_Manager::TEXTAREA, 'dynamic' => array( 'active' => true ), 'rows' => 5, 'default' => esc_html__( 'The team delivered exactly what we asked for, on time and without any fuss. We would happily work with them again.', 'advance-elementor-slider' ), ) ); $repeater->add_control( 'avatar', array( 'label' => esc_html__( 'Photo', 'advance-elementor-slider' ), 'type' => Controls_Manager::MEDIA, 'dynamic' => array( 'active' => true ), 'default' => array( 'url' => Utils::get_placeholder_image_src() ), ) ); $repeater->add_control( 'name', array( 'label' => esc_html__( 'Name', 'advance-elementor-slider' ), 'type' => Controls_Manager::TEXT, 'dynamic' => array( 'active' => true ), 'label_block' => true, 'default' => esc_html__( 'Jane Cooper', 'advance-elementor-slider' ), ) ); $repeater->add_control( 'designation', array( 'label' => esc_html__( 'Role / Company', 'advance-elementor-slider' ), 'type' => Controls_Manager::TEXT, 'dynamic' => array( 'active' => true ), 'label_block' => true, 'default' => esc_html__( 'Marketing Lead, Acme Co.', 'advance-elementor-slider' ), ) ); $repeater->add_control( 'rating', array( 'label' => esc_html__( 'Rating', 'advance-elementor-slider' ), 'type' => Controls_Manager::SELECT, 'default' => '5', 'options' => array( '0' => esc_html__( 'No rating', 'advance-elementor-slider' ), '1' => esc_html__( '1 Star', 'advance-elementor-slider' ), '2' => esc_html__( '2 Stars', 'advance-elementor-slider' ), '3' => esc_html__( '3 Stars', 'advance-elementor-slider' ), '4' => esc_html__( '4 Stars', 'advance-elementor-slider' ), '5' => esc_html__( '5 Stars', 'advance-elementor-slider' ), ), ) ); $this->add_control( 'testimonials', array( 'label' => esc_html__( 'Testimonials', 'advance-elementor-slider' ), 'type' => Controls_Manager::REPEATER, 'fields' => $repeater->get_controls(), 'title_field' => '{{{ name || "Testimonial" }}}', 'default' => array( array( 'name' => esc_html__( 'Jane Cooper', 'advance-elementor-slider' ) ), array( 'name' => esc_html__( 'Devon Lane', 'advance-elementor-slider' ) ), array( 'name' => esc_html__( 'Arlene McCoy', 'advance-elementor-slider' ) ), ), ) ); $this->end_controls_section(); } /** * Layout options. */ private function register_layout_section() { $this->start_controls_section( 'aels_section_layout', array( 'label' => esc_html__( 'Layout', 'advance-elementor-slider' ), 'tab' => Controls_Manager::TAB_CONTENT, ) ); $this->add_control( 'layout', array( 'label' => esc_html__( 'Person Position', 'advance-elementor-slider' ), 'type' => Controls_Manager::SELECT, 'default' => 'bottom', 'options' => array( 'bottom' => esc_html__( 'Below The Quote', 'advance-elementor-slider' ), 'top' => esc_html__( 'Above The Quote', 'advance-elementor-slider' ), ), ) ); $this->add_control( 'show_avatar', array( 'label' => esc_html__( 'Show Photo', 'advance-elementor-slider' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', ) ); $this->add_control( 'show_quote_icon', array( 'label' => esc_html__( 'Show Quote Mark', 'advance-elementor-slider' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', ) ); $this->add_responsive_control( 'text_align', array( 'label' => esc_html__( 'Text Align', 'advance-elementor-slider' ), 'type' => Controls_Manager::CHOOSE, 'options' => array( 'left' => array( 'title' => esc_html__( 'Left', 'advance-elementor-slider' ), 'icon' => 'eicon-text-align-left', ), 'center' => array( 'title' => esc_html__( 'Center', 'advance-elementor-slider' ), 'icon' => 'eicon-text-align-center', ), 'right' => array( 'title' => esc_html__( 'Right', 'advance-elementor-slider' ), 'icon' => 'eicon-text-align-right', ), ), 'default' => 'left', 'selectors' => array( '{{WRAPPER}} .aels-testimonial' => 'text-align: {{VALUE}};', '{{WRAPPER}} .aels-testimonial__person' => 'justify-content: {{VALUE}};', '{{WRAPPER}} .aels-testimonial__rating' => 'justify-content: {{VALUE}};', ), ) ); $this->end_controls_section(); } /** * Card styling. */ private function register_card_style_section() { $this->start_controls_section( 'aels_style_card', array( 'label' => esc_html__( 'Card', 'advance-elementor-slider' ), 'tab' => Controls_Manager::TAB_STYLE, ) ); $this->add_control( 'card_bg', array( 'label' => esc_html__( 'Background', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'default' => '#f9fafb', 'selectors' => array( '{{WRAPPER}} .aels-testimonial' => 'background-color: {{VALUE}};', ), ) ); $this->add_responsive_control( 'card_padding', array( 'label' => esc_html__( 'Padding', 'advance-elementor-slider' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', 'em' ), 'default' => array( 'top' => 32, 'right' => 32, 'bottom' => 32, 'left' => 32, 'unit' => 'px', 'isLinked' => true, ), 'selectors' => array( '{{WRAPPER}} .aels-testimonial' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->add_control( 'card_radius', array( 'label' => esc_html__( 'Border Radius', 'advance-elementor-slider' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%' ), 'default' => array( 'top' => 12, 'right' => 12, 'bottom' => 12, 'left' => 12, 'unit' => 'px', 'isLinked' => true, ), 'selectors' => array( '{{WRAPPER}} .aels-testimonial' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), ) ); $this->add_group_control( Group_Control_Border::get_type(), array( 'name' => 'card_border', 'selector' => '{{WRAPPER}} .aels-testimonial', ) ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), array( 'name' => 'card_shadow', 'selector' => '{{WRAPPER}} .aels-testimonial', ) ); $this->add_control( 'equal_height', array( 'label' => esc_html__( 'Equal Card Height', 'advance-elementor-slider' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', 'separator' => 'before', 'prefix_class' => 'aels-equal-height-', 'return_value' => 'yes', ) ); $this->end_controls_section(); } /** * Quote text styling. */ private function register_quote_style_section() { $this->start_controls_section( 'aels_style_quote', array( 'label' => esc_html__( 'Quote', 'advance-elementor-slider' ), 'tab' => Controls_Manager::TAB_STYLE, ) ); $this->add_control( 'quote_color', array( 'label' => esc_html__( 'Text Color', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'default' => '#374151', 'selectors' => array( '{{WRAPPER}} .aels-testimonial__text' => 'color: {{VALUE}};', ), ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => 'quote_typography', 'selector' => '{{WRAPPER}} .aels-testimonial__text', ) ); $this->add_responsive_control( 'quote_spacing', array( 'label' => esc_html__( 'Spacing', 'advance-elementor-slider' ), 'type' => Controls_Manager::SLIDER, 'size_units' => array( 'px' ), 'range' => array( 'px' => array( 'min' => 0, 'max' => 80, ), ), 'default' => array( 'unit' => 'px', 'size' => 20, ), 'selectors' => array( '{{WRAPPER}} .aels-testimonial__text' => 'margin-bottom: {{SIZE}}{{UNIT}};', ), ) ); $this->add_control( 'quote_icon_color', array( 'label' => esc_html__( 'Quote Mark Color', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'default' => 'rgba(37, 99, 235, 0.18)', 'selectors' => array( '{{WRAPPER}} .aels-testimonial__quote-icon' => 'color: {{VALUE}};', ), 'condition' => array( 'show_quote_icon' => 'yes' ), ) ); $this->add_responsive_control( 'quote_icon_size', array( 'label' => esc_html__( 'Quote Mark Size', 'advance-elementor-slider' ), 'type' => Controls_Manager::SLIDER, 'size_units' => array( 'px' ), 'range' => array( 'px' => array( 'min' => 20, 'max' => 140, ), ), 'default' => array( 'unit' => 'px', 'size' => 56, ), 'selectors' => array( '{{WRAPPER}} .aels-testimonial__quote-icon' => 'font-size: {{SIZE}}{{UNIT}};', ), 'condition' => array( 'show_quote_icon' => 'yes' ), ) ); $this->end_controls_section(); } /** * Name, role and avatar styling. */ private function register_person_style_section() { $this->start_controls_section( 'aels_style_person', array( 'label' => esc_html__( 'Person', 'advance-elementor-slider' ), 'tab' => Controls_Manager::TAB_STYLE, ) ); $this->add_responsive_control( 'avatar_size', array( 'label' => esc_html__( 'Photo Size', 'advance-elementor-slider' ), 'type' => Controls_Manager::SLIDER, 'size_units' => array( 'px' ), 'range' => array( 'px' => array( 'min' => 24, 'max' => 140, ), ), 'default' => array( 'unit' => 'px', 'size' => 56, ), 'selectors' => array( '{{WRAPPER}} .aels-testimonial__avatar' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};', ), 'condition' => array( 'show_avatar' => 'yes' ), ) ); $this->add_control( 'avatar_radius', array( 'label' => esc_html__( 'Photo Radius', 'advance-elementor-slider' ), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => array( 'px', '%' ), 'default' => array( 'top' => 50, 'right' => 50, 'bottom' => 50, 'left' => 50, 'unit' => '%', 'isLinked' => true, ), 'selectors' => array( '{{WRAPPER}} .aels-testimonial__avatar' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ), 'condition' => array( 'show_avatar' => 'yes' ), ) ); $this->add_control( 'name_color', array( 'label' => esc_html__( 'Name Color', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'default' => '#111827', 'separator' => 'before', 'selectors' => array( '{{WRAPPER}} .aels-testimonial__name' => 'color: {{VALUE}};', ), ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => 'name_typography', 'selector' => '{{WRAPPER}} .aels-testimonial__name', ) ); $this->add_control( 'designation_color', array( 'label' => esc_html__( 'Role Color', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'default' => '#6b7280', 'separator' => 'before', 'selectors' => array( '{{WRAPPER}} .aels-testimonial__designation' => 'color: {{VALUE}};', ), ) ); $this->add_group_control( Group_Control_Typography::get_type(), array( 'name' => 'designation_typography', 'selector' => '{{WRAPPER}} .aels-testimonial__designation', ) ); $this->end_controls_section(); } /** * Star rating styling. */ private function register_rating_style_section() { $this->start_controls_section( 'aels_style_rating', array( 'label' => esc_html__( 'Rating', 'advance-elementor-slider' ), 'tab' => Controls_Manager::TAB_STYLE, ) ); $this->add_control( 'star_color', array( 'label' => esc_html__( 'Star Color', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'default' => '#f59e0b', 'selectors' => array( '{{WRAPPER}} .aels-star--on' => 'color: {{VALUE}};', ), ) ); $this->add_control( 'star_empty_color', array( 'label' => esc_html__( 'Empty Star Color', 'advance-elementor-slider' ), 'type' => Controls_Manager::COLOR, 'default' => '#d1d5db', 'selectors' => array( '{{WRAPPER}} .aels-star--off' => 'color: {{VALUE}};', ), ) ); $this->add_responsive_control( 'star_size', array( 'label' => esc_html__( 'Star Size', 'advance-elementor-slider' ), 'type' => Controls_Manager::SLIDER, 'size_units' => array( 'px' ), 'range' => array( 'px' => array( 'min' => 8, 'max' => 40, ), ), 'default' => array( 'unit' => 'px', 'size' => 16, ), 'selectors' => array( '{{WRAPPER}} .aels-testimonial__rating' => 'font-size: {{SIZE}}{{UNIT}};', ), ) ); $this->add_responsive_control( 'rating_spacing', array( 'label' => esc_html__( 'Spacing Below', 'advance-elementor-slider' ), 'type' => Controls_Manager::SLIDER, 'size_units' => array( 'px' ), 'range' => array( 'px' => array( 'min' => 0, 'max' => 60, ), ), 'default' => array( 'unit' => 'px', 'size' => 14, ), 'selectors' => array( '{{WRAPPER}} .aels-testimonial__rating' => 'margin-bottom: {{SIZE}}{{UNIT}};', ), ) ); $this->end_controls_section(); } /** * Render the widget. */ protected function render() { $settings = $this->get_settings_for_display(); if ( empty( $settings['testimonials'] ) || ! is_array( $settings['testimonials'] ) ) { $this->render_empty_notice( esc_html__( 'Add at least one testimonial.', 'advance-elementor-slider' ) ); return; } $this->render_slider_start( $settings, array( 'aels-slider--testimonials' ) ); foreach ( $settings['testimonials'] as $index => $item ) { $this->render_testimonial( $item, $index, $settings ); } $this->render_slider_end( $settings ); } /** * Render one testimonial card. * * @param array $item Repeater item. * @param int $index Index. * @param array $settings Widget settings. */ private function render_testimonial( array $item, $index, array $settings ) { $slide_key = 'testimonial_' . $index; $slide_classes = array( 'swiper-slide', 'aels-slide', 'aels-slide--card' ); if ( ! empty( $item['_id'] ) ) { $slide_classes[] = 'elementor-repeater-item-' . $item['_id']; } $this->add_render_attribute( $slide_key, array( 'class' => $slide_classes ) ); $person_first = isset( $settings['layout'] ) && 'top' === $settings['layout']; ?>
print_render_attribute_string( $slide_key ); ?>>
render_person( $item, $settings ); ?> render_rating( $item ); ?>
is_on( $settings, 'show_quote_icon' ) ) : ?>
render_person( $item, $settings ); ?>
is_on( $settings, 'show_avatar' ) && ! empty( $item['avatar']['url'] ); if ( ! $has_name && ! $has_role && ! $has_avatar ) { return; } ?>
<?php echo esc_attr( $has_name ? $item['name'] : '' ); ?>