File: /home/dmstechonline/public_html/wp-content/plugins/xolio-core/include/elementor/progressbar.php
<?php
namespace TPCore\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use \Elementor\Group_Control_Background;
use \Elementor\Group_Control_Image_Size;
use \Elementor\Repeater;
use \Elementor\Utils;
use \Elementor\Control_Media;
if (!defined('ABSPATH')) exit; // Exit if accessed directly
/**
* Xolio Core
*
* Elementor widget for hello world.
*
* @since 1.0.0
*/
class TG_Progressbar extends Widget_Base
{
/**
* Retrieve the widget name.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget name.
*/
public function get_name()
{
return 'tg-progressbar';
}
/**
* Retrieve the widget title.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget title.
*/
public function get_title()
{
return __('Progressbar', '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()
{
// _tg_progressbar
$this->start_controls_section(
'_tg_progressbar',
[
'label' => esc_html__('Progressbar', 'tpcore'),
]
);
$repeater = new \Elementor\Repeater();
$repeater->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'),
],
]
);
$repeater->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')) {
$repeater->add_control(
'tg_icon2',
[
'show_label' => false,
'type' => Controls_Manager::ICON,
'label_block' => true,
'default' => 'fa fa-star',
'condition' => [
'tg_icon_type' => 'icon'
]
]
);
} else {
$repeater->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'
]
]
);
}
$repeater->add_control(
'progress_title',
[
'label' => esc_html__('Title', 'tpcore'),
'type' => Controls_Manager::TEXT,
'default' => esc_html__('App Design 85%', 'tpcore'),
'placeholder' => esc_html__('Type Title', 'tpcore'),
'label_block' => true,
]
);
$repeater->add_control(
'progress_percentage',
[
'label' => esc_html__('Percentage', 'tpcore'),
'type' => Controls_Manager::SLIDER,
'range' => [
'%' => [
'min' => 0,
'max' => 100,
],
],
'default' => [
'unit' => '%',
'size' => 50,
],
'selectors' => [
'{{WRAPPER}} .progress-bar' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'tg_progress_list',
[
'label' => esc_html__('Progress Lists', 'tpcore'),
'type' => \Elementor\Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'progress_title' => esc_html__('App Design 85%', 'tpcore'),
],
[
'progress_title' => esc_html__('Website Design 75%', 'tpcore'),
],
[
'progress_title' => esc_html__('Product Design 95%', 'tpcore'),
],
],
]
);
$this->end_controls_section();
// Style Tab
$this->start_controls_section(
'section_style',
[
'label' => esc_html__('Style', 'tpcore'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'text_transform',
[
'label' => esc_html__('Text Transform', 'tpcore'),
'type' => Controls_Manager::SELECT,
'default' => '',
'options' => [
'' => esc_html__('None', 'tpcore'),
'uppercase' => esc_html__('UPPERCASE', 'tpcore'),
'lowercase' => esc_html__('lowercase', 'tpcore'),
'capitalize' => esc_html__('Capitalize', 'tpcore'),
],
'selectors' => [
'{{WRAPPER}} .title' => 'text-transform: {{VALUE}};',
],
]
);
$this->end_controls_section();
}
/**
* 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();
?>
<div class="success-list">
<ul class="list-wrap">
<?php foreach ($settings['tg_progress_list'] as $item) : ?>
<li>
<div class="content">
<?php if ($item['tg_icon_type'] !== 'image') : ?>
<?php if (!empty($item['tg_icon']) || !empty($item['tg_selected_icon']['value'])) : ?>
<?php tp_render_icon($item, 'tg_icon', 'tg_selected_icon'); ?>
<?php endif; ?>
<?php else : ?>
<img src="<?php echo esc_url($item['tg_svg']['url']); ?>" alt="<?php echo esc_html__('Icon', 'tpcore') ?>">
<?php endif; ?>
<span><?php echo tp_kses($item['progress_title']) ?></span>
</div>
<div class="progress">
<div class="progress-bar" role="progressbar" style="width: <?php echo esc_attr($item['progress_percentage']['size']); ?>%;" aria-valuenow="<?php echo esc_attr($item['progress_percentage']['size']); ?>" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php
}
}
$widgets_manager->register(new TG_Progressbar());