| Server IP : 172.67.71.254 / Your IP : 216.73.216.4 Web Server : nginx/1.27.1 System : Linux in-5 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64 User : arabianexpress ( 1872) PHP Version : 8.0.30 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /storage/v9321/leapdubai/public_html/wp-content/plugins/printx-core/include/elementor/ |
Upload File : |
<?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;
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_CTA 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-cta';
}
/**
* Retrieve the widget title.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'CTA', '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();
}
// controls file
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();
// title/content
$this->tp_section_title_render_controls('cta', 'Section Title', 'Sub Title', 'your title here', $default_description = 'Hic nesciunt galisum aut dolorem aperiam eum soluta quod ea cupiditate.', ['layout-1', 'layout-2']);
// button
$this->tp_button_render('cta', 'Button', ['layout-1', 'layout-2']);
// _tp_image
$this->start_controls_section(
'_tp_image',
[
'label' => esc_html__('Thumbnail', 'tpcore'),
]
);
$this->add_control(
'tp_image',
[
'label' => esc_html__( 'Choose Image', 'tpcore' ),
'type' => \Elementor\Controls_Manager::MEDIA,
'default' => [
'url' => \Elementor\Utils::get_placeholder_image_src(),
],
]
);
$this->add_control(
'tp_image2',
[
'label' => esc_html__( 'Choose Image 2', 'tpcore' ),
'type' => \Elementor\Controls_Manager::MEDIA,
'default' => [
'url' => \Elementor\Utils::get_placeholder_image_src(),
],
'condition' => [
'tp_design_style' => 'layout-2'
]
]
);
$this->add_group_control(
Group_Control_Image_Size::get_type(),
[
'name' => 'tp_image_size',
'default' => 'full',
'exclude' => [
'custom'
]
]
);
$this->end_controls_section();
// shape
$this->start_controls_section(
'tp_shape',
[
'label' => esc_html__( 'Shape Section', 'tpcore' ),
'condition' => [
'tp_design_style' => 'layout-2'
]
]
);
$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->add_control(
'tp_shape_image_1',
[
'label' => esc_html__( 'Choose Shape Image 1', 'tpcore' ),
'type' => \Elementor\Controls_Manager::MEDIA,
'default' => [
'url' => \Elementor\Utils::get_placeholder_image_src(),
],
'condition' => [
'tp_shape_switch' => 'yes',
]
]
);
$this->add_control(
'tp_shape_image_2',
[
'label' => esc_html__( 'Choose Shape Image 2', 'tpcore' ),
'type' => \Elementor\Controls_Manager::MEDIA,
'default' => [
'url' => \Elementor\Utils::get_placeholder_image_src(),
],
'condition' => [
'tp_shape_switch' => 'yes',
]
]
);
$this->add_control(
'tp_shape_image_3',
[
'label' => esc_html__( 'Choose Shape Image 3', 'tpcore' ),
'type' => \Elementor\Controls_Manager::MEDIA,
'default' => [
'url' => \Elementor\Utils::get_placeholder_image_src(),
],
'condition' => [
'tp_shape_switch' => 'yes',
]
]
);
$this->add_group_control(
Group_Control_Image_Size::get_type(),
[
'name' => 'shape_image_size', // // Usage: `{name}_size` and `{name}_custom_dimension`, in this case `thumbnail_size` and `thumbnail_custom_dimension`.
'exclude' => ['custom'],
'condition' => [
'tp_shape_switch' => 'yes',
],
'default' => 'full'
]
);
$this->end_controls_section();
}
// style_tab_content
protected function style_tab_content(){
$this->tp_section_style_controls('cta_section', 'Section Style', '.ele-section');
$this->tp_basic_style_controls('heading_subtitle', 'Subtitle', '.tp-el-subtitle', ['layout-1', 'layout-2']);
$this->tp_basic_style_controls('heading_title', 'Title', '.tp-el-title', ['layout-1', 'layout-2']);
$this->tp_basic_style_controls('heading_desc', 'Description', '.tp-el-content', ['layout-1', 'layout-2']);
$this->tp_text_link_controls_style('sec_btn', 'Button', '.tp-el-btn', ['layout-1', 'layout-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' ) :
// 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);
}
if ( !empty($settings['tp_image2']['url']) ) {
$tp_image2 = !empty($settings['tp_image2']['id']) ? wp_get_attachment_image_url( $settings['tp_image2']['id'], $settings['tp_image_size_size']) : $settings['tp_image2']['url'];
$tp_image_alt2 = get_post_meta($settings["tp_image2"]["id"], "_wp_attachment_image_alt", true);
}
// shape image
if ( !empty($settings['tp_shape_image_1']['url']) ) {
$tp_shape_image = !empty($settings['tp_shape_image_1']['id']) ? wp_get_attachment_image_url( $settings['tp_shape_image_1']['id'], $settings['shape_image_size_size']) : $settings['tp_shape_image_1']['url'];
$tp_shape_image_alt = get_post_meta($settings["tp_shape_image_1"]["id"], "_wp_attachment_image_alt", true);
}
if ( !empty($settings['tp_shape_image_2']['url']) ) {
$tp_shape_image2 = !empty($settings['tp_shape_image_2']['id']) ? wp_get_attachment_image_url( $settings['tp_shape_image_2']['id'], $settings['shape_image_size_size']) : $settings['tp_shape_image_2']['url'];
$tp_shape_image_alt2 = get_post_meta($settings["tp_shape_image_2"]["id"], "_wp_attachment_image_alt", true);
}
if ( !empty($settings['tp_shape_image_3']['url']) ) {
$tp_shape_image3 = !empty($settings['tp_shape_image_3']['id']) ? wp_get_attachment_image_url( $settings['tp_shape_image_3']['id'], $settings['shape_image_size_size']) : $settings['tp_shape_image_3']['url'];
$tp_shape_image_alt3 = get_post_meta($settings["tp_shape_image_3"]["id"], "_wp_attachment_image_alt", true);
}
// Link
if ('2' == $settings['tp_cta_btn_link_type']) {
$this->add_render_attribute('tp-button-arg', 'href', get_permalink($settings['tp_cta_btn_page_link']));
$this->add_render_attribute('tp-button-arg', 'target', '_self');
$this->add_render_attribute('tp-button-arg', 'rel', 'nofollow');
$this->add_render_attribute('tp-button-arg', 'class', 'tp-btn-lg tp-el-btn');
} else {
if ( ! empty( $settings['tp_cta_btn_link']['url'] ) ) {
$this->add_link_attributes( 'tp-button-arg', $settings['tp_cta_btn_link'] );
$this->add_render_attribute('tp-button-arg', 'class', 'tp-btn-lg tp-el-btn');
}
}
$this->add_render_attribute('title_args', 'class', 'tp-cta__title tp-el-title');
?>
<div class="tp-cta-4__area fix">
<div class="tp-cta-4__bg p-relative ele-section">
<?php if(!empty($tp_image)) : ?>
<div class="tp-cta-4__shape-1 d-none d-lg-block">
<img src="<?php echo esc_url($tp_image);?>" alt="<?php echo esc_attr($tp_image_alt); ?>">
</div>
<?php endif; ?>
<?php if(!empty($tp_image2)) : ?>
<div class="tp-cta-4__shape-2 d-none d-xl-block">
<img src="<?php echo esc_url($tp_image2); ?>" alt="<?php echo esc_attr($tp_image_alt2); ?>">
</div>
<?php endif; ?>
<?php if(!empty($tp_shape_image)) : ?>
<div class="tp-cta-4__shape-3 d-none d-lg-block">
<img src="<?php echo esc_url($tp_shape_image); ?>" alt="<?php echo esc_attr($tp_shape_image_alt); ?>">
</div>
<?php endif; ?>
<?php if(!empty($tp_shape_image2)) : ?>
<div class="tp-cta-4__shape-4 d-none d-lg-block">
<img src="<?php echo esc_url($tp_shape_image2); ?>" alt="<?php echo esc_attr($tp_shape_image_alt2); ?>">
</div>
<?php endif; ?>
<?php if(!empty($tp_shape_image3)) : ?>
<div class="tp-cta-4__shape-5">
<img src="<?php echo esc_url($tp_shape_image3); ?>" alt="<?php echo esc_attr($tp_shape_image_alt3); ?>">
</div>
<?php endif; ?>
<div class="container custom-container-3">
<div class="row">
<div class="col-xl-12">
<div class="tp-cta-4__content text-center z-index">
<?php if ( !empty($settings['tp_cta_sub_title']) ) : ?>
<span class="tp-text-white tp-el-subtitle"><?php echo tp_kses( $settings['tp_cta_sub_title'] ); ?></span>
<?php endif; ?>
<?php
if ( !empty($settings['tp_cta_title' ]) ) :
printf( '<%1$s %2$s>%3$s</%1$s>',
tag_escape( $settings['tp_cta_title_tag'] ),
$this->get_render_attribute_string( 'title_args' ),
tp_kses( $settings['tp_cta_title' ] )
);
endif;
?>
<?php if ( !empty($settings['tp_cta_description']) ) : ?>
<p class="tp-text-white tp-el-content"><?php echo tp_kses( $settings['tp_cta_description'] ); ?></p>
<?php endif; ?>
<?php if ( !empty($settings['tp_cta_btn_text']) ) : ?>
<a <?php echo $this->get_render_attribute_string( 'tp-button-arg' ); ?>><?php echo tp_kses($settings['tp_cta_btn_text']); ?></a>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?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);
}
// Link
if ('2' == $settings['tp_cta_btn_link_type']) {
$this->add_render_attribute('tp-button-arg', 'href', get_permalink($settings['tp_cta_btn_page_link']));
$this->add_render_attribute('tp-button-arg', 'target', '_self');
$this->add_render_attribute('tp-button-arg', 'rel', 'nofollow');
$this->add_render_attribute('tp-button-arg', 'class', 'tp-btn-lg tp-el-btn');
} else {
if ( ! empty( $settings['tp_cta_btn_link']['url'] ) ) {
$this->add_link_attributes( 'tp-button-arg', $settings['tp_cta_btn_link'] );
$this->add_render_attribute('tp-button-arg', 'class', 'tp-btn-lg tp-el-btn');
}
}
$this->add_render_attribute('title_args', 'class', 'tp-cta__title tp-el-title');
?>
<div class="tp-cta__area tp-cta__grey-bg fix ele-section">
<div class="container">
<div class="tp-cta__bg p-relative theme-bg ele-section">
<?php if(!empty($tp_image)) : ?>
<div class="tp-cta__thumb d-none d-xl-block">
<img src="<?php echo esc_url($tp_image); ?>" alt="<?php echo esc_attr($tp_image_alt); ?>">
</div>
<?php endif; ?>
<div class="row">
<div class="col-xl-12">
<div class="tp-cta__content text-center">
<?php if ( !empty($settings['tp_cta_sub_title']) ) : ?>
<span class="tp-section-subtitle tp-text-white tp-el-subtitle"><?php echo tp_kses( $settings['tp_cta_sub_title'] ); ?></span>
<?php endif; ?>
<?php
if ( !empty($settings['tp_cta_title' ]) ) :
printf( '<%1$s %2$s>%3$s</%1$s>',
tag_escape( $settings['tp_cta_title_tag'] ),
$this->get_render_attribute_string( 'title_args' ),
tp_kses( $settings['tp_cta_title' ] )
);
endif;
?>
<?php if ( !empty($settings['tp_cta_description']) ) : ?>
<p class="tp-text-white tp-el-content"><?php echo tp_kses( $settings['tp_cta_description'] ); ?></p>
<?php endif; ?>
<?php if ( !empty($settings['tp_cta_btn_text']) ) : ?>
<a <?php echo $this->get_render_attribute_string( 'tp-button-arg' ); ?>><?php echo tp_kses($settings['tp_cta_btn_text']); ?></a>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endif;
}
}
$widgets_manager->register( new TP_CTA() );