D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
etb1lp46s9ed
/
www
/
lalpathamroha.site
/
wp-content
/
plugins
/
tp-core
/
include
/
elementor
/
Filename :
brand.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 TPCore\Elementor\Controls\Group_Control_TPBGGradient; if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly /** * Tp Core * * Elementor widget for hello world. * * @since 1.0.0 */ class TP_Brand 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 'brand'; } /** * Retrieve the widget title. * * @since 1.0.0 * * @access public * * @return string Widget title. */ public function get_title() { return __( 'Brand', '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(){ $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->end_controls_section(); $this->start_controls_section( 'tp_brand_section', [ 'label' => __( 'Brand Item', 'tpcore' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $repeater = new Repeater(); $repeater->add_control( 'tp_brand_image', [ 'type' => Controls_Manager::MEDIA, 'label' => __( 'Image', 'tpcore' ), 'default' => [ 'url' => Utils::get_placeholder_image_src(), ], 'dynamic' => [ 'active' => true, ] ] ); $repeater->add_control( 'tp_brand_url', [ 'type' => Controls_Manager::TEXT, 'label_block' => true, 'label' => __( 'URL', 'tpcore' ), 'default' => __( '#', 'tpcore' ), 'placeholder' => __( 'Type url here', 'tpcore' ), 'dynamic' => [ 'active' => true, ] ] ); $this->add_control( 'tp_brand_slides', [ 'show_label' => false, 'type' => Controls_Manager::REPEATER, 'fields' => $repeater->get_controls(), 'title_field' => esc_html__( 'Brand Item', 'tpcore' ), 'default' => [ [ 'tp_brand_image' => [ 'url' => Utils::get_placeholder_image_src(), ], ], [ 'tp_brand_image' => [ 'url' => Utils::get_placeholder_image_src(), ], ], ] ] ); $this->add_group_control( Group_Control_Image_Size::get_type(), [ 'name' => 'thumbnail', 'default' => 'medium_large', 'separator' => 'before', 'exclude' => [ 'custom' ] ] ); $this->end_controls_section(); } // style_tab_content protected function style_tab_content(){ $this->start_controls_section( 'tp_section_styling', [ 'label' => esc_html__('Section Style', 'imroz'), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( Group_Control_Background::get_type(), [ 'name' => 'tp_area_background', 'label' => esc_html__('Background', 'imroz'), 'types' => ['classic', 'gradient'], 'selector' => '{{WRAPPER}} .tp-bg-img', ] ); $this->add_group_control( Group_Control_TPBGGradient::get_type(), [ 'name' => 'tp_section_advs', 'label' => esc_html__('Color', 'imroz'), 'selector' => '{{WRAPPER}} .tp-section-style', ] ); $this->add_control( 'tp_section_bg_color', [ 'label' => esc_html__('Background Color', 'imroz'), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .tp-section-style' => 'background: {{VALUE}};', ], ] ); $this->add_responsive_control( 'tp_section_padding', [ 'label' => esc_html__('Padding', 'imroz'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => ['px', '%', 'em'], 'selectors' => [ '{{WRAPPER}} .tp-section-style' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], 'separator' => 'before', ] ); $this->add_responsive_control( 'tp_section_margin', [ 'label' => esc_html__('Margin', 'imroz'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => ['px', '%', 'em'], 'selectors' => [ '{{WRAPPER}} .tp-section-style' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], 'separator' => 'before', ] ); $this->end_controls_section(); $this->tp_basic_style_controls('section_subtitle', 'Section - Subtitle', '.tp-el-subtitle'); $this->tp_basic_style_controls('section_title', 'Section - Title', '.tp-el-title'); $this->tp_basic_style_controls('section_description', 'Section - Description', '.tp-el-content p'); } /** * 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' ) : $this->add_render_attribute('title_args', 'class', 'tp-title tp-el-title'); ?> <div class="brand-area"> <div class="container"> <div class="brand-border pt-60 pb-60"> <div class="swiper-container brand-active"> <div class="swiper-wrapper brand-items"> <?php foreach ($settings['tp_brand_slides'] as $item) : if ( !empty($item['tp_brand_image']['url']) ) { $tp_brand_image_url = !empty($item['tp_brand_image']['id']) ? wp_get_attachment_image_url( $item['tp_brand_image']['id'], $settings['thumbnail_size']) : $item['tp_brand_image']['url']; $tp_brand_image_alt = get_post_meta($item["tp_brand_image"]["id"], "_wp_attachment_image_alt", true); } ?> <div class="swiper-slide"> <?php if (!empty($item['tp_brand_url'])) : ?> <a href="<?php echo esc_url($item['tp_brand_url']); ?>"><img src="<?php echo esc_url($tp_brand_image_url); ?>" alt="<?php echo esc_url($tp_brand_image_alt); ?>"></a> <?php else : ?> <img src="<?php echo esc_url($tp_brand_image_url); ?>" alt="<?php echo esc_url($tp_brand_image_alt); ?>"> <?php endif; ?> </div> <?php endforeach; ?> </div> </div> </div> </div> </div> <?php else : $this->add_render_attribute('title_args', 'class', 'tp-title tp-el-title'); ?> <div class="brand-area"> <div class="container"> <div class="swiper-container brand-active"> <div class="swiper-wrapper brand-items"> <?php foreach ($settings['tp_brand_slides'] as $item) : if ( !empty($item['tp_brand_image']['url']) ) { $tp_brand_image_url = !empty($item['tp_brand_image']['id']) ? wp_get_attachment_image_url( $item['tp_brand_image']['id'], $settings['thumbnail_size']) : $item['tp_brand_image']['url']; $tp_brand_image_alt = get_post_meta($item["tp_brand_image"]["id"], "_wp_attachment_image_alt", true); } ?> <div class="swiper-slide"> <?php if (!empty($item['tp_brand_url'])) : ?> <a href="<?php echo esc_url($item['tp_brand_url']); ?>"><img src="<?php echo esc_url($tp_brand_image_url); ?>" alt="<?php echo esc_url($tp_brand_image_alt); ?>"></a> <?php else : ?> <img src="<?php echo esc_url($tp_brand_image_url); ?>" alt="<?php echo esc_url($tp_brand_image_alt); ?>"> <?php endif; ?> </div> <?php endforeach; ?> </div> </div> </div> </div> <?php endif; ?> <?php } } $widgets_manager->register( new TP_Brand() );