File: /var/www/html/delstar/wp-content/themes/construction/inc/elementors/client-testimonial.php
<?php
namespace WPCharming\Widgets;
use Elementor\Widget_Base ;
use Elementor\Controls_Manager ;
use Elementor\Utils ;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class WPC_Element_Client_Testimonial extends Widget_Base {
public function get_name() {
return 'wpc-client-testimonial';
}
public function get_title() {
return __( 'Client Testimonial', 'wpcharming' );
}
public function get_icon() {
// Icon name from the Elementor font file, as per http://dtbaker.net/web-development/creating-your-own-custom-elementor-widgets/
return 'eicon-wordpress';
}
public function get_categories() {
return [ 'wpc-elements' ];
}
protected function _register_controls() {
$this->start_controls_section(
'section_content',
[
'label' => esc_html__( 'Client Testimonial', 'wpcharming' ),
]
);
$this->add_control(
'style',
[
'label' => __( 'Testimonial Style', 'wpcharming' ),
'label_block' => true,
'description' => __('Choose your testimonial style', 'wpcharming'),
'type' => Controls_Manager::SELECT,
'default' => 'default',
'options' => [
'default' => __( 'Default, on a white background color', 'wpcharming' ),
'inverted' => __( 'Inverted, on a gray background color', 'wpcharming' ),
],
]
);
$this->add_control(
'name',
[
'label' => __( 'Client Name', 'wpcharming' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => ''
]
);
$this->add_control(
'avatar',
[
'label' => __( 'Client Avatar', 'wpcharming' ),
'type' => \Elementor\Controls_Manager::MEDIA,
'default' => [
'url' => \Elementor\Utils::get_placeholder_image_src(),
],
'description' => __('Client image, the size should be smaller than 200 x 200px', 'wpcharming'),
]
);
$this->add_control(
'testimonial_content',
[
'label' => __( 'Testimonial Content', 'wpcharming' ),
'type' => \Elementor\Controls_Manager::TEXTAREA,
'rows' => 10,
'default' => '',
'placeholder' => '',
]
);
$this->end_controls_section();
}
protected function render( $instance = [] ) {
$settings = $this->get_settings_for_display();
$style = $settings['style'];
$testimonial_content = $settings['testimonial_content'];
$name = $settings['name'];
$avatar = $settings['avatar'];
$output = null;
$style_class = null;
if ( $style == 'inverted' ) $style_class = ' inverted';
$output .= '
<div class="testimonial'. $style_class .'">';
$output .= '
<div class="testimonial-content">';
if ( $testimonial_content ) {
$output .= '
<p>'. wp_kses_post($testimonial_content) .'</p>';
}
$output .= '
</div>';
$output .= '
<div class="testimonial-header clearfix">';
if ( $avatar != '' ) {
$avatar_url = $avatar['url'];
$output .= '
<div class="testimonial-avatar"><img src="'. esc_url($avatar_url) .'" alt="'. esc_attr($name) .'"></div>';
}
$output .= '
<div class="testimonial-name font-heading">'. esc_attr($name) .'</div>';
$output .= '
</div>';
$output .= '
</div>';
echo html_entity_decode($output);
}
protected function _content_template() {}
}