File "case-area.php"
Full Path: /home/flipjqml/onlinebetsolution.com/wp-content/plugins/cyarb-toolkit/widgets/case-area.php
File size: 23.63 KB
MIME-type: text/x-php
Charset: utf-8
<?php
/**
* Case Area Widget
*/
namespace Elementor;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Case_Area extends Widget_Base {
public function get_name() {
return 'CaseArea';
}
public function get_title() {
return esc_html__( 'Case Area', 'cyarb-toolkit' );
}
public function get_icon() {
return 'eicon-toggle';
}
public function get_categories() {
return [ 'cyarb-elements' ];
}
protected function register_controls() {
$this->start_controls_section(
'Case_Area',
[
'label' => esc_html__( 'Cyarb Section', 'cyarb-toolkit' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'case_style',
[
'label' => __( 'Case Style', 'cyarb-toolkit' ),
'type' => Controls_Manager::SELECT,
'options' => [
'1' => __( 'Style One', 'cyarb-toolkit' ),
'2' => __( 'Style Two', 'cyarb-toolkit' ),
'3' => __( 'Style Three', 'cyarb-toolkit' ),
],
'default' => '1',
]
);
$this->add_control(
'title',
[
'label' => esc_html__( 'Title', 'cyarb-toolkit' ),
'type' => Controls_Manager::TEXT,
]
);
$this->add_control(
'title_tag',
[
'label' => esc_html__( 'Title Tag', 'cyarb-toolkit' ),
'type' => Controls_Manager::SELECT,
'options' => [
'h1' => esc_html__( 'h1', 'cyarb-toolkit' ),
'h2' => esc_html__( 'h2', 'cyarb-toolkit' ),
'h3' => esc_html__( 'h3', 'cyarb-toolkit' ),
'h4' => esc_html__( 'h4', 'cyarb-toolkit' ),
'h5' => esc_html__( 'h5', 'cyarb-toolkit' ),
'h6' => esc_html__( 'h6', 'cyarb-toolkit' ),
],
'default' => 'h2',
]
);
$this->add_control(
'desc',
[
'label'=>__('Add Description', 'cyarb-toolkit'),
'type'=>Controls_Manager:: WYSIWYG,
'description' => __('This text editor for p','cyarb-toolkit'),
]
);
$this->add_control(
'count',
[
'label' => __( 'Post Per Page', 'cyarb-toolkit' ),
'default' => __( '4', 'cyarb-toolkit' ),
'type' => Controls_Manager::TEXT,
'description' => __('if you want to see all post type -1','cyarb-toolkit')
]
);
$this->add_control(
'cat_name',
[
'label' => __( 'Select Category', 'cyarb-toolkit' ),
'type' => Controls_Manager::SELECT,
'options' => cyarb_toolkit_get_case_cat_list(),
]
);
$this->add_control(
'order',
[
'label' => __( 'Select Order', 'cyarb-toolkit' ),
'type' => Controls_Manager::SELECT,
'options' => [
'DESC' => __( 'DESC', 'cyarb-toolkit' ),
'ASC' => __( 'ASC', 'cyarb-toolkit' ),
],
'default' => 'DESC',
]
);
$this->add_control(
'button_text',
[
'label'=> __('Button Text', 'cyarb-toolkit'),
'type'=>Controls_Manager:: TEXT,
'default' => __( 'View Case Studie Details', 'cyarb-toolkit' ),
]
);
//Shape Images
$this->add_control(
'image_shape',
[
'label' => esc_html__( 'Hide Shapes?', 'cyarb-toolkit' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'cyarb-toolkit' ),
'label_off' => esc_html__( 'Hide', 'cyarb-toolkit' ),
'return_value' => 'yes',
'default' => 'yes',
'condition' => [
'case_style' => '1',
]
]
);
$this->add_control(
'pagination_area',
[
'label' => __( 'Hide Pagination?', 'cyarb-toolkit' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'cyarb-toolkit' ),
'label_off' => __( 'Hide', 'cyarb-toolkit' ),
'return_value' => 'yes',
'default' => 'yes',
'condition' => [
'case_style' => '2',
]
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_style',
[
'label' => esc_html__( 'Style', 'cyarb-toolkit' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__( 'Title Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .section-title h2, .section-title h3, .section-title h4, .section-title h5, .section-title h5, .section-title h6, .section-title h1' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => __( 'Title Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .section-title h2, .section-title h3, .section-title h4, .section-title h5, .section-title h5, .section-title h6, .section-title h1',
]
);
$this->add_control(
'desc_color',
[
'label' => esc_html__( 'Description Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .section-title p' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'desc_typography',
'label' => __( 'Description Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .section-title p',
]
);
$this->add_control(
'card_title_color',
[
'label' => esc_html__( 'Card Title Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-resources-box .content h3 a, .single-explore-card .explore-content h3 a, .single-resources-item .content h3 a, .resources-box .content h3 a' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'card_title_typography',
'label' => __( 'Card Title Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-resources-box .content h3, .single-explore-card .explore-content h3 a, .single-resources-item .content h3 a, .resources-box .content h3 a',
]
);
$this->add_control(
'cat_title_color',
[
'label' => esc_html__( 'Category Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-resources-box .content .category a, .single-explore-card .explore-content span a, .single-resources-item .content .category a, .resources-box .content .category a' => 'color: {{VALUE}}',
],
]
);
$this->add_control(
'cat_bg_color',
[
'label' => esc_html__( 'Category Background Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-resources-item .content .category a, .single-explore-card .explore-content span a, .single-resources-item .content .category a, .single-resources-box .content .category a, .resources-box .content .category a' => 'background: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'cat_title_typography',
'label' => __( 'Category Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-resources-box .content .category a, .single-explore-card .explore-content span a, .single-resources-item .content .category a, .resources-box .content .category a',
]
);
$this->add_control(
'ex_color',
[
'label' => esc_html__( 'Excerpt Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-resources-box .content p, .single-explore-card .explore-content p, .single-resources-item .content p, .resources-box .content p' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'ex_typography',
'label' => __( 'Excerpt Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-resources-box .content p, .single-explore-card .explore-content p, .single-resources-item .content p, .resources-box .content p',
]
);
$this->add_control(
'read_color',
[
'label' => esc_html__( 'Read More Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-resources-item .content .link-btn, .single-explore-card .explore-content .explore-btn, .single-resources-box .content .link-btn, .resources-box .content .link-btn' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'readm_typography',
'label' => __( 'Read More Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-resources-item .content .link-btn, .single-explore-card .explore-content .explore-btn, .single-resources-box .content .link-btn, .resources-box .content .link-btn',
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
global $cyarb_opt;
$count_cat = !empty($cyarb_opt['count_tag']) ? $cyarb_opt['count_tag'] : 1;
if( $settings['cat_name'] != '' ) {
$args = array(
'post_type' => 'case',
'posts_per_page' => $settings['count'],
'order' => $settings['order'],
'paged' => get_query_var('paged') ? get_query_var('paged') : 1,
'tax_query' => array(
array(
'taxonomy' => 'case_cat',
'field' => 'slug',
'terms' => $settings['cat_name'],
'hide_empty' => false
)
)
);
} else {
$args = array(
'post_type' => 'case',
'posts_per_page' => $settings['count'],
'order' => $settings['order'],
'paged' => get_query_var('paged') ? get_query_var('paged') : 1,
);
}
$cases_array = new \WP_Query( $args );
?>
<?php if( $settings['case_style'] == '1' ): ?>
<div class="resources-area bg-color ptb-100">
<?php if( $settings['title'] != '' || $settings['desc'] != '' ) : ?>
<div class="container">
<div class="section-title">
<<?php echo esc_attr($settings['title_tag']);?>><?php echo esc_html( $settings['title'] ); ?></<?php echo esc_attr($settings['title_tag']);?>>
<?php echo wp_kses_post( $settings['desc'] ); ?>
</div>
</div>
<?php endif; ?>
<div class="container-fluid">
<div class="resources-slides owl-carousel owl-theme">
<?php while($cases_array->have_posts()): $cases_array->the_post(); $id = get_the_ID();?>
<div class="single-resources-item">
<div class="image">
<a href="<?php the_permalink(); ?>" class="d-block">
<img src="<?php echo esc_url(get_the_post_thumbnail_url($id, 'cyarb_case_thumb')); ?>" alt="<?php echo esc_attr__('case-image','cyarb-toolkit'); ?>">
</a>
</div>
<div class="content">
<?php $case_tags = get_terms('case_tag');
if( !empty( $case_tags ) && ! is_wp_error( $case_tags )) {
$i = 1; foreach( $case_tags as $tag){ ?>
<div class="category">
<?php echo get_the_term_list( get_the_ID(), 'case_tag' ); ?>
</div>
<?php if( $i == $count_cat ){ break; $i++;}
}
}
?>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>" class="link-btn"><?php echo esc_html( $settings['button_text'] ); ?> <i class="lni lni-chevron-right"></i></a>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
</div>
</div>
<?php if ( 'yes' === $settings['image_shape'] ) : ?>
<div class="shape4"><img src="<?php echo esc_url(get_template_directory_uri() .'/assets/img/shape/shape4.png' ); ?>" alt="<?php echo esc_attr__( 'Shape', 'cyarb-toolkit' ); ?>"></div>
<div class="shape1"><img src="<?php echo esc_url(get_template_directory_uri() .'/assets/img/shape/shape4.png' ); ?>" alt="<?php echo esc_attr__( 'Shape', 'cyarb-toolkit' ); ?>"></div>
<?php endif; ?>
</div>
<?php elseif( $settings['case_style'] == '2' ): ?>
<div class="resources-area ptb-100">
<div class="container">
<?php if( $settings['title'] != '' || $settings['desc'] != '' ) : ?>
<div class="section-title">
<<?php echo esc_attr($settings['title_tag']);?>><?php echo esc_html( $settings['title'] ); ?></<?php echo esc_attr($settings['title_tag']);?>>
<?php echo wp_kses_post( $settings['desc'] ); ?>
</div>
<?php endif; ?>
<div class="row">
<?php while($cases_array->have_posts()): $cases_array->the_post(); $id = get_the_ID();
?>
<div class="col-lg-6 col-md-6">
<div class="single-resources-box">
<div class="image">
<a href="<?php the_permalink(); ?>" class="d-block">
<img src="<?php echo esc_url(get_the_post_thumbnail_url($id, 'cyarb_case_thumb')); ?>" alt="<?php echo esc_attr__('case-image','cyarb-toolkit'); ?>">
</a>
</div>
<div class="content">
<?php $case_tags = get_terms('case_tag');
if( !empty( $case_tags ) && ! is_wp_error( $case_tags )) {
$i = 1;
foreach( $case_tags as $tag){ ?>
<div class="category">
<?php echo get_the_term_list( get_the_ID(), 'case_tag' ); ?>
</div>
<?php
if( $i == $count_cat ){ break;
$i++;
}
}
}
?>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>" class="link-btn"><?php echo esc_html( $settings['button_text'] ); ?> <i class="lni lni-chevron-right"></i></a>
</div>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
<?php if ( 'yes' === $settings['pagination_area'] ) : ?>
<div class="col-lg-12 col-md-12">
<div class="pagination-area">
<nav aria-label="navigation">
<?php
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $cases_array->max_num_pages,
//'format' => '?paged=%#%',
'prev_text' => '<i class="lni lni-angle-double-left"></i>',
'next_text' => '<i class="lni lni-angle-double-right"></i>',
) ); ?>
</nav>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php else: ?>
<div class="resources-area pt-100 pb-75">
<div class="container">
<?php if( $settings['title'] != '' || $settings['desc'] != '' ) : ?>
<div class="section-title">
<<?php echo esc_attr($settings['title_tag']);?>><?php echo esc_html( $settings['title'] ); ?></<?php echo esc_attr($settings['title_tag']);?>>
<?php echo wp_kses_post( $settings['desc'] ); ?>
</div>
<?php endif; ?>
<div class="row justify-content-center">
<?php while($cases_array->have_posts()): $cases_array->the_post();
$id = get_the_ID();
?>
<div class="col-xl-4 col-lg-6 col-md-6">
<div class="resources-box">
<div class="image">
<a href="<?php the_permalink(); ?>" class="d-block">
<img src="<?php echo esc_url(get_the_post_thumbnail_url($id, 'cyarb_case_thumb')); ?>" alt="<?php echo esc_attr__('case-image','cyarb-toolkit'); ?>">
</a>
</div>
<div class="content">
<?php $case_tags = get_terms('case_tag');
if( !empty( $case_tags ) && ! is_wp_error( $case_tags )) {
$i = 1;
foreach( $case_tags as $tag){ ?>
<div class="category">
<?php echo get_the_term_list( get_the_ID(), 'case_tag' ); ?>
</div>
<?php
if( $i == $count_cat ){ break;
$i++;
}
}
}
?>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<p><?php echo esc_html(wp_trim_words( get_the_excerpt(), 16, '.' )); ?></p>
<a href="<?php the_permalink(); ?>" class="link-btn"><?php echo esc_html( $settings['button_text'] ); ?> <i class="lni lni-chevron-right"></i></a>
</div>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
</div>
</div>
</div>
<?php endif; ?>
<?php
}
}
Plugin::instance()->widgets_manager->register_widget_type( new Case_Area );