| 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_Background;
use \Elementor\Group_Control_Image_Size;
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_CTA_Two 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-two';
}
/**
* Retrieve the widget title.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'CTA Two', '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'),
],
'default' => 'layout-1',
]
);
$this->end_controls_section();
// Service group
$this->start_controls_section(
'tp_services',
[
'label' => esc_html__('Services List', '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_service_sub', [
'label' => esc_html__('Sub Titile', 'tpcore'),
'description' => tp_get_allowed_html_desc( 'basic' ),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => esc_html__('Support center 24/7', 'tpcore'),
]
);
$repeater->add_control(
'tp_service_title', [
'label' => esc_html__('Title', 'tpcore'),
'description' => tp_get_allowed_html_desc( 'basic' ),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => esc_html__('Main Title', 'tpcore'),
'label_block' => true,
]
);
$repeater->add_control(
'tp_services_link_switcher',
[
'label' => esc_html__( 'Add Services 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_services_link_type',
[
'label' => esc_html__( 'Service Link Type', 'tpcore' ),
'type' => \Elementor\Controls_Manager::SELECT,
'options' => [
'1' => 'Custom Link',
'2' => 'Internal Page',
],
'default' => '1',
'condition' => [
'tp_services_link_switcher' => 'yes'
]
]
);
$repeater->add_control(
'tp_link_text', [
'label' => esc_html__('Link Text', 'tpcore'),
'description' => tp_get_allowed_html_desc( 'basic' ),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => esc_html__('Link Text', 'tpcore'),
'label_block' => true,
'condition' => [
'tp_services_link_switcher' => 'yes',
]
]
);
$repeater->add_control(
'tp_services_link',
[
'label' => esc_html__( 'Service 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_services_link_type' => '1',
'tp_services_link_switcher' => 'yes',
]
]
);
$repeater->add_control(
'tp_services_page_link',
[
'label' => esc_html__( 'Select Service Link Page', 'tpcore' ),
'type' => \Elementor\Controls_Manager::SELECT2,
'label_block' => true,
'options' => tp_get_all_pages(),
'condition' => [
'tp_services_link_type' => '2',
'tp_services_link_switcher' => 'yes',
]
]
);
$repeater->add_control(
'tp_service_bg',
[
'label' => esc_html__('Upload Background Image', 'tpcore'),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
]
);
$this->add_control(
'tp_service_list',
[
'label' => esc_html__('Services - List', 'tpcore'),
'type' => \Elementor\Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'tp_service_title' => esc_html__('Business Stratagy', 'tpcore'),
],
[
'tp_service_title' => esc_html__('Website Development', 'tpcore')
],
[
'tp_service_title' => esc_html__('Marketing & Reporting', 'tpcore')
]
],
'title_field' => '{{{ tp_service_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-post-thumb',
]
);
$this->end_controls_section();
}
// style_tab_content
protected function style_tab_content(){
$this->tp_section_style_controls('services_section', 'Section - Style', '.tp-el-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:
// 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_image_2 = !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_alt_2 = get_post_meta($settings["tp_shape_image_2"]["id"], "_wp_attachment_image_alt", true);
}
$this->add_render_attribute('title_args', 'class', 'tp-section__title mb-10 wow fadeInUp');
$this->add_render_attribute('title_args', 'data-wow-duration', '.9s');
$this->add_render_attribute('title_args', 'data-wow-delay', '.4s');
?>
<div class="tpcontact-area p-relative fix">
<div class="tpcontact ">
<div class="container-fluid">
<div class="row">
<?php foreach ($settings['tp_service_list'] as $key => $item) :
// Link
if ('2' == $item['tp_services_link_type']) {
$link = get_permalink($item['tp_services_page_link']);
$target = '_self';
$rel = 'nofollow';
} else {
$link = !empty($item['tp_services_link']['url']) ? $item['tp_services_link']['url'] : '';
$target = !empty($item['tp_services_link']['is_external']) ? '_blank' : '';
$rel = !empty($item['tp_services_link']['nofollow']) ? 'nofollow' : '';
}
// bg image
if ( !empty($item['tp_service_bg']['url']) ) {
$tp_service_bg = !empty($item['tp_service_bg']['id']) ? wp_get_attachment_image_url( $item['tp_service_bg']['id'], $settings['thumbnail_size']) : $item['tp_service_bg']['url'];
$tp_service_bg_alt = get_post_meta($item["tp_service_bg"]["id"], "_wp_attachment_image_alt", true);
}
$item_class = ($key == '0') ? 'tpcontact__item' : 'tpcontact__item-right';
?>
<div class="col-xl-6 col-lg-6 col-md-6 col-12 p-0 ">
<div class="<?php echo esc_attr($item_class); ?> z-index-2 pt-90 pb-90 text-center text-lg-start tp-el-section"
data-background="<?php echo esc_url($tp_service_bg); ?>">
<?php if (!empty($item['tp_service_sub'])): ?>
<span class="wow fadeInUp " data-wow-duration=".9s" data-wow-delay=".3s"><?php echo tp_kses($item['tp_service_sub' ]); ?></span>
<?php endif; ?>
<?php if (!empty($item['tp_service_title'])): ?>
<h3 class="tpcontact-title-2 wow fadeInUp " data-wow-duration=".9s" data-wow-delay=".5s">
<?php echo tp_kses($item['tp_service_title' ]); ?></h3>
<?php endif; ?>
<?php if (!empty($item['tp_link_text'])): ?>
<div class="tpcontact__btn wow fadeInUp " data-wow-duration=".7s" data-wow-delay=".5s"">
<a class=" tp-btn" href="<?php echo esc_url($link); ?>"><?php echo esc_html($item['tp_link_text' ]); ?></a>
</div>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
<?php endif;
}
}
$widgets_manager->register( new TP_CTA_Two() );