402 lines
13 KiB
PHP
402 lines
13 KiB
PHP
|
<?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 Our_Cases 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_our_cases';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 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 Our Cases', 'thinkai' );
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Get widget icon.
|
||
|
* Retrieve button widget icon.
|
||
|
*
|
||
|
* @since 1.0.0
|
||
|
* @access public
|
||
|
* @return string Widget icon.
|
||
|
*/
|
||
|
public function get_icon() {
|
||
|
return 'eicon-gallery-grid';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 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(
|
||
|
'our_cases',
|
||
|
[
|
||
|
'label' => esc_html__( 'Thinkai Our Cases', 'thinkai' ),
|
||
|
]
|
||
|
);
|
||
|
|
||
|
//Layout
|
||
|
$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'),
|
||
|
),
|
||
|
]
|
||
|
);
|
||
|
|
||
|
//Banner Carousel Repeater
|
||
|
$repeater = new Repeater();
|
||
|
$repeater->add_control(
|
||
|
'author_img',
|
||
|
[
|
||
|
'label' => __( 'Author Image', 'thinkai' ),
|
||
|
'type' => Controls_Manager::MEDIA,
|
||
|
'default' => ['url' => Utils::get_placeholder_image_src(),],
|
||
|
]
|
||
|
);
|
||
|
$repeater->add_control(
|
||
|
'author_subtitle',
|
||
|
[
|
||
|
'label' => __( 'Author Sub Title', 'thinkai' ),
|
||
|
'type' => Controls_Manager::TEXT,
|
||
|
'label_block' => true,
|
||
|
'dynamic' => [
|
||
|
'active' => true,
|
||
|
],
|
||
|
'placeholder' => __( 'Enter your subtitle', 'thinkai' ),
|
||
|
]
|
||
|
);
|
||
|
$repeater->add_control(
|
||
|
'author_title',
|
||
|
[
|
||
|
'label' => __( 'Author Title', 'thinkai' ),
|
||
|
'type' => Controls_Manager::TEXT,
|
||
|
'label_block' => true,
|
||
|
'dynamic' => [
|
||
|
'active' => true,
|
||
|
],
|
||
|
'placeholder' => __( 'Enter your author title', 'thinkai' ),
|
||
|
]
|
||
|
);
|
||
|
//Icon
|
||
|
$repeater->add_control(
|
||
|
'icon',
|
||
|
[
|
||
|
'label' => esc_html__('Enter The icons', 'thinkai'),
|
||
|
'type' => \Elementor\Controls_Manager::ICONS,
|
||
|
'default' => [
|
||
|
'value' => 'icon-graduation',
|
||
|
'library' => 'solid',
|
||
|
],
|
||
|
]
|
||
|
);
|
||
|
$repeater->add_control(
|
||
|
'category_title',
|
||
|
[
|
||
|
'label' => __( 'Category Title', 'thinkai' ),
|
||
|
'type' => Controls_Manager::TEXT,
|
||
|
'label_block' => true,
|
||
|
'dynamic' => [
|
||
|
'active' => true,
|
||
|
],
|
||
|
'placeholder' => __( 'Enter your category title', 'thinkai' ),
|
||
|
]
|
||
|
);
|
||
|
$repeater->add_control(
|
||
|
'category_link',
|
||
|
[
|
||
|
'label' => __( 'Category 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,
|
||
|
],
|
||
|
]
|
||
|
);
|
||
|
//Button Title
|
||
|
$repeater->add_control(
|
||
|
'btn_title',
|
||
|
[
|
||
|
'label' => __( 'Button Title', 'thinkai' ),
|
||
|
'label_block' => true,
|
||
|
'type' => Controls_Manager::TEXT,
|
||
|
'dynamic' => [
|
||
|
'active' => true,
|
||
|
],
|
||
|
'default' => esc_html__( 'Read More', 'thinkai' ),
|
||
|
]
|
||
|
);
|
||
|
$repeater->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'),
|
||
|
),
|
||
|
]
|
||
|
);
|
||
|
$repeater->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' => [
|
||
|
'link_option' => 'extranal',
|
||
|
]
|
||
|
]
|
||
|
);
|
||
|
$repeater->add_control(
|
||
|
'page_select',
|
||
|
[
|
||
|
'label' => esc_html__( 'Select Page', 'thinkai' ),
|
||
|
'label_block' => true,
|
||
|
'type' => Controls_Manager::SELECT2,
|
||
|
'default' => 'extranal',
|
||
|
'options' => thinkai_page_list(),
|
||
|
'condition' => [
|
||
|
'link_option' => 'page',
|
||
|
]
|
||
|
]
|
||
|
);
|
||
|
$repeater->add_control(
|
||
|
'feature_img',
|
||
|
[
|
||
|
'label' => __( 'Feature Image', 'thinkai' ),
|
||
|
'type' => Controls_Manager::MEDIA,
|
||
|
'default' => ['url' => Utils::get_placeholder_image_src(),],
|
||
|
]
|
||
|
);
|
||
|
//Title
|
||
|
$repeater->add_control(
|
||
|
'title',
|
||
|
[
|
||
|
'label' => __( 'Title', 'thinkai' ),
|
||
|
'label_block' => true,
|
||
|
'type' => Controls_Manager::TEXTAREA,
|
||
|
'dynamic' => [
|
||
|
'active' => true,
|
||
|
],
|
||
|
'placeholder' => __( 'Enter your Title', 'thinkai' ),
|
||
|
]
|
||
|
);
|
||
|
$this->add_control(
|
||
|
'cases',
|
||
|
[
|
||
|
'label' => __('Add Case Item', 'thinkai'),
|
||
|
'type' => Controls_Manager::REPEATER,
|
||
|
'fields' => $repeater->get_controls(),
|
||
|
'title_field' => '{{{ author_title }}}',
|
||
|
'default' => [
|
||
|
[
|
||
|
'author_subtitle' => esc_html__( 'Voice by', 'thinkai' ),
|
||
|
'author_title' => esc_html__( 'Evelyn Scarlett', 'thinkai' ),
|
||
|
'category_title' => esc_html__( 'Education', 'thinkai' ),
|
||
|
'category_link' => esc_html__( '#', 'thinkai' ),
|
||
|
'btn_title' => esc_html__( 'Read More', 'thinkai' ),
|
||
|
'btn_link' => esc_html__( '#', 'thinkai' ),
|
||
|
'title' => esc_html__( 'Create Education Content now Using ThinkAi', 'thinkai' ),
|
||
|
],
|
||
|
[
|
||
|
'author_subtitle' => esc_html__( 'Voice by', 'thinkai' ),
|
||
|
'author_title' => esc_html__( 'Richard Frederick', 'thinkai' ),
|
||
|
'category_title' => esc_html__( 'Youtube Videos', 'thinkai' ),
|
||
|
'category_link' => esc_html__( '#', 'thinkai' ),
|
||
|
'btn_title' => esc_html__( 'Read More', 'thinkai' ),
|
||
|
'btn_link' => esc_html__( '#', 'thinkai' ),
|
||
|
'title' => esc_html__( 'Simplify the Narration Process of your YouTube Videos', 'thinkai' ),
|
||
|
],
|
||
|
[
|
||
|
'author_subtitle' => esc_html__( 'Voice by', 'thinkai' ),
|
||
|
'author_title' => esc_html__( 'Rowan Grayson', 'thinkai' ),
|
||
|
'category_title' => esc_html__( 'Advertisement', 'thinkai' ),
|
||
|
'category_link' => esc_html__( '#', 'thinkai' ),
|
||
|
'btn_title' => esc_html__( 'Read More', 'thinkai' ),
|
||
|
'btn_link' => esc_html__( '#', 'thinkai' ),
|
||
|
'title' => esc_html__( 'Create Engaging & Persuasive Advertisements', 'thinkai' ),
|
||
|
],
|
||
|
],
|
||
|
]
|
||
|
);
|
||
|
$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'] == '3') :?>
|
||
|
|
||
|
|
||
|
<?php elseif($settings['layout_control'] == '2') :?>
|
||
|
|
||
|
|
||
|
<?php else: ?>
|
||
|
|
||
|
<!--Start Cases Style1 -->
|
||
|
<section class="cases-style1 p-0 m-0">
|
||
|
<div class="container">
|
||
|
<ul class="row">
|
||
|
<?php
|
||
|
foreach($settings['cases'] as $key => $items):
|
||
|
$icon = $items['icon'];
|
||
|
$page = $items['link_option'];
|
||
|
$page_select = $items[ 'page_select' ];
|
||
|
$ext_url = $items[ '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"' : '';
|
||
|
}
|
||
|
?>
|
||
|
<!--Start Cases Style1 Single-->
|
||
|
<li class="col-xl-4 col-lg-4">
|
||
|
<div class="cases-style1__single">
|
||
|
<div class="cases-style1__single-inner">
|
||
|
<div class="cases-style1__single-top">
|
||
|
<div class="author-box">
|
||
|
<?php if($items['author_img']){ ?>
|
||
|
<div class="img-box">
|
||
|
<img src="<?php echo esc_url(wp_get_attachment_url($items['author_img']['id'])); ?>" alt="<?php bloginfo( 'name' ); ?>">
|
||
|
</div>
|
||
|
<?php } ?>
|
||
|
<div class="text-box">
|
||
|
<p><?php echo wp_kses($items['author_subtitle'], true);?></p>
|
||
|
<h4><?php echo wp_kses($items['author_title'], true);?></h4>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="category-box">
|
||
|
<div class="text">
|
||
|
<p>
|
||
|
<?php if($icon){ ?>
|
||
|
<?php
|
||
|
$icon = str_replace( "icon ", "", $items['icon']);
|
||
|
if( !empty( $icon ) ):?>
|
||
|
<?php \Elementor\Icons_Manager::render_icon( $icon ); ?>
|
||
|
<?php else:?>
|
||
|
<span class="icon-graduation"></span>
|
||
|
<?php endif; }?>
|
||
|
<a href="<?php echo esc_url($items['category_link']['url']);?>"><?php echo wp_kses($items['category_title'], true);?></a>
|
||
|
</p>
|
||
|
</div>
|
||
|
<?php ?>
|
||
|
|
||
|
<?php if($items['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 );?>>
|
||
|
<i class="icon-arrow-upper-right"></i>
|
||
|
<span class="txt"><?php echo wp_kses($items['btn_title'], true);?></span>
|
||
|
</a>
|
||
|
</div>
|
||
|
<?php } ?>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="cases-style1__single-img">
|
||
|
<img src="<?php echo esc_url(wp_get_attachment_url($items['feature_img']['id'])); ?>" alt="<?php bloginfo( 'name' ); ?>">
|
||
|
</div>
|
||
|
<div class="cases-style1__single-title">
|
||
|
<h2>
|
||
|
<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($items['title'], true);?></a>
|
||
|
</h2>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</li>
|
||
|
<!--End Cases Style1 Single-->
|
||
|
<?php endforeach; ?>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</section>
|
||
|
<!--End Cases Style1 -->
|
||
|
|
||
|
<?php endif; ?>
|
||
|
|
||
|
<?php
|
||
|
}
|
||
|
}
|