| Server IP : 69.72.244.102 / Your IP : 216.73.216.164 Web Server : LiteSpeed System : Linux s3434.fra1.stableserver.net 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64 User : konzalta ( 1271) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/thread-self/cwd/wp-content/plugins/portx-core/include/elementor/ |
Upload File : |
<?php
namespace TPCore\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use \Elementor\Group_Control_Image_Size;
use \Elementor\Group_Control_Background;
use \Elementor\Control_Media;
use \Elementor\Repeater;
use \Elementor\Group_Control_Typography;
use \Elementor\Group_Control_Box_Shadow;
use \Elementor\Utils;
use TPCore\Elementor\Controls\Group_Control_TPBGGradient;
use TPCore\Elementor\Controls\Group_Control_TPGradient;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Tp Core
*
* Elementor widget for hello world.
*
* @since 1.0.0
*/
class TP_Slider extends Widget_Base {
use \TPCore\Widgets\TPCoreElementFunctions;
/**
* Retrieve the widget name.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget name.
*/
public function get_name() {
return 'tp-slider';
}
/**
* Retrieve the widget title.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'Slider', 'tp-core' );
}
/**
* 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 [ 'tp-core' ];
}
/**
* 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(){
$this->register_controls_section();
$this->style_tab_content();
}
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] : '';
}
protected function register_controls_section() {
// layout Panel
$this->start_controls_section(
'tp_layout',
[
'label' => esc_html__('Design Layout', 'tpcore'),
]
);
$this->add_control(
'tp_design_style',
[
'label' => esc_html__('Select Layout', 'tpcore'),
'type' => Controls_Manager::SELECT,
'options' => [
'layout-1' => esc_html__('Layout 1', 'tpcore'),
'layout-2' => esc_html__('Layout 2', 'tpcore'),
],
'default' => 'layout-1',
]
);
$this->end_controls_section();
$this->start_controls_section(
'tp_main_slider',
[
'label' => esc_html__('Main Slider', 'tpcore'),
'description' => esc_html__( 'Control all the style settings from Style tab', 'tpcore' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
]
);
$repeater = new \Elementor\Repeater();
$repeater->add_control(
'repeater_condition',
[
'label' => __( 'Field condition', 'tpcore' ),
'type' => Controls_Manager::SELECT,
'options' => [
'style_1' => __( 'Style 1', 'tpcore' ),
'style_2' => __( 'Style 2', 'tpcore' ),
],
'default' => 'style_1',
'frontend_available' => true,
'style_transfer' => true,
]
);
$repeater->add_control(
'tp_slider_bg_image',
[
'label' => esc_html__('Upload Background Image', 'tpcore'),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'condition' => [
'repeater_condition' => ['style_1', 'style_2']
]
]
);
$repeater->add_control(
'tp_slider_sub_title',
[
'label' => esc_html__('Sub Title', 'tpcore'),
'description' => tp_get_allowed_html_desc( 'basic' ),
'type' => Controls_Manager::TEXT,
'default' => 'Subtitle',
'placeholder' => esc_html__('Type Before Heading Text', 'tpcore'),
'label_block' => true,
]
);
$repeater->add_control(
'tp_slider_title',
[
'label' => esc_html__('Title', 'tpcore'),
'description' => tp_get_allowed_html_desc( 'intermediate' ),
'type' => Controls_Manager::TEXTAREA,
'default' => esc_html__('Grow business.', 'tpcore'),
'placeholder' => esc_html__('Type Heading Text', 'tpcore'),
'label_block' => true,
]
);
$repeater->add_control(
'video_url',
[
'label' => __('Video url', 'tpcore'),
'type' => Controls_Manager::TEXT,
'default' => '#',
'dynamic' => [
'active' => true
]
]
);
$repeater->add_control(
'tp_btn_link_switcher',
[
'label' => esc_html__( 'Add Button link', 'tpcore' ),
'type' => \Elementor\Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'tpcore' ),
'label_off' => esc_html__( 'No', 'tpcore' ),
'return_value' => 'yes',
'default' => 'yes',
'separator' => 'before',
]
);
$repeater->add_control(
'tp_btn_btn_text',
[
'label' => esc_html__('Button Text', 'tpcore'),
'type' => Controls_Manager::TEXT,
'default' => esc_html__('Button Text', 'tpcore'),
'title' => esc_html__('Enter button text', 'tpcore'),
'label_block' => true,
'condition' => [
'tp_btn_link_switcher' => 'yes',
],
]
);
$repeater->add_control(
'tp_btn_link_type',
[
'label' => esc_html__( 'Button Link Type', 'tpcore' ),
'type' => \Elementor\Controls_Manager::SELECT,
'options' => [
'1' => 'Custom Link',
'2' => 'Internal Page',
],
'default' => '1',
'condition' => [
'tp_btn_link_switcher' => 'yes',
]
]
);
$repeater->add_control(
'tp_btn_link',
[
'label' => esc_html__( 'Button Link link', 'tpcore' ),
'type' => \Elementor\Controls_Manager::URL,
'dynamic' => [
'active' => true,
],
'placeholder' => esc_html__( 'https://your-link.com', 'tpcore' ),
'show_external' => true,
'default' => [
'url' => '#',
'is_external' => false,
'nofollow' => false,
],
'condition' => [
'tp_btn_link_type' => '1',
'tp_btn_link_switcher' => 'yes',
]
]
);
$repeater->add_control(
'tp_btn_page_link',
[
'label' => esc_html__( 'Select Button Link Page', 'tpcore' ),
'type' => \Elementor\Controls_Manager::SELECT2,
'label_block' => true,
'options' => tp_get_all_pages(),
'condition' => [
'tp_btn_link_type' => '2',
'tp_btn_link_switcher' => 'yes',
]
]
);
$this->add_control(
'slider_list',
[
'label' => esc_html__('Slider List', 'tpcore'),
'type' => \Elementor\Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'tp_slider_title' => esc_html__('Grow business.', 'tpcore')
],
[
'tp_slider_title' => esc_html__('Development.', 'tpcore')
],
[
'tp_slider_title' => esc_html__('Marketing.', 'tpcore')
],
],
'title_field' => '{{{ tp_slider_title }}}',
]
);
$this->add_group_control(
Group_Control_Image_Size::get_type(),
[
'name' => 'thumbnail', // // Usage: `{name}_size` and `{name}_custom_dimension`, in this case `thumbnail_size` and `thumbnail_custom_dimension`.
'exclude' => ['custom'],
// 'default' => 'tp-portfolio-thumb',
]
);
$this->end_controls_section();
// shape
$this->start_controls_section(
'tp_shape',
[
'label' => esc_html__( 'Shape Section', 'tpcore' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'tp_shape_switch',
[
'label' => esc_html__( 'Shape On/Off', 'tpcore' ),
'type' => \Elementor\Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'tpcore' ),
'label_off' => esc_html__( 'Hide', 'tpcore' ),
'return_value' => 'yes',
'default' => '0',
]
);
$this->end_controls_section();
}
protected function style_tab_content(){
$this->tp_section_style_controls('slider_section', 'Section Style', '.ele-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();
?>
<?php if ( $settings['tp_design_style'] == 'layout-2' ) :
?>
<div class="tpslider__area fix">
<div class="hero-wrapp">
<div class="hero-active-2 swiper-container">
<div class="swiper-wrapper">
<?php foreach ($settings['slider_list'] as $key => $item) :
$this->add_render_attribute('title_args', 'class', 'tp-hero-title tp-el-title ele-heading');
if ( !empty($item['tp_slider_bg_image']['url']) ) {
$tp_slider_bg_image_url = !empty($item['tp_slider_bg_image']['id']) ? wp_get_attachment_image_url( $item['tp_slider_bg_image']['id'], $settings['thumbnail_size']) : $item['tp_slider_bg_image']['url'];
$tp_slider_bg_image_alt = get_post_meta($item["tp_slider_bg_image"]["id"], "_wp_attachment_image_alt", true);
}
// btn Link
if ('2' == $item['tp_btn_link_type']) {
$link = get_permalink($item['tp_btn_page_link']);
$target = '_self';
$rel = 'nofollow';
} else {
$link = !empty($item['tp_btn_link']['url']) ? $item['tp_btn_link']['url'] : '';
$target = !empty($item['tp_btn_link']['is_external']) ? '_blank' : '';
$rel = !empty($item['tp_btn_link']['nofollow']) ? 'nofollow' : '';
}
?>
<div class="swiper-slide tpslider__item tpslider__height d-flex align-items-center p-relative fix"
style="background-image: url(<?php echo esc_url($tp_slider_bg_image_url); ?>">
<?php if(!empty($settings['tp_shape_switch'])) : ?>
<div class="tpslider__shap">
<img class="home-2-shap" src="<?php echo get_template_directory_uri(); ?>/assets/img/slider/slider-shap.png" alt="">
</div>
<div class="tpslider__shap-2 ">
<img class="home-2-shap-2" src="<?php echo get_template_directory_uri(); ?>/assets/img/slider/slider-shap2.png" alt="">
</div>
<?php endif; ?>
<div class="container">
<div class="row">
<div class="col-xl-7">
<div class="tpslider__wrap">
<div class="tpslider__content">
<?php if(!empty($item['tp_slider_sub_title'])) : ?>
<span class="tpslider__subtitle "><?php echo tp_kses($item['tp_slider_sub_title']); ?></span>
<?php endif; ?>
<?php if(!empty($item['tp_slider_title'])) : ?>
<h1 class="tpslider__title-2"><?php echo tp_kses($item['tp_slider_title']); ?></h1>
<?php endif; ?>
</div>
<div class="tpslider__info d-flex align-items-center">
<?php if(!empty($item['tp_btn_btn_text'])) : ?>
<div class="tpslider__btn-box mr-30">
<a class="thm-btn" href="<?php echo esc_url($link); ?>" target="<?php echo esc_attr($target); ?>" rel="<?php echo esc_attr($rel); ?>"><?php echo tp_kses($item['tp_btn_btn_text']); ?></a>
</div>
<?php endif; ?>
<?php if(!empty($item['video_url'])) : ?>
<div class="tpslider__video d-flex align-items-center">
<a href="<?php echo tp_kses($item['video_url']); ?>" class="popup-video">
<div class="video-one__video-icons icon mr-20">
<span class="fa fa-play"></span>
</div>
</a>
<div class="text ">
<h3>Watch Our <br>
Showcase</h3>
</div>
</div>
<?php endif; ?>
<?php if(!empty($settings['tp_shape_switch'])) : ?>
<div class="tpslider__shap-3 ml-30">
<img src="<?php echo get_template_directory_uri( ); ?>/assets/img/slider/slider-shap3.png" alt="">
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<div class="tpslider__dots text-end"></div>
</div>
</div>
</div>
<?php else:
?>
<!-- slider area start -->
<div class="tp-slider__area p-relative">
<div class="hero-active swiper-container">
<div class="swiper-wrapper">
<?php foreach ($settings['slider_list'] as $key => $item) :
$this->add_render_attribute('title_args', 'class', 'tp-hero-title tp-el-title ele-heading');
if ( !empty($item['tp_slider_bg_image']['url']) ) {
$tp_slider_bg_image_url = !empty($item['tp_slider_bg_image']['id']) ? wp_get_attachment_image_url( $item['tp_slider_bg_image']['id'], $settings['thumbnail_size']) : $item['tp_slider_bg_image']['url'];
$tp_slider_bg_image_alt = get_post_meta($item["tp_slider_bg_image"]["id"], "_wp_attachment_image_alt", true);
}
// btn Link
if ('2' == $item['tp_btn_link_type']) {
$link = get_permalink($item['tp_btn_page_link']);
$target = '_self';
$rel = 'nofollow';
} else {
$link = !empty($item['tp_btn_link']['url']) ? $item['tp_btn_link']['url'] : '';
$target = !empty($item['tp_btn_link']['is_external']) ? '_blank' : '';
$rel = !empty($item['tp_btn_link']['nofollow']) ? 'nofollow' : '';
}
?>
<div class=" swiper-slide tp-slider__item p-relative">
<div class="tp-slider-right-bg tp-slider__height d-flex align-items-center "
style="background-image: url(<?php echo esc_url($tp_slider_bg_image_url); ?>">
<div class="circal">
</div>
<div class="cargo-shipping text-end ">
<?php if(!empty($item['tp_slider_sub_title'])) : ?>
<div class="cargo-shipping-text">
<span><?php echo tp_kses($item['tp_slider_sub_title']); ?></span>
</div>
<?php endif; ?>
</div>
<div class="tp-slider__counter-number d-flex align-items-start">
<span>0<?php echo esc_html($key + 1); ?></span>
<div class="tp-slider__quote-icon">
<i class="flaticon-quotations"></i>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-xxl-9 col-xl-9">
<div class="tp-slider__content p-relative z-index-1">
<?php if(!empty($item['tp_slider_title'])) : ?>
<h2 class="tp-slider-title mb-35"><?php echo tp_kses($item['tp_slider_title']); ?>
</h2>
<?php endif; ?>
<?php if(!empty($item['tp_btn_btn_text'])) : ?>
<div class="tp-slide-btn-box">
<a class="thm-btn" href="<?php echo esc_url($link); ?>" target="<?php echo esc_attr($target); ?>" rel="<?php echo esc_attr($rel); ?>"><?php echo tp_kses($item['tp_btn_btn_text']); ?></a>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<div class="tp-slider__nav text-end">
<button class="hero-button-next"><i class="fa-regular fa-angle-left"></i></button>
<button class="hero-button-prev"><i class="fa-regular fa-angle-right"></i></button>
</div>
</div>
</div>
<!-- slider area end -->
<?php endif;
}
}
$widgets_manager->register( new TP_Slider() );