File "wgl-testimonials.php"
Full Path: /home/ubunrgit/public_html/wp-content/plugins/unicoach-core/includes/elementor/widgets/wgl-testimonials.php
File size: 25.75 KB
MIME-type: text/x-php
Charset: utf-8
<?php
/*
* This template can be overridden by copying it to yourtheme/unicoach-core/elementor/widgets/wgl-testimonials.php.
*/
namespace WglAddons\Widgets;
defined('ABSPATH') || exit; // Abort, if called directly.
use Elementor\{Widget_Base, Controls_Manager, Utils, Repeater};
use Elementor\{Group_Control_Border, Group_Control_Box_Shadow, Group_Control_Typography, Group_Control_Background};
use WglAddons\Unicoach_Global_Variables as Unicoach_Globals;
use WglAddons\Includes\Wgl_Carousel_Settings;
use WglAddons\Templates\WglTestimonials;
class Wgl_Testimonials extends Widget_Base
{
public function get_name()
{
return 'wgl-testimonials';
}
public function get_title()
{
return esc_html__('WGL Testimonials', 'unicoach-core');
}
public function get_icon()
{
return 'wgl-testimonials';
}
public function get_script_depends()
{
return ['slick'];
}
public function get_categories()
{
return ['wgl-extensions'];
}
protected function register_controls()
{
/*-----------------------------------------------------------------------------------*/
/* CONTENT -> GENERAL
/*-----------------------------------------------------------------------------------*/
$this->start_controls_section(
'wgl_testimonials_section',
['label' => esc_html__('General', 'unicoach-core')]
);
$this->add_control(
'posts_per_line',
[
'label' => esc_html__('Grid Columns Amount', 'unicoach-core'),
'type' => Controls_Manager::SELECT,
'options' => [
'1' => esc_html__('One ', 'unicoach-core'),
'2' => esc_html__('Two', 'unicoach-core'),
'3' => esc_html__('Three', 'unicoach-core'),
'4' => esc_html__('Four', 'unicoach-core'),
'5' => esc_html__('Five', 'unicoach-core'),
],
'default' => '1',
]
);
$repeater = new Repeater();
$repeater->add_control(
'thumbnail',
[
'label' => esc_html__('Image', 'unicoach-core'),
'type' => Controls_Manager::MEDIA,
'label_block' => true,
'default' => ['url' => Utils::get_placeholder_image_src()],
]
);
$repeater->add_control(
'author_name',
[
'label' => esc_html__('Author Name', 'unicoach-core'),
'type' => Controls_Manager::TEXT,
'label_block' => true
]
);
$repeater->add_control(
'link_author',
[
'label' => esc_html__('Link Author', 'unicoach-core'),
'type' => Controls_Manager::URL,
'label_block' => true,
]
);
$repeater->add_control(
'author_position',
[
'label' => esc_html__('Author Position', 'unicoach-core'),
'type' => Controls_Manager::TEXT,
'label_block' => true
]
);
$repeater->add_control(
'author_date',
[
'label' => esc_html__('Date', 'unicoach-core'),
'type' => Controls_Manager::TEXT,
'label_block' => true,
]
);
$repeater->add_control(
'quote',
[
'label' => esc_html__('Quote', 'unicoach-core'),
'type' => Controls_Manager::WYSIWYG,
'label_block' => true,
'dynamic' => ['active' => true],
]
);
$this->add_control(
'list',
[
'label' => esc_html__('Items', 'unicoach-core'),
'type' => Controls_Manager::REPEATER,
'default' => [
[
'author_name' => esc_html__('Tina Johanson', 'unicoach-core'),
'author_position' => esc_html__('UI Designer', 'unicoach-core'),
'quote' => esc_html__('“Choosing online studies was the best way to do it – the internet is fast, cheap & popular and it’s easy to communicate in social media with native speakers.”', 'unicoach-core'),
'thumbnail' => Utils::get_placeholder_image_src(),
],
],
'fields' => $repeater->get_controls(),
'title_field' => '{{{ author_name }}}',
]
);
$this->add_control(
'item_type',
[
'label' => esc_html__('Layout', 'unicoach-core'),
'type' => 'wgl-radio-image',
'options' => [
'author_top' => [
'title' => esc_html__('Top', 'unicoach-core'),
'image' => WGL_ELEMENTOR_ADDONS_URL . 'assets/img/wgl_elementor_addon/icons/testimonials_1.png',
],
'author_bottom' => [
'title' => esc_html__('Bottom', 'unicoach-core'),
'image' => WGL_ELEMENTOR_ADDONS_URL . 'assets/img/wgl_elementor_addon/icons/testimonials_4.png',
],
'inline_top' => [
'title' => esc_html__('Top Inline', 'unicoach-core'),
'image' => WGL_ELEMENTOR_ADDONS_URL . 'assets/img/wgl_elementor_addon/icons/testimonials_2.png',
],
'inline_bottom' => [
'title' => esc_html__('Bottom Inline', 'unicoach-core'),
'image' => WGL_ELEMENTOR_ADDONS_URL . 'assets/img/wgl_elementor_addon/icons/testimonials_3.png',
],
],
'default' => 'inline_bottom',
]
);
$this->add_control(
'item_align',
[
'label' => esc_html__('Alignment', 'unicoach-core'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => esc_html__('Left', 'unicoach-core'),
'icon' => 'fa fa-align-left',
],
'center' => [
'title' => esc_html__('Center', 'unicoach-core'),
'icon' => 'fa fa-align-center',
],
'right' => [
'title' => esc_html__('Right', 'unicoach-core'),
'icon' => 'fa fa-align-right',
],
],
'default' => 'left',
'toggle' => true,
]
);
$this->add_control(
'hover_animation',
[
'label' => esc_html__('Enable Hover Animation', 'unicoach-core'),
'type' => Controls_Manager::SWITCHER,
'description' => esc_html__('Lift up the item on hover.', 'unicoach-core'),
]
);
$this->end_controls_section();
/*-----------------------------------------------------------------------------------*/
/* CONTENT -> CAROUSEL OPTIONS
/*-----------------------------------------------------------------------------------*/
Wgl_Carousel_Settings::options( $this, [ 'wgl_motion' => true ] );
/*-----------------------------------------------------------------------------------*/
/* STYLE -> IMAGE
/*-----------------------------------------------------------------------------------*/
$this->start_controls_section(
'section_style_image',
[
'label' => esc_html__('Image', 'unicoach-core'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'additional_style',
[
'label' => esc_html__('Additional Image Style', 'unicoach-core'),
'type' => Controls_Manager::SWITCHER,
'condition' => ['item_type' => 'author_top'],
'prefix_class' => 'additional_style_',
'render_type' => 'template',
]
);
$this->add_control(
'image_size',
[
'label' => esc_html__('Image Width', 'unicoach-core'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => ['min' => 20, 'max' => 1000],
],
'default' => ['size' => 80],
]
);
$this->add_control(
'image_height',
[
'label' => esc_html__('Image Height', 'unicoach-core'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => ['min' => 20, 'max' => 1000],
],
'default' => ['size' => 80],
'condition' => ['additional_style!' => ''],
]
);
$this->add_responsive_control(
'image_margin',
[
'label' => esc_html__('Margin', 'unicoach-core'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .wgl-testimonials_image' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'image_padding',
[
'label' => esc_html__('Padding', 'unicoach-core'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .wgl-testimonials_image' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'testimonials_image_shadow',
'selector' => '{{WRAPPER}} .wgl-testimonials_image img',
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'image_border',
'selector' => '{{WRAPPER}} .wgl-testimonials_image img',
'separator' => 'before',
]
);
$this->add_control(
'image_border_radius',
[
'label' => esc_html__('Border Radius', 'unicoach-core'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'default' => [
'top' => '50',
'left' => '50',
'right' => '50',
'bottom' => '50',
'unit' => '%',
'isLinked' => false
],
'selectors' => [
'{{WRAPPER}} .wgl-testimonials_image img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
/*-----------------------------------------------------------------------------------*/
/* STYLE -> QUOTE
/*-----------------------------------------------------------------------------------*/
$this->start_controls_section(
'section_style_quote',
[
'label' => esc_html__('Quote', 'unicoach-core'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'quote_tag',
[
'label' => esc_html__('Quote tag', 'unicoach-core'),
'type' => Controls_Manager::SELECT,
'options' => [
'div' => '‹div›',
'span' => '‹span›',
'h1' => '‹h1›',
'h2' => '‹h2›',
'h3' => '‹h3›',
'h4' => '‹h4›',
'h5' => '‹h5›',
'h6' => '‹h6›',
],
'default' => 'div',
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'custom_fonts_quote',
'selector' => '{{WRAPPER}} .wgl-testimonials_quote',
]
);
$this->add_control(
'quote_color',
[
'label' => esc_html__('Text Color', 'unicoach-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .wgl-testimonials_quote' => 'color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'quote_margin',
[
'label' => esc_html__('Margin', 'unicoach-core'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .wgl-testimonials_quote' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'quote_padding',
[
'label' => esc_html__('Padding', 'unicoach-core'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .wgl-testimonials_quote' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
/*-----------------------------------------------------------------------------------*/
/* STYLE -> AUTHOR NAME
/*-----------------------------------------------------------------------------------*/
$this->start_controls_section(
'section_style_author_name',
[
'label' => esc_html__('Author Name', 'unicoach-core'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'name_tag',
[
'label' => esc_html__('HTML tag', 'unicoach-core'),
'type' => Controls_Manager::SELECT,
'default' => 'h3',
'options' => [
'div' => '‹div›',
'span' => '‹span›',
'h1' => '‹h1›',
'h2' => '‹h2›',
'h3' => '‹h3›',
'h4' => '‹h4›',
'h5' => '‹h5›',
'h6' => '‹h6›',
],
]
);
$this->add_responsive_control(
'name_padding',
[
'label' => esc_html__('Padding', 'unicoach-core'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .wgl-testimonials_name' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->start_controls_tabs('name_colors');
$this->start_controls_tab(
'tab_name_idle',
['label' => esc_html__('Idle', 'unicoach-core')]
);
$this->add_control(
'name_color_idle',
[
'label' => esc_html__('Text Color', 'unicoach-core'),
'type' => Controls_Manager::COLOR,
'default' => Unicoach_Globals::get_h_font_color(),
'selectors' => [
'{{WRAPPER}} .wgl-testimonials_name' => 'color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'tab_name_hover',
['label' => esc_html__('Hover', 'unicoach-core')]
);
$this->add_control(
'name_color_hover',
[
'label' => esc_html__('Text Color', 'unicoach-core'),
'type' => Controls_Manager::COLOR,
'default' => Unicoach_Globals::get_h_font_color(),
'selectors' => [
'{{WRAPPER}} .wgl-testimonials_name:hover' => 'color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'custom_fonts_name',
'selector' => '{{WRAPPER}} .wgl-testimonials_name',
]
);
$this->end_controls_section();
/*-----------------------------------------------------------------------------------*/
/* STYLE -> AUTHOR POSITION
/*-----------------------------------------------------------------------------------*/
$this->start_controls_section(
'section_style_author_position',
[
'label' => esc_html__('Author Position', 'unicoach-core'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'position_tag',
[
'label' => esc_html__('HTML tag', 'unicoach-core'),
'type' => Controls_Manager::SELECT,
'default' => 'span',
'options' => [
'div' => '‹div›',
'span' => '‹span›',
'h1' => '‹h1›',
'h2' => '‹h2›',
'h3' => '‹h3›',
'h4' => '‹h4›',
'h5' => '‹h5›',
'h6' => '‹h6›',
],
]
);
$this->add_responsive_control(
'position_padding',
[
'label' => esc_html__('Padding', 'unicoach-core'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'default' => [
'top' => '12',
'left' => '0',
'right' => '0',
'bottom' => '0',
'unit' => 'px',
'isLinked' => false
],
'selectors' => [
'{{WRAPPER}} .wgl-testimonials_position' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->start_controls_tabs('position_colors');
$this->start_controls_tab(
'position_color_idle',
['label' => esc_html__('Idle', 'unicoach-core')]
);
$this->add_control(
'custom_position_color',
[
'label' => esc_html__('Text Color', 'unicoach-core'),
'type' => Controls_Manager::COLOR,
'default' => Unicoach_Globals::get_primary_color(),
'selectors' => [
'{{WRAPPER}} .wgl-testimonials_position' => 'color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'tab_position_hover',
[
'label' => esc_html__('Hover', 'unicoach-core'),
]
);
$this->add_control(
'position_color_hover',
[
'label' => esc_html__('Text Color', 'unicoach-core'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .wgl-testimonials_position:hover' => 'color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'custom_fonts_position',
'selector' => '{{WRAPPER}} .wgl-testimonials_position',
]
);
$this->end_controls_section();
/*-----------------------------------------------------------------------------------*/
/* STYLE -> DATE
/*-----------------------------------------------------------------------------------*/
$this->start_controls_section(
'section_style_date',
[
'label' => esc_html__('Date', 'unicoach-core'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'date_padding',
[
'label' => esc_html__('Padding', 'unicoach-core'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .wgl-testimonials_date' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'custom_date_color',
[
'label' => esc_html__('Text Color', 'unicoach-core'),
'type' => Controls_Manager::COLOR,
'default' => '#a2a2a2',
'selectors' => [
'{{WRAPPER}} .wgl-testimonials_date' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'custom_fonts_date',
'selector' => '{{WRAPPER}} .wgl-testimonials_date',
]
);
$this->end_controls_section();
/*-----------------------------------------------------------------------------------*/
/* STYLE -> ITEM BOX
/*-----------------------------------------------------------------------------------*/
$this->start_controls_section(
'section_style_item_box',
[
'label' => esc_html__('Item Box', 'unicoach-core'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'background_item',
'label' => esc_html__('Background', 'unicoach-core'),
'types' => ['classic', 'gradient'],
'selector' => '{{WRAPPER}} .wgl-testimonials_item',
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'testimonials_shadow',
'selector' => '{{WRAPPER}} .wgl-testimonials_item',
'fields_options' => [
'box_shadow_type' => [
'default' => 'yes'
],
'box_shadow' => [
'default' => [
'horizontal' => 11,
'vertical' => 10,
'blur' => 38,
'spread' => 0,
'color' => 'rgba(46, 63, 99, 0.15)',
]
]
]
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'testimonials_border',
'label' => esc_html__('Border', 'unicoach-core'),
'selector' => '{{WRAPPER}} .wgl-testimonials_item',
]
);
$this->add_responsive_control(
'item_margin',
[
'label' => esc_html__('Margin', 'unicoach-core'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .wgl-testimonials_item' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'item_padding',
[
'label' => esc_html__('Padding', 'unicoach-core'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .wgl-testimonials_item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'item_border_radius',
[
'label' => esc_html__('Border Radius', 'unicoach-core'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'default' => [
'top' => '10',
'left' => '10',
'right' => '10',
'bottom' => '10',
'unit' => 'px',
'isLinked' => false
],
'selectors' => [
'{{WRAPPER}} .wgl-testimonials_item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
}
protected function render()
{
echo (new WglTestimonials())->render($this, $this->get_settings_for_display());
}
public function wpml_support_module() {
add_filter( 'wpml_elementor_widgets_to_translate', [$this, 'wpml_widgets_to_translate_filter']);
}
public function wpml_widgets_to_translate_filter( $widgets ){
return \WglAddons\Includes\Wgl_WPML_Settings::get_translate(
$this, $widgets
);
}
}