D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
etb1lp46s9ed
/
www
/
lalpathamroha.site
/
wp-content
/
plugins
/
tp-core
/
include
/
elementor
/
Filename :
slider.php
back
Copy
<?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 /** * Tp Core * * Elementor widget for hello world. * * @since 1.0.0 */ class TP_Main_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 __( 'Main Slider', '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' ]; } protected static function get_profile_names() { return [ 'apple' => esc_html__('Apple', 'tp-core'), 'behance' => esc_html__('Behance', 'tp-core'), 'bitbucket' => esc_html__('BitBucket', 'tp-core'), 'codepen' => esc_html__('CodePen', 'tp-core'), 'delicious' => esc_html__('Delicious', 'tp-core'), 'deviantart' => esc_html__('DeviantArt', 'tp-core'), 'digg' => esc_html__('Digg', 'tp-core'), 'dribbble' => esc_html__('Dribbble', 'tp-core'), 'email' => esc_html__('Email', 'tp-core'), 'facebook' => esc_html__('Facebook', 'tp-core'), 'flickr' => esc_html__('Flicker', 'tp-core'), 'foursquare' => esc_html__('FourSquare', 'tp-core'), 'github' => esc_html__('Github', 'tp-core'), 'houzz' => esc_html__('Houzz', 'tp-core'), 'instagram' => esc_html__('Instagram', 'tp-core'), 'jsfiddle' => esc_html__('JS Fiddle', 'tp-core'), 'linkedin' => esc_html__('LinkedIn', 'tp-core'), 'medium' => esc_html__('Medium', 'tp-core'), 'pinterest' => esc_html__('Pinterest', 'tp-core'), 'product-hunt' => esc_html__('Product Hunt', 'tp-core'), 'reddit' => esc_html__('Reddit', 'tp-core'), 'slideshare' => esc_html__('Slide Share', 'tp-core'), 'snapchat' => esc_html__('Snapchat', 'tp-core'), 'soundcloud' => esc_html__('SoundCloud', 'tp-core'), 'spotify' => esc_html__('Spotify', 'tp-core'), 'stack-overflow' => esc_html__('StackOverflow', 'tp-core'), 'tripadvisor' => esc_html__('TripAdvisor', 'tp-core'), 'tumblr' => esc_html__('Tumblr', 'tp-core'), 'twitch' => esc_html__('Twitch', 'tp-core'), 'twitter' => esc_html__('Twitter', 'tp-core'), 'vimeo' => esc_html__('Vimeo', 'tp-core'), 'vk' => esc_html__('VK', 'tp-core'), 'website' => esc_html__('Website', 'tp-core'), 'whatsapp' => esc_html__('WhatsApp', 'tp-core'), 'wordpress' => esc_html__('WordPress', 'tp-core'), 'xing' => esc_html__('Xing', 'tp-core'), 'yelp' => esc_html__('Yelp', 'tp-core'), 'youtube' => esc_html__('YouTube', '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(); } 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->add_control( 'hero_search_switch', [ 'label' => __('Hero Search Show/Hide', 'bdevs-element'), 'type' => Controls_Manager::SWITCHER, 'label_on' => __('Show', 'bdevs-element'), 'label_off' => __('Hide', 'bdevs-element'), 'return_value' => 'yes', 'default' => 'yes', 'condition' => [ 'tp_design_style' => 'layout-2', ], 'style_transfer' => true, ] ); $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( 'tp_slider_image', [ 'label' => esc_html__('Upload Image', 'tpcore'), 'type' => Controls_Manager::MEDIA, 'default' => [ 'url' => Utils::get_placeholder_image_src(), ] ] ); $repeater->add_control( 'tp_slider_image_2', [ 'label' => esc_html__('Upload Image 2', 'tpcore'), 'type' => Controls_Manager::MEDIA, 'default' => [ 'url' => Utils::get_placeholder_image_src(), ] ] ); $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' => '', '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::TEXT, 'default' => esc_html__('Grow business.', 'tpcore'), 'placeholder' => esc_html__('Type Heading Text', 'tpcore'), 'label_block' => true, ] ); $repeater->add_control( 'tp_slider_title_tag', [ 'label' => esc_html__('Title HTML Tag', 'tpcore'), 'type' => Controls_Manager::CHOOSE, 'options' => [ 'h1' => [ 'title' => esc_html__('H1', 'tpcore'), 'icon' => 'eicon-editor-h1' ], 'h2' => [ 'title' => esc_html__('H2', 'tpcore'), 'icon' => 'eicon-editor-h2' ], 'h3' => [ 'title' => esc_html__('H3', 'tpcore'), 'icon' => 'eicon-editor-h3' ], 'h4' => [ 'title' => esc_html__('H4', 'tpcore'), 'icon' => 'eicon-editor-h4' ], 'h5' => [ 'title' => esc_html__('H5', 'tpcore'), 'icon' => 'eicon-editor-h5' ], 'h6' => [ 'title' => esc_html__('H6', 'tpcore'), 'icon' => 'eicon-editor-h6' ] ], 'default' => 'h2', 'toggle' => false, ] ); $repeater->add_control( 'tp_slider_description', [ 'label' => esc_html__('Description', 'tpcore'), 'description' => tp_get_allowed_html_desc( 'intermediate' ), 'type' => Controls_Manager::TEXTAREA, 'default' => esc_html__('There are many variations of passages of Lorem Ipsum available but the majority have suffered alteration.', 'tpcore'), 'placeholder' => esc_html__('Type section description here', 'tpcore'), ] ); $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', ] ] ); // link 2 $repeater->add_control( 'tp_btn_link_switcher_2', [ 'label' => esc_html__( 'Add Button link 2', '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', 'condition' => [ 'ddd' => 'yes' ], ] ); $repeater->add_control( 'tp_btn_btn_text_2', [ 'label' => esc_html__('Button Text 2', 'tpcore'), 'type' => Controls_Manager::TEXT, 'default' => esc_html__('Button Text 2', 'tpcore'), 'title' => esc_html__('Enter button text', 'tpcore'), 'label_block' => true, 'condition' => [ 'tp_btn_link_switcher_2' => 'yes' ], ] ); $repeater->add_control( 'tp_btn_link_type_2', [ 'label' => esc_html__( 'Button Link Type 2', 'tpcore' ), 'type' => \Elementor\Controls_Manager::SELECT, 'options' => [ '1' => 'Custom Link', '2' => 'Internal Page', ], 'default' => '1', 'condition' => [ 'tp_btn_link_switcher_2' => 'yes' ] ] ); $repeater->add_control( 'tp_btn_link_2', [ 'label' => esc_html__( 'Button Link link 2', '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_2' => '1', 'tp_btn_link_switcher_2' => 'yes', ] ] ); $repeater->add_control( 'tp_btn_page_link_2', [ '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' => '2', 'tp_btn_link_switcher_2' => '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(); $this->start_controls_section( 'tp_main_slider_social', [ 'label' => esc_html__('Slider Social', 'tpcore'), 'description' => esc_html__( 'Control all the style settings from Style tab', 'tpcore' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $repeater = new \Elementor\Repeater(); if (tp_is_elementor_version('<', '2.6.0')) { $repeater->add_control( 'tp_slider_icon', [ 'show_label' => false, 'type' => Controls_Manager::ICON, 'label_block' => true, 'default' => 'fa-solid fa-check', ] ); } else { $repeater->add_control( 'tp_slider_selected_icon', [ 'show_label' => false, 'type' => Controls_Manager::ICONS, 'fa4compatibility' => 'icon', 'label_block' => true, 'default' => [ 'value' => 'fas fa-star', 'library' => 'solid', ], ] ); } $repeater->add_control( 'tp_slider_social_name', [ 'label' => esc_html__('Profile Name', 'tp-core'), 'type' => Controls_Manager::SELECT2, 'label_block' => true, 'select2options' => [ 'allowClear' => false, ], 'options' => self::get_profile_names() ] ); $repeater->add_control( 'tp_slider_social_link', [ 'label' => esc_html__('Profile Link', 'tp-core'), 'placeholder' => esc_html__('Add your profile link', 'tp-core'), 'type' => Controls_Manager::URL, 'label_block' => true, 'autocomplete' => false, 'show_external' => false, 'dynamic' => [ 'active' => true, ] ] ); $this->add_control( 'slider_social_list', [ 'label' => esc_html__('Slider Social List', 'tpcore'), 'type' => \Elementor\Controls_Manager::REPEATER, 'fields' => $repeater->get_controls(), 'default' => [ [ 'tp_slider_social_name' => esc_html__('Facebook', 'tpcore') ], [ 'tp_slider_social_name' => esc_html__('YouTube', 'tpcore') ], [ 'tp_slider_social_name' => esc_html__('Twitter', 'tpcore') ], ], 'title_field' => '{{{ tp_slider_social_name }}}', ] ); $this->end_controls_section(); } // style_tab_content protected function style_tab_content(){ $this->tp_section_style_controls('slider_section', 'Section Style', '.ele-section'); $this->tp_basic_style_controls('slider_sub_title', 'Subtitle Style', '.ele-subtitle'); $this->tp_basic_style_controls('slider_title', 'Title Style', '.ele-title'); $this->tp_basic_style_controls('slider_content', 'Content Style', '.ele-content'); $this->tp_link_controls_style_2('button', 'Button Style', '.ele-button'); $this->tp_link_controls_style_2('button_2', 'Button 2 Style', '.ele-button-2'); } /** * 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' ): ?> <?php else: ?> <section class="slider-area slider-tp-top ele-section"> <div class="slider-social"> <div class="container"> <div class="row"> <div class="col-lg-6 col-md-10 d-none d-md-block"> <div class="slider-content__social"> <?php foreach ($settings['slider_social_list'] as $social_item) : ?> <a class="facebook-2" href="<?php echo esc_url( $social_item['tp_slider_social_link']['url'] ); ?>"> <?php if (!empty($social_item['tp_slider_icon']) || !empty($social_item['tp_slider_selected_icon']['value'])) : ?> <?php tp_render_icon($social_item, 'tp_slider_icon', 'tp_slider_selected_icon'); ?> <?php endif; ?> <?php echo tp_kses( $social_item['tp_slider_social_name'] ); ?> </a> <?php endforeach; ?> </div> </div> <div class="col-lg-6 col-md-2 col-12 d-none d-md-block"> <div class="slider-content__arrow d-flex align-items-center"> <div class="slider-p"><i class="fa-regular fa-arrow-left"></i></div> <div class="slider-n"><i class="fa-regular fa-arrow-right"></i></div> </div> </div> </div> </div> </div> <div class="swiper-container tp-slider slider-active"> <div class="swiper-wrapper"> <?php foreach ($settings['slider_list'] as $item) : $this->add_render_attribute('title_args', 'class', 'slider-content__title mb-45 ele-title'); if ( !empty($item['tp_slider_image']['url']) ) { $tp_slider_image_url = !empty($item['tp_slider_image']['id']) ? wp_get_attachment_image_url( $item['tp_slider_image']['id'], $settings['thumbnail_size']) : $item['tp_slider_image']['url']; $tp_slider_image_alt = get_post_meta($item["tp_slider_image"]["id"], "_wp_attachment_image_alt", true); } if ( !empty($item['tp_slider_image_2']['url']) ) { $tp_slider_image_2_url = !empty($item['tp_slider_image_2']['id']) ? wp_get_attachment_image_url( $item['tp_slider_image_2']['id'], $settings['thumbnail_size']) : $item['tp_slider_image_2']['url']; $tp_slider_image_2_alt = get_post_meta($item["tp_slider_image_2"]["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' : ''; } // btn 2 Link if ('2' == $item['tp_btn_link_type_2']) { $link2 = get_permalink($item['tp_btn_page_link_2']); $target2 = '_self'; $rel2 = 'nofollow'; } else { $link2 = !empty($item['tp_btn_link_2']['url']) ? $item['tp_btn_link_2']['url'] : ''; $target2 = !empty($item['tp_btn_link_2']['is_external']) ? '_blank' : ''; $rel2 = !empty($item['tp_btn_link_2']['nofollow']) ? 'nofollow' : ''; } ?> <div class="swiper-slide bg-white ele-section"> <div class="container"> <div class="row align-items-center"> <div class="col-lg-6 col-md-12 col-12 order-2 order-lg-1"> <div class="slider-content pt-60"> <?php if (!empty($item['tp_slider_sub_title'])) : ?> <span class="tp-el-subtitle ele-subtitle"><?php echo tp_kses( $item['tp_slider_sub_title'] ); ?></span> <?php endif; ?> <?php if ($item['tp_slider_title_tag']) : printf('<%1$s %2$s>%3$s</%1$s>', tag_escape($item['tp_slider_title_tag']), $this->get_render_attribute_string('title_args'), tp_kses($item['tp_slider_title']) ); endif; ?> <?php if (!empty($item['tp_slider_description'])) : ?> <p class="ele-content"><?php echo tp_kses( $item['tp_slider_description'] ); ?></p> <?php endif; ?> <div class="slider-content__btn mb-165"> <?php if (!empty($link)) : ?> <a target="<?php echo esc_attr($target); ?>" rel="<?php echo esc_attr($rel); ?>" href="<?php echo esc_url($link); ?>" class="tp-btn ele-button"> <?php echo tp_kses($item['tp_btn_btn_text']); ?> </a> <a target="<?php echo esc_attr($target2); ?>" rel="<?php echo esc_attr($rel2); ?>" href="<?php echo esc_url($link2); ?>" class="tp-btn-second ml-25 ele-button-2"> <?php echo tp_kses($item['tp_btn_btn_text_2']); ?> </a> <?php endif; ?> </div> </div> </div> <div class="col-lg-6 col-md-6 col-12 order-1 order-lg-2"> <div class="slider-content__bg"> <?php if (!empty($tp_slider_image_url)) : ?> <img src="<?php echo esc_url($tp_slider_image_url); ?>" alt="<?php echo esc_attr($tp_slider_image_alt); ?>"> <?php endif; ?> </div> <div class="slider-content__shape d-none d-md-block"> <?php if (!empty($tp_slider_image_2_url)) : ?> <img src="<?php echo esc_url($tp_slider_image_2_url); ?>" alt="<?php echo esc_attr($tp_slider_image_2_alt); ?>"> <?php endif; ?> </div> </div> </div> </div> </div> <?php endforeach; ?> </div> </div> </section> <?php endif; } } $widgets_manager->register( new TP_Main_Slider() );