| 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\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_Hero_Banner 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 'hero-banner';
}
/**
* Retrieve the widget title.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'Hero Banner', '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();
}
protected function register_controls_section() {
// layout Panel
$this->start_controls_section(
'tp_layout',
[
'label' => esc_html__('Design Layout', 'tp-core'),
]
);
$this->add_control(
'tp_design_style',
[
'label' => esc_html__('Select Layout', 'tp-core'),
'type' => Controls_Manager::SELECT,
'options' => [
'layout-1' => esc_html__('Layout 1', 'tp-core'),
],
'default' => 'layout-1',
]
);
$this->end_controls_section();
// tp_section_title
$this->start_controls_section(
'tp_section_title',
[
'label' => esc_html__('Title & Content', 'tp-core'),
]
);
$this->add_control(
'tp_section_title_show',
[
'label' => esc_html__( 'Section Title & Content', 'tp-core' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'tp-core' ),
'label_off' => esc_html__( 'Hide', 'tp-core' ),
'return_value' => 'yes',
'default' => 'yes',
]
);
$this->add_control(
'tp_subtitle',
[
'label' => esc_html__('Sub Title', 'tp-core'),
'description' => tp_get_allowed_html_desc( 'intermediate' ),
'type' => Controls_Manager::TEXT,
'default' => esc_html__('Sub Title', 'tp-core'),
'placeholder' => esc_html__('Type Heading Text', 'tp-core'),
'label_block' => true,
'condition' => [
'tp_design_style' => 'layout-2'
]
]
);
$this->add_control(
'tp_title',
[
'label' => esc_html__('Title', 'tp-core'),
'description' => tp_get_allowed_html_desc( 'intermediate' ),
'type' => Controls_Manager::TEXTAREA,
'default' => esc_html__('TP Title 1', 'tp-core'),
'placeholder' => esc_html__('Type Heading Text', 'tp-core'),
'label_block' => true,
]
);
$this->add_control(
'tp_title_2',
[
'label' => esc_html__('Title 2', 'tp-core'),
'description' => tp_get_allowed_html_desc( 'intermediate' ),
'type' => Controls_Manager::TEXTAREA,
'default' => esc_html__('TP Title 2', 'tp-core'),
'placeholder' => esc_html__('Type Heading Text', 'tp-core'),
'label_block' => true,
]
);
$this->add_control(
'tp_desctiption',
[
'label' => esc_html__('Description', 'tp-core'),
'description' => tp_get_allowed_html_desc( 'intermediate' ),
'type' => Controls_Manager::TEXTAREA,
'default' => esc_html__('TP section description here', 'tp-core'),
'placeholder' => esc_html__('Type section description here', 'tp-core'),
]
);
$this->add_responsive_control(
'tp_align',
[
'label' => esc_html__('Alignment', 'tp-core'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'text-left' => [
'title' => esc_html__('Left', 'tp-core'),
'icon' => 'eicon-text-align-left',
],
'text-center' => [
'title' => esc_html__('Center', 'tp-core'),
'icon' => 'eicon-text-align-center',
],
'text-right' => [
'title' => esc_html__('Right', 'tp-core'),
'icon' => 'eicon-text-align-right',
],
],
'default' => 'left',
'toggle' => false,
]
);
$this->end_controls_section();
$this->tp_button_render('banner', 'Button', 'layout-1');
// _tp_image
$this->start_controls_section(
'_tp_image',
[
'label' => esc_html__('Thumbnail', 'tp-core'),
'condition' => [
'tp_design_style' => 'layout-1'
]
]
);
$this->add_control(
'tp_image',
[
'label' => esc_html__( 'Choose Image', 'tp-core' ),
'type' => \Elementor\Controls_Manager::MEDIA,
'default' => [
'url' => \Elementor\Utils::get_placeholder_image_src(),
],
]
);
$this->add_group_control(
Group_Control_Image_Size::get_type(),
[
'name' => 'tp_image_size',
'default' => 'full',
'exclude' => [
'custom'
]
]
);
$this->end_controls_section();
}
// style_tab_content
protected function style_tab_content(){
$this->tp_section_style_controls('banner_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' ) :
?>
<?php else :
// thumbnail
if ( !empty($settings['tp_image']['url']) ) {
$tp_image = !empty($settings['tp_image']['id']) ? wp_get_attachment_image_url( $settings['tp_image']['id'], $settings['tp_image_size_size']) : $settings['tp_image']['url'];
$tp_image_alt = get_post_meta($settings["tp_image"]["id"], "_wp_attachment_image_alt", true);
}
// banner button Link
if ('2' == $settings['tp_banner_btn_link_type']) {
$this->add_render_attribute('tp_banner-button-arg', 'href', get_permalink($settings['tp_banner_btn_page_link']));
$this->add_render_attribute('tp_banner-button-arg', 'target', '_self');
$this->add_render_attribute('tp_banner-button-arg', 'rel', 'nofollow');
$this->add_render_attribute('tp_banner-button-arg', 'class', 'tp-btn');
} else {
if ( ! empty( $settings['tp_banner_btn_link']['url'] ) ) {
$this->add_link_attributes( 'tp_banner-button-arg', $settings['tp_banner_btn_link'] );
$this->add_render_attribute('tp_banner-button-arg', 'class', 'tp-btn');
}
}
$this->add_render_attribute('title_args', 'class', 'tp-hero-2__title');
?>
<section class="tp-slider-3__area p-relative fix">
<div class="tp-slider-3__right-bg tp-slider-3__height d-flex align-items-center p-relative">
<div class="tp-slider-3__slider-img" style="background-image: url(<?php echo esc_url($tp_image); ?>); ?>">
</div>
<div class="container">
<div class="tp-slider-3__shap p-relative">
<span class="tp-slider-3-shap-1 wow fadeInRightBig" data-wow-duration=".9s" data-wow-delay=".3s"></span>
<span class="tp-slider-3-shap-2 wow fadeInDownBig" data-wow-duration=".9s" data-wow-delay=".3s"></span>
</div>
<div class="row">
<div class="col-xl-11 offset-lg-1 col-lg-12 offset-md-1 col-md-12 col-12">
<div class="tp-slider-3__content p-relative z-index-1 pt-165">
<?php if ( !empty($settings['tp_title']) ) : ?>
<h2 class="tp-slider-3__title mb-35 wow fadeInRightBig" data-wow-duration=".9s"
data-wow-delay=".3s"><?php echo tp_kses( $settings['tp_title' ] ); ?> <br>
<span class="offset-lg-3 offset-md-3 wow fadeInRightBig" data-wow-duration=".9s"
data-wow-delay=".9s"> <?php echo tp_kses( $settings['tp_title_2' ] ); ?></span>
</h2>
<?php endif; ?>
<div class="tp-slider-3__btn-box d-flex align-items-center">
<?php if ( !empty($settings['tp_desctiption']) ) : ?>
<p class="wow fadeInLeftBig" data-wow-duration=".9s" data-wow-delay=".7s">We have a
<?php echo tp_kses( $settings['tp_desctiption'] ); ?></p>
<?php endif; ?>
<?php if ( !empty($settings['tp_banner_btn_text']) ) : ?>
<div class="wow fadeInRightBig"><a <?php echo $this->get_render_attribute_string( 'tp_banner-button-arg' ); ?>><?php echo tp_kses($settings['tp_banner_btn_text']); ?></a></div>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<?php endif;
}
}
$widgets_manager->register( new TP_Hero_Banner() );