370 lines
13 KiB
PHP
370 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 Project_Masonry 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_project_masonry';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 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 Project Masonry', 'thinkai' );
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Get widget icon.
|
||
|
* Retrieve button widget icon.
|
||
|
*
|
||
|
* @since 1.0.0
|
||
|
* @access public
|
||
|
* @return string Widget icon.
|
||
|
*/
|
||
|
public function get_icon() {
|
||
|
return 'eicon-banner';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 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(
|
||
|
'project_masonry',
|
||
|
[
|
||
|
'label' => esc_html__( 'Thinkai Project Masonry', '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'),
|
||
|
),
|
||
|
]
|
||
|
);
|
||
|
|
||
|
//Shape Image
|
||
|
$this->add_control(
|
||
|
'shape_image',
|
||
|
[
|
||
|
'label' => esc_html__( 'BG Shape Image', 'thinkai' ),
|
||
|
'type' => Controls_Manager::MEDIA,
|
||
|
'default' => [
|
||
|
'url' => Utils::get_placeholder_image_src(),
|
||
|
],
|
||
|
'condition' => [
|
||
|
'layout_control' => '2',
|
||
|
]
|
||
|
]
|
||
|
);
|
||
|
$this->add_control(
|
||
|
'subtitle',
|
||
|
[
|
||
|
'label' => __( 'Sub Title', 'thinkai' ),
|
||
|
'label_block' => true,
|
||
|
'type' => Controls_Manager::TEXT,
|
||
|
'dynamic' => [
|
||
|
'active' => true,
|
||
|
],
|
||
|
'default' => esc_html__( '[ CASE STUDIES ]', 'thinkai' ),
|
||
|
'condition' => [
|
||
|
'layout_control' => '2',
|
||
|
]
|
||
|
]
|
||
|
);
|
||
|
$this->add_control(
|
||
|
'title',
|
||
|
[
|
||
|
'label' => __( 'Title', 'thinkai' ),
|
||
|
'label_block' => true,
|
||
|
'type' => Controls_Manager::TEXT,
|
||
|
'dynamic' => [
|
||
|
'active' => true,
|
||
|
],
|
||
|
'default' => esc_html__( 'Explore latest cases', 'thinkai' ),
|
||
|
'condition' => [
|
||
|
'layout_control' => '2',
|
||
|
]
|
||
|
]
|
||
|
);
|
||
|
|
||
|
$this->add_control(
|
||
|
'query_number',
|
||
|
[
|
||
|
'label' => esc_html__( 'Number of post', 'thinkai' ),
|
||
|
'type' => Controls_Manager::NUMBER,
|
||
|
'default' => 3,
|
||
|
'min' => 1,
|
||
|
'max' => 100,
|
||
|
'step' => 1,
|
||
|
]
|
||
|
);
|
||
|
$this->add_control(
|
||
|
'query_orderby',
|
||
|
[
|
||
|
'label' => esc_html__( 'Order By', 'thinkai' ),
|
||
|
'label_block' => true,
|
||
|
'type' => Controls_Manager::SELECT,
|
||
|
'default' => 'date',
|
||
|
'options' => array(
|
||
|
'date' => esc_html__( 'Date', 'thinkai' ),
|
||
|
'title' => esc_html__( 'Title', 'thinkai' ),
|
||
|
'menu_order' => esc_html__( 'Menu Order', 'thinkai' ),
|
||
|
'rand' => esc_html__( 'Random', 'thinkai' ),
|
||
|
),
|
||
|
]
|
||
|
);
|
||
|
$this->add_control(
|
||
|
'query_order',
|
||
|
[
|
||
|
'label' => esc_html__( 'Order', 'thinkai' ),
|
||
|
'label_block' => true,
|
||
|
'type' => Controls_Manager::SELECT,
|
||
|
'default' => 'DESC',
|
||
|
'options' => array(
|
||
|
'DESC' => esc_html__( 'DESC', 'thinkai' ),
|
||
|
'ASC' => esc_html__( 'ASC', 'thinkai' ),
|
||
|
),
|
||
|
]
|
||
|
);
|
||
|
$this->add_control(
|
||
|
'query_category',
|
||
|
[
|
||
|
'type' => Controls_Manager::SELECT,
|
||
|
'label' => esc_html__('Category', 'thinkai'),
|
||
|
'label_block' => true,
|
||
|
'options' => get_project_categories()
|
||
|
]
|
||
|
);
|
||
|
$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');
|
||
|
$layout = $settings[ 'layout_control' ];
|
||
|
|
||
|
$paged = get_query_var('paged');
|
||
|
$paged = thinkai_set($_REQUEST, 'paged') ? esc_attr($_REQUEST['paged']) : $paged;
|
||
|
|
||
|
$this->add_render_attribute( 'wrapper', 'class', 'templatepath-thinkai' );
|
||
|
$args = array(
|
||
|
'post_type' => 'project',
|
||
|
'posts_per_page' => thinkai_set( $settings, 'query_number' ),
|
||
|
'orderby' => thinkai_set( $settings, 'query_orderby' ),
|
||
|
'order' => thinkai_set( $settings, 'query_order' ),
|
||
|
'paged' => $paged
|
||
|
);
|
||
|
|
||
|
if( thinkai_set( $settings, 'query_category' ) ) $args['project_cat'] = thinkai_set( $settings, 'query_category' );
|
||
|
$query = new \WP_Query( $args );
|
||
|
|
||
|
if ( $query->have_posts() ) {
|
||
|
$dimention = get_post_meta( get_the_id(), 'dimension', true );
|
||
|
?>
|
||
|
|
||
|
<?php if( $layout === '2' ): ?>
|
||
|
|
||
|
<!--Start Case style2-->
|
||
|
<section class="case-style2">
|
||
|
<?php if($settings['shape_image']){ ?>
|
||
|
<div class="case-style2__shape1">
|
||
|
<img src="<?php echo esc_url(wp_get_attachment_url($settings['shape_image']['id'])); ?>" alt="<?php bloginfo( 'name' ); ?>">
|
||
|
</div>
|
||
|
<?php } ?>
|
||
|
<div class="container">
|
||
|
<?php if($settings['subtitle'] || $settings['title']){ ?>
|
||
|
<div class="sec-title text-center sec-title-animation animation-style2">
|
||
|
<?php if($settings['subtitle']){ ?>
|
||
|
<div class="sub-title">
|
||
|
<h4><?php echo wp_kses($settings['subtitle'], true); ?></h4>
|
||
|
</div>
|
||
|
<?php } ?>
|
||
|
|
||
|
<?php if($settings['title']){ ?>
|
||
|
<h2 class="title-animation"><?php echo wp_kses($settings['title'], true); ?></h2>
|
||
|
<?php } ?>
|
||
|
</div>
|
||
|
<?php } ?>
|
||
|
<div class="row masonary-layout">
|
||
|
<?php
|
||
|
global $post;
|
||
|
while ( $query->have_posts() ) : $query->the_post();
|
||
|
$term_list = wp_get_post_terms(get_the_id(), 'project_cat', array("fields" => "names"));
|
||
|
$post_thumbnail_id = get_post_thumbnail_id($post->ID);
|
||
|
$post_thumbnail_url = wp_get_attachment_url($post_thumbnail_id);
|
||
|
?>
|
||
|
<!--Start Single Case style2-->
|
||
|
<div class="col-xl-4 col-lg-6 col-md-6">
|
||
|
<div class="case-style2__single <?php if(get_post_meta( get_the_id(), 'dimension', true) == 'extra_height') echo 'height'; else echo ' '?>">
|
||
|
<div class="case-style2__single-img">
|
||
|
<div class="inner">
|
||
|
<?php
|
||
|
$dimention = get_post_meta( get_the_id(), 'dimension', true );
|
||
|
if($dimention == 'extra_height'){
|
||
|
$image_size = 'thinkai_370x370';
|
||
|
} else{
|
||
|
$image_size = 'thinkai_370x270';
|
||
|
} the_post_thumbnail($image_size);
|
||
|
?>
|
||
|
</div>
|
||
|
<div class="case-style2__single-overlay-icon">
|
||
|
<a class="lightbox-image" data-fancybox="gallery" href="<?php echo esc_url($post_thumbnail_url); ?>"><span class="icon-right-arrow1"></span></a>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="case-style2__single-content text-center">
|
||
|
<h3><?php the_title(); ?></h3>
|
||
|
<p><?php echo implode( ', ', (array)$term_list );?></p>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<!--End Single Case style2-->
|
||
|
<?php endwhile; ?>
|
||
|
</div>
|
||
|
</div>
|
||
|
</section>
|
||
|
<!--End Case style2-->
|
||
|
|
||
|
<?php else: ?>
|
||
|
|
||
|
<!--Start Project Style1-->
|
||
|
<section class="project-style1 p-0 m-0">
|
||
|
<div class="auto-container">
|
||
|
<div class="project-style1__inner ">
|
||
|
<ul class="clearfix masonry-items-container">
|
||
|
<?php
|
||
|
global $post;
|
||
|
while ( $query->have_posts() ) : $query->the_post();
|
||
|
$term_list = wp_get_post_terms(get_the_id(), 'project_cat', array("fields" => "names"));
|
||
|
$post_thumbnail_id = get_post_thumbnail_id($post->ID);
|
||
|
$post_thumbnail_url = wp_get_attachment_url($post_thumbnail_id);
|
||
|
$ext_link = get_post_meta( get_the_id(), 'project_ext_link', true);
|
||
|
?>
|
||
|
<li class="masonry-item <?php if(get_post_meta( get_the_id(), 'dimension', true) == 'extra_width') echo 'gallery-item width40'; elseif(get_post_meta( get_the_id(), 'dimension', true) == 'extra_height') echo 'gallery-item extra-height'; else echo 'gallery-item'?>">
|
||
|
<div class="project-style1__single">
|
||
|
<div class="project-style1__single-img">
|
||
|
<div class="inner">
|
||
|
<?php
|
||
|
$dimention = get_post_meta( get_the_id(), 'dimension', true );
|
||
|
if($dimention == 'extra_width'){
|
||
|
$image_size = 'thinkai_730x295';
|
||
|
} elseif($dimention == 'extra_height'){
|
||
|
$image_size = 'thinkai_350x620';
|
||
|
} elseif($dimention == 'normal_height'){
|
||
|
$image_size = 'thinkai_350x295';
|
||
|
} else{
|
||
|
$image_size = 'full';
|
||
|
} the_post_thumbnail( $image_size );
|
||
|
?>
|
||
|
<div class="overlay-img">
|
||
|
<?php
|
||
|
$dimention = get_post_meta( get_the_id(), 'dimension', true );
|
||
|
if($dimention == 'extra_width'){
|
||
|
$image_size = 'thinkai_730x295';
|
||
|
} elseif($dimention == 'extra_height'){
|
||
|
$image_size = 'thinkai_350x620';
|
||
|
} elseif($dimention == 'normal_height'){
|
||
|
$image_size = 'thinkai_350x295';
|
||
|
} else{
|
||
|
$image_size = 'full';
|
||
|
} the_post_thumbnail( $image_size );
|
||
|
?>
|
||
|
</div>
|
||
|
<div class="overlay-box">
|
||
|
<a class="lightbox-image" data-fancybox="gallery" href="<?php echo esc_url($post_thumbnail_url); ?>">
|
||
|
<span class="icon-right-arrow1"></span>
|
||
|
</a>
|
||
|
</div>
|
||
|
<div class="text-box">
|
||
|
<div class="icon-box">
|
||
|
<span class="icon-abstract-shape-1"></span>
|
||
|
</div>
|
||
|
<p><?php echo wp_kses( get_post_meta( get_the_id(), 'project_designation', true), true); ?></p>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="project-style1__single-content">
|
||
|
<h3><a href="<?php echo esc_url( $ext_link ); ?>"><?php the_title(); ?></a></h3>
|
||
|
<p><?php echo implode( ', ', (array)$term_list );?></p>
|
||
|
</div>
|
||
|
</div>
|
||
|
</li>
|
||
|
<?php endwhile; ?>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</div>
|
||
|
</section>
|
||
|
<!--Start Project Style1-->
|
||
|
<?php endif; ?>
|
||
|
|
||
|
<?php }
|
||
|
wp_reset_postdata();
|
||
|
}
|
||
|
|
||
|
}
|