<?php
/**
* Class: Jet_Reviews
* Name: Jet Reviews
* Slug: jet-reviews
*/
namespace Elementor;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Typography;
use Elementor\Repeater;
use Elementor\Scheme_Color;
use Elementor\Scheme_Typography;
use Elementor\Widget_Base;
use Elementor\Utils;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class Jet_Reviews extends Jet_Reviews_Base {
private $__review_data = [];
private $__primary_review_data = [];
public function get_name() {
return 'jet-reviews';
}
public function get_title() {
return esc_html__( 'Static Review', 'jet-reviews' );
}
public function get_icon() {
return 'eicon-favorite';
}
public function get_help_url() {
return 'https://crocoblock.com/knowledge-base/article-category/jetreviews/?utm_source=jetreviews&utm_medium=jet-reviews&utm_campaign=need-help';
}
public function get_categories() {
return array( 'cherry' );
}
protected function _register_controls() {
$css_scheme = apply_filters(
'jet-reviews/widget/css-scheme',
array(
'header' => '.jet-review__header',
'total_average' => '.jet-review__total-average',
'form' => '.jet-review__form',
'form_input' => '.jet-review__form input[type="text"], .jet-review__form textarea',
'review_item' => '.jet-review__item',
'author' => '.jet-review__user',
'title' => '.jet-review__title',
'fields_box' => '.jet-review__fields',
'field' => '.jet-review__field',
'field_heading' => '.jet-review__field-heading',
'stars' => '.jet-review__stars',
'field_value' => '.jet-review__field-val',
'progress' => '.jet-review__progress',
'progress_bar' => '.jet-review__progress-bar',
'progress_value' => '.jet-review__progress-val',
'summary' => '.jet-review__summary-content',
'summary_data' => '.jet-review__summary-data',
'summary_value' => '.jet-review__summary-val',
'summary_title' => '.jet-review__summary-title',
'summary_content' => '.jet-review__summary-text',
'summary_legend' => '.jet-review__summary-legend',
'summary' => '.jet-review__summary-content',
)
);
$this->start_controls_section(
'section_content',
array(
'label' => esc_html__( 'Content', 'jet-reviews' ),
)
);
$this->add_control(
'content_source',
array(
'type' => 'select',
'label' => esc_html__( 'Content Source', 'jet-reviews' ),
'default' => 'manually',
'options' => $this->__review_sources(),
)
);
$this->add_control(
'review_post_id',
array(
'label' => esc_html__( 'Get Data From Post', 'jet-reviews' ),
'description' => esc_html__( 'Enter post ID to get data from or leave empy to get data from current post', 'jet-reviews' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'condition' => array(
'content_source' => 'post-meta',
),
)
);
$this->add_control(
'show_review_author',
array(
'label' => esc_html__( 'Show Review Author', 'jet-reviews' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'jet-reviews' ),
'label_off' => esc_html__( 'No', 'jet-reviews' ),
'return_value' => 'yes',
'default' => 'no',
)
);
$repeater = new Repeater();
$repeater->add_control(
'field_label',
array(
'label' => esc_html__( 'Label', 'jet-reviews' ),
'type' => Controls_Manager::TEXT,
)
);
$repeater->add_control(
'field_value',
array(
'label' => esc_html__( 'Field Value', 'jet-reviews' ),
'type' => Controls_Manager::NUMBER,
'default' => 9,
'min' => 1,
'max' => 100,
'step' => 0.1,
)
);
$repeater->add_control(
'field_max',
array(
'label' => esc_html__( 'Field Max', 'jet-reviews' ),
'type' => Controls_Manager::NUMBER,
'default' => 10,
'min' => 1,
'max' => 100,
'step' => 0.1,
)
);
$this->add_control(
'review_fields',
array(
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => array(
array(
'field_label' => esc_html__( 'Design', 'jet-reviews' ),
'field_value' => 9,
'field_max' => 10,
),
),
'title_field' => '{{{ field_label }}}',
'condition' => array(
'content_source' => 'manually',
),
)
);
$this->add_control(
'summary_title',
array(
'label' => esc_html__( 'Summary Title', 'jet-reviews' ),
'default' => esc_html__( 'Review Summary Title', 'jet-reviews' ),
'type' => Controls_Manager::TEXT,
'condition' => array(
'content_source' => 'manually',
),
)
);
$this->add_control(
'summary_text',
array(
'label' => esc_html__( 'Summary Text', 'jet-reviews' ),
'type' => Controls_Manager::WYSIWYG,
'default' => esc_html__( 'Review Summary Description', 'jet-reviews' ),
'condition' => array(
'content_source' => 'manually',
),
)
);
$this->add_control(
'summary_legend',
array(
'label' => esc_html__( 'Summary Legend', 'jet-reviews' ),
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Nice!', 'jet-reviews' ),
'condition' => array(
'content_source' => 'manually',
),
)
);
$this->end_controls_section();
$this->start_controls_section(
'section_sdata',
array(
'label' => esc_html__( 'Structured Data', 'jet-reviews' ),
)
);
$this->add_control(
'add_sdata',
array(
'label' => esc_html__( 'Add Structured Data to review box', 'jet-reviews' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'jet-reviews' ),
'label_off' => esc_html__( 'No', 'jet-reviews' ),
'return_value' => 'yes',
'default' => '',
)
);
$this->add_control(
'sdata_item_name',
array(
'label' => esc_html__( 'Review Item Name', 'jet-reviews' ),
'type' => Controls_Manager::TEXT,
'default' => '',
'condition' => array(
'add_sdata' => 'yes',
'content_source' => 'manually',
),
)
);
$this->add_control(
'sdata_item_image',
array(
'label' => esc_html__( 'Review Item Image', 'jet-reviews' ),
'type' => Controls_Manager::MEDIA,
'default' => array(
'url' => Utils::get_placeholder_image_src(),
),
'condition' => array(
'add_sdata' => 'yes',
'content_source' => 'manually',
),
)
);
$this->add_control(
'sdata_item_description',
array(
'label' => esc_html__( 'Review Item Description', 'jet-reviews' ),
'type' => Controls_Manager::TEXTAREA,
'default' => '',
'condition' => array(
'add_sdata' => 'yes',
'content_source' => 'manually',
),
)
);
$default_date = date( 'Y-m-d H:i' );
$this->add_control(
'sdata_review_date',
array(
'label' => esc_html__( 'Review Date', 'jet-reviews' ),
'type' => Controls_Manager::DATE_TIME,
'default' => $default_date,
'separator' => 'before',
'condition' => array(
'add_sdata' => 'yes',
'content_source' => 'manually',
),
)
);
$this->add_control(
'sdata_review_author',
array(
'label' => esc_html__( 'Review Author Name', 'jet-reviews' ),
'type' => Controls_Manager::TEXT,
'default' => '',
'condition' => array(
'add_sdata' => 'yes',
'content_source' => 'manually',
),
)
);
$this->end_controls_section();
$this->start_controls_section(
'section_header_settings',
array(
'label' => esc_html__( 'Header Settings', 'jet-reviews' ),
)
);
$this->add_control(
'review_title',
array(
'label' => esc_html__( 'Title', 'jet-reviews' ),
'type' => Controls_Manager::TEXT,
'condition' => array(
'content_source' => 'manually',
),
)
);
$this->add_control(
'total_average_layout',
array(
'label' => esc_html__( 'Average Layout', 'jet-reviews' ),
'type' => Controls_Manager::SELECT,
'default' => 'points',
'options' => array(
'stars' => esc_html__( 'Stars', 'jet-reviews' ),
'percentage' => esc_html__( 'Percentage', 'jet-reviews' ),
'points' => esc_html__( 'Points', 'jet-reviews' ),
),
)
);
$this->add_control(
'total_average_progressbar',
array(
'label' => esc_html__( 'Progressbar', 'jet-reviews' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'jet-reviews' ),
'label_off' => esc_html__( 'Hide', 'jet-reviews' ),
'return_value' => 'yes',
'default' => '',
'condition' => array(
'total_average_layout' => array( 'percentage', 'points' ),
),
Loading ...