File: /home/dmstechonline/public_html/wp-content/plugins/xolio-core/include/elementor/pricing.php
<?php
namespace TPCore\Widgets;
use Elementor\Widget_Base;
use \Elementor\Group_Control_Text_Shadow;
use \Elementor\Repeater;
use \Elementor\Control_Media;
use \Elementor\Utils;
use \Elementor\Core\Schemes\Typography;
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Box_Shadow;
use \Elementor\Group_Control_Typography;
use \Elementor\Group_Control_Image_Size;
if (!defined('ABSPATH')) exit; // Exit if accessed directly
/**
* Xolio Core
*
* Elementor widget for hello world.
*
* @since 1.0.0
*/
class TP_Pricing extends Widget_Base
{
/**
* Retrieve the widget name.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget name.
*/
public function get_name()
{
return 'tp-pricing';
}
/**
* Retrieve the widget title.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget title.
*/
public function get_title()
{
return __('Pricing', 'tpcore');
}
/**
* Retrieve the widget icon.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget icon.
*/
public function get_icon()
{
return 'tp-icon';
}
/**
* Retrieve the list of categories the widget belongs to.
*
* Used to determine where to display the widget in the editor.
*
* Note that currently Elementor supports only one category.
* When multiple categories passed, Elementor uses the first one.
*
* @since 1.0.0
*
* @access public
*
* @return array Widget categories.
*/
public function get_categories()
{
return ['tpcore'];
}
/**
* Retrieve the list of scripts the widget depended on.
*
* Used to set scripts dependencies required to run the widget.
*
* @since 1.0.0
*
* @access public
*
* @return array Widget scripts dependencies.
*/
public function get_script_depends()
{
return ['tpcore'];
}
/**
* Register the widget controls.
*
* Adds different input fields to allow the user to change and customize the widget settings.
*
* @since 1.0.0
*
* @access protected
*/
protected function register_controls()
{
// Header
$this->start_controls_section(
'_section_header',
[
'label' => esc_html__('Header', 'tpcore'),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'tg_is_active',
[
'label' => esc_html__('Select Pricing Type', 'tpcore'),
'type' => \Elementor\Controls_Manager::SELECT,
'default' => 'default',
'options' => [
'default' => esc_html__('Default', 'tpcore'),
'active' => esc_html__('Active', 'tpcore'),
],
]
);
$this->add_control(
'tg_icon_type',
[
'label' => esc_html__('Select Icon Type', 'tpcore'),
'type' => \Elementor\Controls_Manager::SELECT,
'default' => 'image',
'options' => [
'image' => esc_html__('Image', 'tpcore'),
'icon' => esc_html__('Icon', 'tpcore'),
],
]
);
$this->add_control(
'tg_svg',
[
'label' => esc_html__('Upload Icon', 'tpcore'),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'condition' => [
'tg_icon_type' => 'image'
]
]
);
if (tp_is_elementor_version('<', '2.6.0')) {
$this->add_control(
'tg_icon',
[
'show_label' => false,
'type' => Controls_Manager::ICON,
'label_block' => true,
'default' => 'fa fa-star',
'condition' => [
'tg_icon_type' => 'icon'
]
]
);
} else {
$this->add_control(
'tg_selected_icon',
[
'show_label' => false,
'type' => Controls_Manager::ICONS,
'fa4compatibility' => 'icon',
'label_block' => true,
'default' => [
'value' => 'fas fa-star',
'library' => 'solid',
],
'condition' => [
'tg_icon_type' => 'icon'
]
]
);
}
$this->add_control(
'main_title',
[
'label' => esc_html__('Package Name', 'tpcore'),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => esc_html__('Professional', 'tpcore'),
'dynamic' => [
'active' => true
],
]
);
$this->add_control(
'pricing_desc',
[
'label' => esc_html__('Description', 'tpcore'),
'type' => Controls_Manager::TEXTAREA,
'label_block' => true,
'default' => esc_html__('Do more with Dokan Using Powerful Advanced feat..', 'tpcore'),
'dynamic' => [
'active' => true
],
]
);
$this->end_controls_section();
// Price
$this->start_controls_section(
'_section_pricing',
[
'label' => esc_html__('Pricing', 'tpcore'),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'currency',
[
'label' => esc_html__('Currency', 'tpcore'),
'type' => Controls_Manager::SELECT,
'label_block' => false,
'options' => [
'' => esc_html__('None', 'tpcore'),
'baht' => '฿ ' . _x('Baht', 'Currency Symbol', 'tpcore'),
'bdt' => '৳ ' . _x('BD Taka', 'Currency Symbol', 'tpcore'),
'dollar' => '$ ' . _x('Dollar', 'Currency Symbol', 'tpcore'),
'euro' => '€ ' . _x('Euro', 'Currency Symbol', 'tpcore'),
'franc' => '₣ ' . _x('Franc', 'Currency Symbol', 'tpcore'),
'guilder' => 'ƒ ' . _x('Guilder', 'Currency Symbol', 'tpcore'),
'krona' => 'kr ' . _x('Krona', 'Currency Symbol', 'tpcore'),
'lira' => '₤ ' . _x('Lira', 'Currency Symbol', 'tpcore'),
'peseta' => '₧ ' . _x('Peseta', 'Currency Symbol', 'tpcore'),
'peso' => '₱ ' . _x('Peso', 'Currency Symbol', 'tpcore'),
'pound' => '£ ' . _x('Pound Sterling', 'Currency Symbol', 'tpcore'),
'real' => 'R$ ' . _x('Real', 'Currency Symbol', 'tpcore'),
'ruble' => '₽ ' . _x('Ruble', 'Currency Symbol', 'tpcore'),
'rupee' => '₨ ' . _x('Rupee', 'Currency Symbol', 'tpcore'),
'indian_rupee' => '₹ ' . _x('Rupee (Indian)', 'Currency Symbol', 'tpcore'),
'shekel' => '₪ ' . _x('Shekel', 'Currency Symbol', 'tpcore'),
'won' => '₩ ' . _x('Won', 'Currency Symbol', 'tpcore'),
'yen' => '¥ ' . _x('Yen/Yuan', 'Currency Symbol', 'tpcore'),
'custom' => esc_html__('Custom', 'tpcore'),
],
'default' => 'dollar',
]
);
$this->add_control(
'currency_custom',
[
'label' => esc_html__('Custom Symbol', 'tpcore'),
'type' => Controls_Manager::TEXT,
'condition' => [
'currency' => 'custom',
],
'dynamic' => [
'active' => true,
]
]
);
$this->add_control(
'price',
[
'label' => esc_html__('Price', 'tpcore'),
'type' => Controls_Manager::TEXT,
'default' => '49',
'dynamic' => [
'active' => true
]
]
);
$this->add_control(
'duration',
[
'label' => esc_html__('Duration', 'tpcore'),
'type' => Controls_Manager::TEXT,
'default' => '/mo',
'dynamic' => [
'active' => true
]
]
);
$this->end_controls_section();
// Pricing List
$this->start_controls_section(
'_section_price_list',
[
'label' => esc_html__('Pricing List', 'tpcore'),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'list_title',
[
'label' => esc_html__('Title', 'tpcore'),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => esc_html__('Everything in Starter', 'tpcore'),
'dynamic' => [
'active' => true
],
]
);
$repeater = new Repeater();
$repeater->add_control(
'list_item',
[
'type' => Controls_Manager::TEXT,
'label' => esc_html__('List Item', 'tpcore'),
'default' => esc_html__('WC Product Addon Integration', 'tpcore'),
'label_block' => true,
'dynamic' => [
'active' => true,
]
]
);
$this->add_control(
'list_items',
[
'show_label' => false,
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'list_item' => esc_html__('WC Product Addon Integration', 'tpcore'),
],
[
'list_item' => esc_html__('Vendor Review', 'tpcore'),
],
[
'list_item' => esc_html__('Store Support', 'tpcore'),
],
[
'list_item' => esc_html__('Seller Verification', 'tpcore'),
],
[
'list_item' => esc_html__('Stripe & Msip', 'tpcore'),
],
],
'title_field' => '{{ list_item }}',
]
);
$this->end_controls_section();
// tp_btn_button_group
$this->start_controls_section(
'tp_btn_button_group',
[
'label' => esc_html__('Button', 'tpcore'),
]
);
$this->add_control(
'tp_button_show',
[
'label' => esc_html__('Show Button', 'tpcore'),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__('Show', 'tpcore'),
'label_off' => esc_html__('Hide', 'tpcore'),
'return_value' => 'yes',
'default' => 'yes',
]
);
$this->add_control(
'tp_btn_text',
[
'label' => esc_html__('Button Text', 'tpcore'),
'type' => Controls_Manager::TEXT,
'default' => esc_html__('Choose Plan', 'tpcore'),
'title' => esc_html__('Enter button text', 'tpcore'),
'label_block' => true,
'condition' => [
'tp_button_show' => 'yes'
],
]
);
$this->add_control(
'tp_btn_link_type',
[
'label' => esc_html__('Button Link Type', 'tpcore'),
'type' => Controls_Manager::SELECT,
'options' => [
'1' => 'Custom Link',
'2' => 'Internal Page',
],
'default' => '1',
'label_block' => true,
'condition' => [
'tp_button_show' => 'yes'
],
]
);
$this->add_control(
'tp_btn_link',
[
'label' => esc_html__('Button link', 'tpcore'),
'type' => Controls_Manager::URL,
'dynamic' => [
'active' => true,
],
'placeholder' => esc_html__('https://your-link.com', 'tpcore'),
'show_external' => false,
'default' => [
'url' => '#',
'is_external' => true,
'nofollow' => true,
'custom_attributes' => '',
],
'condition' => [
'tp_btn_link_type' => '1',
'tp_button_show' => 'yes'
],
'label_block' => true,
]
);
$this->add_control(
'tp_btn_page_link',
[
'label' => esc_html__('Select Button Page', 'tpcore'),
'type' => Controls_Manager::SELECT2,
'label_block' => true,
'options' => tp_get_all_pages(),
'condition' => [
'tp_btn_link_type' => '2',
'tp_button_show' => 'yes'
]
]
);
$this->end_controls_section();
}
private static function get_currency_symbol($symbol_name)
{
$symbols = [
'baht' => '฿',
'bdt' => '৳',
'dollar' => '$',
'euro' => '€',
'franc' => '₣',
'guilder' => 'ƒ',
'indian_rupee' => '₹',
'pound' => '£',
'peso' => '₱',
'peseta' => '₧',
'lira' => '₤',
'ruble' => '₽',
'shekel' => '₪',
'rupee' => '₨',
'real' => 'R$',
'krona' => 'kr',
'won' => '₩',
'yen' => '¥',
];
return isset($symbols[$symbol_name]) ? $symbols[$symbol_name] : '';
}
/**
* Render the widget output on the frontend.
*
* Written in PHP and used to generate the final HTML.
*
* @since 1.0.0
*
* @access protected
*/
protected function render()
{
$settings = $this->get_settings_for_display();
// Link
if ('2' == $settings['tp_btn_link_type']) {
$this->add_render_attribute('tp-button-arg', 'href', get_permalink($settings['tp_btn_page_link']));
$this->add_render_attribute('tp-button-arg', 'target', '_self');
$this->add_render_attribute('tp-button-arg', 'rel', 'nofollow');
$this->add_render_attribute('tp-button-arg', 'class', 'btn');
} else {
if (!empty($settings['tp_btn_link']['url'])) {
$this->add_link_attributes('tp-button-arg', $settings['tp_btn_link']);
$this->add_render_attribute('tp-button-arg', 'class', 'btn');
}
}
if ($settings['currency'] === 'custom') {
$currency = $settings['currency_custom'];
} else {
$currency = self::get_currency_symbol($settings['currency']);
}
?>
<div class="pricing-item <?php echo esc_attr( $settings['tg_is_active'] ) ?>">
<div class="pricing-icon">
<?php if ($settings['tg_icon_type'] !== 'image') : ?>
<?php if (!empty($settings['tg_icon']) || !empty($settings['tg_selected_icon']['value'])) : ?>
<?php tp_render_icon($settings, 'tg_icon', 'tg_selected_icon'); ?>
<?php endif; ?>
<?php else : ?>
<img src="<?php echo esc_url($settings['tg_svg']['url']); ?>" alt="img">
<?php endif; ?>
</div>
<div class="pricing-top">
<?php if (!empty($settings['main_title'])) : ?>
<h2 class="title"><?php echo tp_kses($settings['main_title']); ?></h2>
<?php endif; ?>
<p><?php echo tp_kses($settings['pricing_desc']); ?></p>
</div>
<div class="pricing-price">
<h2 class="price"><span><?php echo esc_html($currency); ?></span><?php echo tp_kses($settings['price']); ?><strong><?php echo tp_kses($settings['duration']); ?></strong></h2>
</div>
<div class="pricing-list">
<h4 class="title"><?php echo tp_kses($settings['list_title']) ?></h4>
<ul class="list-wrap">
<?php foreach ($settings['list_items'] as $item) : ?>
<li><i class="far fa-check"></i><?php echo esc_html($item['list_item']); ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php if (!empty($settings['tp_button_show'])) : ?>
<div class="pricing-btn">
<a <?php echo $this->get_render_attribute_string('tp-button-arg'); ?>><?php echo esc_html($settings['tp_btn_text']) ?></a>
</div>
<?php endif; ?>
</div>
<?php
}
}
$widgets_manager->register(new TP_Pricing());