<?php
/**
* Feedback Two Widget
*/
namespace Elementor;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Cyarb_Testimonial_Two extends Widget_Base {
public function get_name() {
return 'Cyarb_Feedback_Two';
}
public function get_title() {
return __( 'Feedback Two', 'cyarb-toolkit' );
}
public function get_icon() {
return 'eicon-testimonial';
}
public function get_categories() {
return [ 'cyarb-elements' ];
}
protected function register_controls() {
$this->start_controls_section(
'content_section',
[
'label' => __( 'Content', 'cyarb-toolkit' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'qi_image', [
'label' => __( 'Quote Image', 'cyarb-toolkit' ),
'type' => Controls_Manager::MEDIA,
]
);
$repeater = new Repeater();
$repeater->add_control(
'feedback', [
'label' => esc_html__('Feedback Content', 'cyarb-toolkit'),
'type' => Controls_Manager:: WYSIWYG,
'label_block' => true,
]
);
$repeater->add_control(
'image', [
'label' => __( 'Image', 'cyarb-toolkit' ),
'type' => Controls_Manager::MEDIA,
]
);
$repeater->add_control(
'name', [
'label' => esc_html__('Name', 'cyarb-toolkit'),
'type' => Controls_Manager::TEXT,
'label_block' => true,
]
);
$repeater->add_control(
'designation', [
'label' => esc_html__('Designation', 'cyarb-toolkit'),
'type' => Controls_Manager::TEXT,
'label_block' => true,
]
);
$repeater->add_control(
'star_count',
[
'label' => __( 'Choose Star', 'cyarb-toolkit' ),
'type' => Controls_Manager::SELECT,
'label_block' => true,
'options' => [
'1' => __( '1', 'cyarb-toolkit' ),
'2' => __( '2', 'cyarb-toolkit' ),
'3' => __( '3', 'cyarb-toolkit' ),
'4' => __( '4', 'cyarb-toolkit' ),
'5' => __( '5', 'cyarb-toolkit' ),
],
'default' => '5',
]
);
$repeater->add_control(
'icon_class',
[
'label' => __( 'Add Star Icon Class', 'cyarb-toolkit' ),
'type' => Controls_Manager::TEXT,
]
);
$this->add_control(
'cyarb_feedback_items',
[
'label' => __('Add Feedback Item', 'cyarb-toolkit'),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
]
);
$this->end_controls_section();
$this->start_controls_section(
'style',
[
'label' => __( 'Style', 'cyarb-toolkit' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'feedback_color',
[
'label' => __( 'Feedback Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-testimonials-card p' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'feedback_type_typography',
'label' => __( 'Feedback Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-testimonials-card p',
]
);
$this->add_control(
'name_color',
[
'label' => __( 'Name Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-testimonials-card .client-info .title h3' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'name_type_typography',
'label' => __( 'Name Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-testimonials-card .client-info .title h3',
]
);
$this->add_control(
'designation_color',
[
'label' => __( 'Designation Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-testimonials-card .client-info .title h3 span' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'designation_type_typography',
'label' => __( 'Designation Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-testimonials-card .client-info .title h3 span',
]
);
$this->add_control(
'icon_color',
[
'label' => __( 'Icon Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-testimonials-card .client-info .title .rating' => 'color: {{VALUE}}',
],
]
);
$this->add_control(
'inner_divi',
[
'type' => Controls_Manager::DIVIDER,
]
);
$this->add_control(
'sec_bghead',
[
'label' => esc_html__( 'Section Background', 'cyarb-toolkit' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'secbg_color',
'types' => ['gradient' ],
'selector' => '{{WRAPPER}} .single-testimonials-card',
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
$slider = $settings['cyarb_feedback_items'];
?>
<div class="testimonials-area ">
<div class="container">
<div class="testimonials-slides owl-carousel owl-theme">
<?php foreach ($slider as $key => $value): ?>
<div class="single-testimonials-card">
<p><?php echo wp_kses_post( $value['feedback'] ); ?></p>
<div class="client-info">
<div class="d-flex align-items-center">
<?php if($value['image']['url'] != ''): ?>
<img src="<?php echo esc_url( $value['image']['url'] ); ?>" alt="<?php echo esc_attr( $value['name'] ); ?>">
<?php endif; ?>
<div class="title">
<h3><?php echo esc_html( $value['name'] ); ?> <span><?php echo esc_html( $value['designation'] ); ?></span></h3>
<div class="rating">
<?php if( $value['star_count'] == 1 ) { ?>
<i class="<?php echo esc_attr($value['icon_class']) ; ?>"></i>
<?php } elseif( $value['star_count'] == 2 ) { ?>
<i class="<?php echo esc_attr($value['icon_class']) ; ?>"></i>
<i class="<?php echo esc_attr($value['icon_class']) ; ?>"></i>
<?php } elseif( $value['star_count'] == 3 ) { ?>
<i class="<?php echo esc_attr($value['icon_class']) ; ?>"></i>
<i class="<?php echo esc_attr($value['icon_class']) ; ?>"></i>
<i class="<?php echo esc_attr($value['icon_class']) ; ?>"></i>
<?php } elseif( $value['star_count'] == 4 ) { ?>
<i class="<?php echo esc_attr($value['icon_class']) ; ?>"></i>
<i class="<?php echo esc_attr($value['icon_class']) ; ?>"></i>
<i class="<?php echo esc_attr($value['icon_class']) ; ?>"></i>
<i class="<?php echo esc_attr($value['icon_class']) ; ?>"></i>
<?php } elseif( $value['star_count'] == 5 ) { ?>
<i class="<?php echo esc_attr($value['icon_class']) ; ?>"></i>
<i class="<?php echo esc_attr($value['icon_class']) ; ?>"></i>
<i class="<?php echo esc_attr($value['icon_class']) ; ?>"></i>
<i class="<?php echo esc_attr($value['icon_class']) ; ?>"></i>
<i class="<?php echo esc_attr($value['icon_class']) ; ?>"></i>
<?php } ?>
</div>
</div>
</div>
</div>
<?php if( $settings['qi_image']['url'] != '' ) : ?>
<div class="quote-shape">
<img src="<?php echo esc_url( $settings['qi_image']['url'] ); ?>" class="quote" alt="<?php echo esc_attr__( 'quote', 'cyarb-toolkit' ) ?>">
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<?php
}
}
Plugin::instance()->widgets_manager->register_widget_type( new Cyarb_Testimonial_Two );