<?php
/**
* Feedback Widget
*/
namespace Elementor;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Cyarb_Testimonial extends Widget_Base {
public function get_name() {
return 'Feedback';
}
public function get_title() {
return __( 'Feedback', '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(
'feedback_style',
[
'label' => __( 'Feedback Style', 'cyarb-toolkit' ),
'type' => Controls_Manager::SELECT,
'options' => [
'1' => __( 'Style One', 'cyarb-toolkit' ),
'2' => __( 'Style Two', 'cyarb-toolkit' ),
'3' => __( 'Style Three', 'cyarb-toolkit' ),
],
'default' => '1',
]
);
$this->add_control(
'title',
[
'label' => __( 'Title', 'cyarb-toolkit' ),
'type' => Controls_Manager::TEXT,
'condition' => [
'feedback_style' => ['1','3'],
]
]
);
$this->add_control(
'title_tag',
[
'label' => __( 'Title Tag', 'cyarb-toolkit' ),
'type' => Controls_Manager::SELECT,
'options' => [
'h1' => __( 'h1', 'cyarb-toolkit' ),
'h2' => __( 'h2', 'cyarb-toolkit' ),
'h3' => __( 'h3', 'cyarb-toolkit' ),
'h4' => __( 'h4', 'cyarb-toolkit' ),
'h5' => __( 'h5', 'cyarb-toolkit' ),
'h6' => __( 'h6', 'cyarb-toolkit' ),
],
'default' => 'h2',
'condition' => [
'feedback_style' => ['1','3'],
]
]
);
$this->add_control(
'desc',
[
'label'=>__('Description', 'cyarb-toolkit'),
'type'=>Controls_Manager:: WYSIWYG,
'description' => __('This text editor for p','cyarb-toolkit'),
'condition' => [
'feedback_style' => ['1','3'],
]
]
);
$repeater = new Repeater();
$repeater->add_control(
'feedback_bg_style',
[
'label' => __( 'Feedback Background Style', 'cyarb-toolkit' ),
'type' => Controls_Manager::SELECT,
'options' => [
'single-feedback-box' => __( 'With White Background', 'cyarb-toolkit' ),
'single-feedback-box bg-f9f9f9' => __( 'With Background', 'cyarb-toolkit' ),
],
'default' => 'single-feedback-box',
]
);
$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(
'feedback', [
'label' => esc_html__('Feedback Content', 'cyarb-toolkit'),
'type'=>Controls_Manager:: WYSIWYG,
'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(
'quote_image',
[
'label' => esc_html__( 'Add Quote Image', 'cyarb-toolkit' ),
'type' => Controls_Manager::MEDIA,
]
);
$this->add_control(
'cyarb_feedback_items',
[
'label' => esc_html__('Slider Item', 'cyarb-toolkit'),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
]
);
//Shape Images
$this->add_control(
'image_shape',
[
'label' => esc_html__( 'Hide Shapes?', 'cyarb-toolkit' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'cyarb-toolkit' ),
'label_off' => esc_html__( 'Hide', 'cyarb-toolkit' ),
'return_value' => 'yes',
'default' => 'yes',
'condition' => [
'feedback_style' => ['1','3'],
]
]
);
$this->add_control(
'shape1',
[
'label' => esc_html__( 'Shape1', 'cyarb-toolkit' ),
'type' => Controls_Manager::MEDIA,
'condition' => [
'feedback_style' => ['1','3'],
]
]
);
$this->add_control(
'shape2',
[
'label' => esc_html__( 'Shape2', 'cyarb-toolkit' ),
'type' => Controls_Manager::MEDIA,
'condition' => [
'feedback_style' => ['1','3'],
]
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_images',
[
'label' => esc_html__( 'Images', 'cyarb-toolkit' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'fimage',
[
'label' => esc_html__( 'Add Background Image', 'cyarb-toolkit' ),
'type' => Controls_Manager::MEDIA,
]
);
$this->end_controls_section();
$this->start_controls_section(
'style',
[
'label' => __( 'Style', 'cyarb-toolkit' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'title_color',
[
'label' => __( 'Title Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .section-title h1, .feedback-area.bg-image .section-title h2, .section-title h3, .section-title h4, .section-title h5, .section-title h6' => 'color: {{VALUE}}',
],
'condition' => [
'feedback_style' => '1',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_type_typography',
'label' => __( 'Title Type Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .section-title h1, .section-title h2, .section-title h3, .section-title h4, .section-title h5, .section-title h6',
'condition' => [
'feedback_style' => ['1','2'],
]
]
);
$this->add_control(
'feedback_color',
[
'label' => __( 'Feedback Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} p, .feedback-area.bg-image .section-title p' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'feedback_type_typography',
'label' => __( 'Feedback Type Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} p',
]
);
$this->add_control(
'name_color',
[
'label' => __( 'Name Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-feedback-box .client-info .title h3, .single-feedback-item .client-info .title h3' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'name_type_typography',
'label' => __( 'Name Type Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-feedback-box .client-info .title h3, .single-feedback-item .client-info .title h3',
]
);
$this->add_control(
'designation_color',
[
'label' => __( 'Designation Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-feedback-box .client-info .title h3 span, .single-feedback-item .client-info .title h3 span' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'designation_type_typography',
'label' => __( 'Designation Type Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-feedback-box .client-info .title h3 span, .single-feedback-item .client-info .title h3 span',
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
$slider = $settings['cyarb_feedback_items'];
?>
<?php if( $settings['feedback_style'] == '1' ): ?>
<?php if( $settings['fimage']['url'] != '' ) : ?>
<div class="feedback-area ptb-100 bg-image" style="background-image:url(<?php echo esc_url( $settings['fimage']['url'] ); ?>);">
<?php else: ?>
<div class="feedback-area ptb-100 ">
<?php endif; ?>
<div class="container">
<?php if( $settings['title'] != '' || $settings['desc'] != '') : ?>
<div class="section-title">
<<?php echo esc_attr( $settings['title_tag'] ); ?>>
<?php echo esc_html( $settings['title'] ); ?>
</<?php echo esc_attr( $settings['title_tag'] ); ?>>
<?php echo wp_kses_post( $settings['desc'] ); ?>
</div>
<?php endif; ?>
<div class="feedback-slides owl-carousel owl-theme">
<?php foreach ($slider as $key => $value): ?>
<div class="<?php echo esc_attr( $value['feedback_bg_style'] ); ?>">
<?php echo wp_kses_post( $value['feedback'] ); ?>
<div class="client-info">
<div class="d-flex align-items-center">
<img src="<?php echo esc_url( $value['image']['url'] ); ?>" alt="<?php echo esc_attr( $value['name'] ) ?>">
<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="lni lni-star-filled"></i>
<?php } elseif( $value['star_count'] == 2 ) { ?>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<?php } elseif( $value['star_count'] == 3 ) { ?>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<?php } elseif( $value['star_count'] == 4 ) { ?>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<?php } elseif( $value['star_count'] == 5 ) { ?>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<?php } ?>
</div>
</div>
</div>
</div>
<img src="<?php echo esc_url( $value['quote_image']['url'] ); ?>" class="quote" alt="<?php echo esc_attr( $value['name'] ) ?>">
</div>
<?php endforeach; ?>
</div>
</div>
<?php if ( 'yes' === $settings['image_shape'] ) : ?>
<?php if( $settings['shape1']['url'] != '' ) : ?>
<div class="shape3"> <img src="<?php echo esc_url( $settings['shape1']['url'] ); ?>" alt="<?php echo esc_attr__( 'Shape' ); ?>"></div>
<?php endif; ?>
<?php if( $settings['shape2']['url'] != '' ) : ?>
<div class="shape8"><img src="<?php echo esc_url( $settings['shape2']['url'] ); ?>" alt="<?php echo esc_attr__( 'Shape' ); ?>"></div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php elseif( $settings['feedback_style'] == '2' ): ?>
<div class="feedback-area pt-100 pb-75">
<div class="container">
<div class="row">
<?php foreach ($slider as $key => $value): ?>
<div class="col-xl-4 col-lg-6 col-md-6">
<div class="<?php echo esc_attr( $value['feedback_bg_style'] ); ?>">
<?php echo wp_kses_post( $value['feedback'] ); ?>
<div class="client-info">
<div class="d-flex align-items-center">
<img src="<?php echo esc_url( $value['image']['url'] ); ?>" alt="<?php echo esc_attr( $value['name'] ); ?>">
<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="lni lni-star-filled"></i>
<?php } elseif( $value['star_count'] == 2 ) { ?>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<?php } elseif( $value['star_count'] == 3 ) { ?>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<?php } elseif( $value['star_count'] == 4 ) { ?>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<?php } elseif( $value['star_count'] == 5 ) { ?>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<?php } ?>
</div>
</div>
</div>
</div>
<img src="<?php echo esc_url( $value['quote_image']['url'] ); ?>" class="quote" alt="<?php echo esc_attr( $value['name'] ) ?>">
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<?php else: ?>
<div class="feedback-area ptb-100 bg-image" style="background-image:url(<?php echo esc_url( $settings['fimage']['url'] ); ?>);">
<div class="container">
<?php if( $settings['title'] != '' || $settings['desc'] != '') : ?>
<div class="section-title">
<<?php echo esc_attr( $settings['title_tag'] ); ?>>
<?php echo esc_html( $settings['title'] ); ?>
</<?php echo esc_attr( $settings['title_tag'] ); ?>>
<?php echo wp_kses_post( $settings['desc'] ); ?>
</div>
<?php endif; ?>
<div class="feedback-slides-two owl-carousel owl-theme">
<?php foreach ($slider as $key => $value): ?>
<div class="single-feedback-item">
<img src="<?php echo esc_url( $value['quote_image']['url'] ); ?>" class="quote" alt="<?php echo esc_attr( $value['name'] ) ?>">
<?php echo wp_kses_post( $value['feedback'] ); ?>
<div class="client-info">
<div class="d-flex align-items-center">
<img src="<?php echo esc_url( $value['image']['url'] ); ?>" alt="<?php echo esc_attr( $value['name'] ); ?>">
<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="lni lni-star-filled"></i>
<?php } elseif( $value['star_count'] == 2 ) { ?>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<?php } elseif( $value['star_count'] == 3 ) { ?>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<?php } elseif( $value['star_count'] == 4 ) { ?>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<?php } elseif( $value['star_count'] == 5 ) { ?>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<i class="lni lni-star-filled"></i>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php if ( 'yes' === $settings['image_shape'] ) : ?>
<?php if( $settings['shape1']['url'] != '' ) : ?>
<div class="shape3"> <img src="<?php echo esc_url( $settings['shape1']['url'] ); ?>" alt="<?php echo esc_attr__( 'Shape' ); ?>"></div>
<?php endif; ?>
<?php if( $settings['shape2']['url'] != '' ) : ?>
<div class="shape8"><img src="<?php echo esc_url( $settings['shape2']['url'] ); ?>" alt="<?php echo esc_attr__( 'Shape' ); ?>"></div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<?php
}
}
Plugin::instance()->widgets_manager->register_widget_type( new Cyarb_Testimonial );