navasena/wp-content/plugins/thinkai-plugin/elementor/icon_box.php

483 lines
14 KiB
PHP
Raw Normal View History

2024-07-31 13:12:38 +07:00
<?php namespace THINKAIPLUGIN\Element;
use Elementor\Controls_Manager;
use Elementor\Controls_Stack;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Border;
use Elementor\Repeater;
use Elementor\Widget_Base;
use Elementor\Utils;
use Elementor\Group_Control_Text_Shadow;
use \Elementor\Group_Control_Box_Shadow;
use \Elementor\Group_Control_Background;
use \Elementor\Group_Control_Image_Size;
use \Elementor\Group_Control_Text_Stroke;
use Elementor\Plugin;
/**
* Elementor button widget.
* Elementor widget that displays a button with the ability to control every
* aspect of the button design.
*
* @since 1.0.0
*/
class Icon_Box extends Widget_Base {
/**
* Get widget name.
* Retrieve button widget name.
*
* @since 1.0.0
* @access public
* @return string Widget name.
*/
public function get_name() {
return 'thinkai_icon_box';
}
/**
* Get widget title.
* Retrieve button widget title.
*
* @since 1.0.0
* @access public
* @return string Widget title.
*/
public function get_title() {
return esc_html__( 'Thinkai Icon Box', 'thinkai' );
}
/**
* Get widget icon.
* Retrieve button widget icon.
*
* @since 1.0.0
* @access public
* @return string Widget icon.
*/
public function get_icon() {
return 'eicon-icon-box';
}
/**
* Get widget categories.
* Retrieve the list of categories the button widget belongs to.
* Used to determine where to display the widget in the editor.
*
* @since 2.0.0
* @access public
* @return array Widget categories.
*/
public function get_categories() {
return [ 'thinkai' ];
}
/**
* Register button 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->start_controls_section(
'icon_box',
[
'label' => esc_html__( 'Thinkai Icon Box', 'thinkai' ),
]
);
$this->add_control(
'layout_control',
[
'label' => esc_html__( 'Layout Style', 'thinkai' ),
'label_block' => true,
'type' => Controls_Manager::SELECT,
'default' => '1',
'options' => array(
'1' => esc_html__( 'Style One ', 'thinkai'),
'2' => esc_html__( 'Style Two ', 'thinkai'),
'3' => esc_html__( 'Style Three ', 'thinkai'),
'4' => esc_html__( 'Style Four ', 'thinkai'),
),
]
);
//Shape Image
$this->add_control(
'bg_shape_image',
[
'label' => esc_html__( 'BG Shape Image', 'thinkai' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'condition' => [
'layout_control' => ['2','3']
]
]
);
//Shape Image V2
$this->add_control(
'bg_shape_image_v2',
[
'label' => esc_html__( 'BG Shape Image V2', 'thinkai' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'condition' => [
'layout_control' => '3',
]
]
);
//Icon
$this->add_control(
'icon',
[
'label' => esc_html__('Enter The icons', 'thinkai'),
'type' => \Elementor\Controls_Manager::ICONS,
'default' => [
'value' => 'icon-input',
'library' => 'solid',
],
'condition' => [
'layout_control' => ['1','2','3']
]
]
);
//Icon V2
$this->add_control(
'icon_v2',
[
'label' => esc_html__('Enter The icons', 'thinkai'),
'type' => \Elementor\Controls_Manager::ICONS,
'default' => [
'value' => 'icon-radio-waves',
'library' => 'solid',
],
'condition' => [
'layout_control' => ['1']
]
]
);
//Counter Value
$this->add_control(
'counter_value',
[
'label' => __( 'Counter Value', 'thinkai' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
],
'default' => esc_html__( '01', 'thinkai' ),
'condition' => [
'layout_control' => '4',
]
]
);
//Title
$this->add_control(
'title',
[
'label' => __( 'Title', 'thinkai' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
],
'placeholder' => __( 'Enter your Title', 'thinkai' ),
'condition' => [
'layout_control' => ['2','4']
]
]
);
//Text
$this->add_control(
'text',
[
'label' => __( 'Description', 'thinkai' ),
'type' => Controls_Manager::TEXTAREA,
'dynamic' => [
'active' => true,
],
'placeholder' => __( 'Enter your Desription', 'thinkai' ),
'condition' => [
'layout_control' => ['1','2','3','4']
]
]
);
//Contact Info Text
$this->add_control(
'contact_info_text',
[
'label' => __( 'Contact Info', 'thinkai' ),
'type' => Controls_Manager::TEXTAREA,
'dynamic' => [
'active' => true,
],
'placeholder' => __( 'Enter your Contact Info', 'thinkai' ),
'condition' => [
'layout_control' => '3',
]
]
);
//Button Title
$this->add_control(
'btn_title',
[
'label' => __( 'Button Title', 'thinkai' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
],
'default' => esc_html__( 'Read More', 'thinkai' ),
'condition' => [
'layout_control' => ['1']
]
]
);
$this->add_control(
'link_option',
[
'label' => esc_html__( 'Select link Option', 'thinkai' ),
'label_block' => true,
'type' => Controls_Manager::SELECT,
'default' => 'extranal',
'options' => array(
'extranal' => esc_html__( 'Extranal ', 'thinkai'),
'page' => esc_html__( 'Page ', 'thinkai'),
),
'condition' => [
'layout_control' => ['1','2','4']
]
]
);
$this->add_control(
'link',
[
'label' => __( 'External Link', 'thinkai' ),
'type' => Controls_Manager::URL,
'label_block' => true,
'placeholder' => __( 'https://your-link.com', 'thinkai' ),
'show_external' => true,
'default' => [
'url' => '',
'is_external' => true,
'nofollow' => true,
],
'condition' => [
'layout_control' => ['1','2','4'],
'link_option' => 'extranal',
]
]
);
$this->add_control(
'page_select',
[
'label' => esc_html__( 'Select Page', 'thinkai' ),
'label_block' => true,
'type' => Controls_Manager::SELECT2,
'default' => 'extranal',
'options' => thinkai_page_list(),
'condition' => [
'layout_control' => ['1','2','4'],
'link_option' => 'page',
]
]
);
$this->end_controls_section();
}
/**
* Render button 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();
$allowed_tags = wp_kses_allowed_html('post');
?>
<?php
if($settings['layout_control'] == '4') :
$icon = $settings['icon'];
$page = $settings['link_option'];
$page_select = $settings[ 'page_select' ];
$ext_url = $settings[ 'link' ];
if( $page == 'page' ){
$mount_link = get_page_link( $page_select );
}else{
$mount_link = $ext_url['url'];
$target = $ext_url['is_external'] ? ' target="_blank"' : '';
$nofollow = $ext_url['nofollow'] ? ' rel="nofollow"' : '';
}
?>
<div class="services-and-applications__single-box text-center">
<div class="static-content">
<div class="number-box">
<span><?php echo wp_kses($settings['counter_value'], true);?></span>
</div>
<div class="title-box">
<h4><?php echo wp_kses($settings['title'], true);?></h4>
</div>
<div class="btn-box">
<a href="<?php echo esc_url( $mount_link );?>" <?php if( $page == 'extranal' ) echo esc_attr( $target );?> <?php if( $page == 'extranal' ) echo esc_attr( $nofollow );?>><span class="icon-right-arrow1"></span></a>
</div>
</div>
<div class="overlay-content">
<h4><?php echo wp_kses($settings['title'], true);?></h4>
<p><?php echo wp_kses($settings['text'], true);?></p>
<div class="btn-box">
<a href="<?php echo esc_url( $mount_link );?>" <?php if( $page == 'extranal' ) echo esc_attr( $target );?> <?php if( $page == 'extranal' ) echo esc_attr( $nofollow );?>><span class="icon-right-arrow1"></span></a>
</div>
</div>
</div>
<?php
elseif($settings['layout_control'] == '3') :
$icon = $settings['icon'];
?>
<!--Start Contact Info Style2 -->
<section class="contact-info-style2 p-0 m-0">
<div class="contact-info-style2__single text-center">
<div class="shape-1">
<img src="<?php echo esc_url(wp_get_attachment_url($settings['bg_shape_image']['id'])); ?>" alt="<?php bloginfo( 'name' ); ?>">
</div>
<div class="shape-2">
<img src="<?php echo esc_url(wp_get_attachment_url($settings['bg_shape_image_v2']['id'])); ?>" alt="<?php bloginfo( 'name' ); ?>">
</div>
<?php if($icon){ ?>
<div class="icon-box">
<?php
$icon = str_replace( "icon ", "", $settings['icon']);
if( !empty( $icon ) ):?>
<?php \Elementor\Icons_Manager::render_icon( $icon ); ?>
<?php else:?>
<span class="icon-headset"></span>
<?php endif;?>
</div>
<?php } ?>
<div class="text-box">
<p><?php echo wp_kses($settings['text'], true);?></p>
</div>
<div class="phone-number-box">
<h3><?php echo wp_kses($settings['contact_info_text'], true);?></h3>
</div>
</div>
</section>
<?php
elseif($settings['layout_control'] == '2') :
$icon = $settings['icon'];
$page = $settings['link_option'];
$page_select = $settings[ 'page_select' ];
$ext_url = $settings[ 'link' ];
if( $page == 'page' ){
$mount_link = get_page_link( $page_select );
}else{
$mount_link = $ext_url['url'];
$target = $ext_url['is_external'] ? ' target="_blank"' : '';
$nofollow = $ext_url['nofollow'] ? ' rel="nofollow"' : '';
}
?>
<div class="features-style2__single text-center">
<div class="icon-box">
<?php if($settings['bg_shape_image']){ ?>
<div class="shape1 float-bob-y">
<img src="<?php echo esc_url(wp_get_attachment_url($settings['bg_shape_image']['id'])); ?>" alt="<?php bloginfo( 'name' ); ?>">
</div>
<?php } ?>
<?php if($icon){ ?>
<div class="inner">
<?php
$icon = str_replace( "icon ", "", $settings['icon']);
if( !empty( $icon ) ):?>
<?php \Elementor\Icons_Manager::render_icon( $icon ); ?>
<?php else:?>
<span class="icon-voice-detection"></span>
<?php endif;?>
</div>
<?php } ?>
</div>
<div class="content-box">
<h3><a href="<?php echo esc_url( $mount_link );?>" <?php if( $page == 'extranal' ) echo esc_attr( $target );?> <?php if( $page == 'extranal' ) echo esc_attr( $nofollow );?>><?php echo wp_kses($settings['title'], true);?></a></h3>
<p><?php echo wp_kses($settings['text'], true);?></p>
</div>
</div>
<?php
else:
$icon = $settings['icon'];
$icon_v2 = $settings['icon_v2'];
$page = $settings['link_option'];
$page_select = $settings[ 'page_select' ];
$ext_url = $settings[ 'link' ];
if( $page == 'page' ){
$mount_link = get_page_link( $page_select );
}else{
$mount_link = $ext_url['url'];
$target = $ext_url['is_external'] ? ' target="_blank"' : '';
$nofollow = $ext_url['nofollow'] ? ' rel="nofollow"' : '';
}
?>
<div class="about-style3__left-content">
<ul class="clearfix">
<li class="p-0 m-0">
<div class="bottom-content">
<div class="icon-box">
<?php if($icon){ ?>
<?php
$icon = str_replace( "icon ", "", $settings['icon']);
if( !empty( $icon ) ):?>
<?php \Elementor\Icons_Manager::render_icon( $icon ); ?>
<?php else:?>
<span class="icon-input"></span>
<?php endif;?>
<?php } ?>
<a href="<?php echo esc_url( $mount_link );?>" <?php if( $page == 'extranal' ) echo esc_attr( $target );?> <?php if( $page == 'extranal' ) echo esc_attr( $nofollow );?>>
<span class="icon-right-arrow1 icon2"></span>
</a>
<?php if($icon_v2){ ?>
<?php
$icon_v2 = str_replace( "icon ", "", $settings['icon_v2']);
if( !empty( $icon_v2 ) ):?>
<?php \Elementor\Icons_Manager::render_icon( $icon_v2 ); ?>
<?php else:?>
<span class="icon-radio-waves"></span>
<?php endif;?>
<?php } ?>
</div>
<div class="text-box">
<p><?php echo wp_kses($settings['text'], true);?></p>
<?php if($settings['btn_title']){ ?>
<div class="btn-box">
<a href="<?php echo esc_url( $mount_link );?>" <?php if( $page == 'extranal' ) echo esc_attr( $target );?> <?php if( $page == 'extranal' ) echo esc_attr( $nofollow );?>><?php echo wp_kses($settings['btn_title'], true);?></a>
</div>
<?php } ?>
</div>
</div>
</li>
</ul>
</div>
<?php endif; ?>
<?php
}
}