File "service-features.php"
Full Path: /home/flipjqml/onlinebetsolution.com/next_old/wp-content/plugins/cyarb-toolkit/widgets/service-features.php
File size: 29.25 KB
MIME-type: text/x-php
Charset: utf-8
<?php
/**
* Services Features Widget
*/
namespace Elementor;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Cyarb_Servcies_Features extends Widget_Base {
public function get_name() {
return 'ServicesFeatures';
}
public function get_title() {
return esc_html__( 'Services Features', 'cyarb-toolkit' );
}
public function get_icon() {
return 'eicon-handle';
}
public function get_categories() {
return [ 'cyarb-elements' ];
}
protected function register_controls() {
$this->start_controls_section(
'Cyarb_Features_Area_controls',
[
'label' => __( 'Services Features Controls', 'cyarb-toolkit' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'choose_style',
[
'label' => __( 'Choose Style', 'cyarb-toolkit' ),
'type' => Controls_Manager::SELECT,
'options' => [
'1' => __( 'Style One', 'cyarb-toolkit' ),
'2' => __( 'Style Two', 'cyarb-toolkit' ),
],
'default' => '1',
]
);
$this->add_control(
'columns',
[
'label' => esc_html__( 'Choose Columns', 'rola-toolkit' ),
'type' => Controls_Manager::SELECT,
'options' => [
'1' => esc_html__( '1', 'rola-toolkit' ),
'2' => esc_html__( '2', 'rola-toolkit' ),
'3' => esc_html__( '3', 'rola-toolkit' ),
'4' => esc_html__( '4', 'rola-toolkit' ),
],
'default' => '3',
]
);
$this->add_control(
'title',
[
'label' => esc_html__( 'Title', 'cyarb-toolkit' ),
'type' => Controls_Manager::TEXTAREA,
'condition' => [
'choose_style' => '2',
]
]
);
$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',
'condition' => [
'choose_style' => '2',
]
]
);
$this->add_control(
'button_text',
[
'label' => __( 'Button Text', 'cyarb-toolkit' ),
'type' => Controls_Manager::TEXT,
'default' => __('Get A Free Quote', 'cyarb-toolkit'),
'condition' => [
'choose_style' => '2',
]
]
);
$this->add_control(
'link_type',
[
'label' => __( 'Link Type', 'cyarb-toolkit' ),
'type' => Controls_Manager::SELECT,
'label_block' => true,
'options' => [
'1' => __( 'Link To Page', 'cyarb-toolkit' ),
'2' => __( 'External Link', 'cyarb-toolkit' ),
],
'condition' => [
'choose_style' => '2',
]
]
);
$this->add_control(
'link_to_page',
[
'label' => __( 'Link Page', 'cyarb-toolkit' ),
'type' => Controls_Manager::SELECT,
'label_block' => true,
'options' => cyarb_toolkit_get_page_as_list(),
'condition' => [
'link_type' => '1',
'choose_style' => '2',
]
]
);
$this->add_control(
'external_link',
[
'label' =>__('External Link', 'cyarb-toolkit'),
'type' => Controls_Manager:: TEXT,
'condition' => [
'link_type' => '2',
'choose_style' => '2',
]
]
);
//Target Page
$this->add_control(
'target_page',
[
'label' => __( 'Link Open In New Tab?', 'cyarb-toolkit' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Yes', 'cyarb-toolkit' ),
'label_off' => __( 'No', 'cyarb-toolkit' ),
'return_value' => 'yes',
'default' => 'yes',
'condition' => [
'choose_style' => '2',
]
]
);
$this->add_control(
'count',
[
'label' => __( 'Post Per Page', 'cyarb-toolkit' ),
'default' => __( '3', '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_product_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(
'excerpt_num',
[
'label' => __( 'Excerpt', 'cyarb-toolkit' ),
'type' => Controls_Manager::NUMBER,
'default' => 8,
]
);
$this->add_control(
'read_more_btntext',
[
'label' => __( 'Read More Button Text', 'cyarb-toolkit' ),
'default' => __( 'Read More', 'cyarb-toolkit' ),
'type' => Controls_Manager::TEXT,
'condition' => [
'choose_style' => '1',
]
]
);
$this->add_control(
'shape1',
[
'label' => __('Add Shape Image', 'cyarb-toolkit' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'condition' => [
'choose_style' => '2',
]
]
);
$this->end_controls_section();
$this->start_controls_section(
'style',
[
'label' => esc_html__( 'Style', 'cyarb-toolkit' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'sec_title_color',
[
'label' => esc_html__( 'Section Title Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .section-title-wrap .wrap-title h2, .section-title-wrap .wrap-title h1, .section-title-wrap .wrap-title h3, .section-title-wrap .wrap-title h4, .section-title-wrap .wrap-title h5, .section-title-wrap .wrap-title h6' => 'color: {{VALUE}}',
],
'condition' => [
'choose_style' => '2',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'sec_title_typography',
'label' => __( 'Section Title Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .section-title-wrap .wrap-title h2, .section-title-wrap .wrap-title h1, .section-title-wrap .wrap-title h3, .section-title-wrap .wrap-title h4, .section-title-wrap .wrap-title h5, .section-title-wrap .wrap-title h6',
'condition' => [
'choose_style' => '2',
]
]
);
$this->add_control(
'sec_divider',
[
'type' => Controls_Manager::DIVIDER,
]
);
$this->add_control(
'sec_btncolor',
[
'label' => esc_html__( 'Section Button Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .default-btn-two' => 'color: {{VALUE}}',
],
'condition' => [
'choose_style' => '2',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'secbtn_type_typography',
'label' => __( 'Button Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .default-btn-two',
'condition' => [
'choose_style' => '2',
]
]
);
$this->add_control(
'btn_bg_head',
[
'label' => esc_html__( 'Button Background Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
'condition' => [
'choose_style' => '2',
]
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'btn_bg2_color',
'types' => ['gradient' ],
'selector' => '{{WRAPPER}} .default-btn-two',
'condition' => [
'choose_style' => '2',
]
]
);
$this->add_control(
'onedivider',
[
'type' => Controls_Manager::DIVIDER,
]
);
$this->add_control(
'twodivider',
[
'type' => Controls_Manager::DIVIDER,
]
);
$this->add_control(
'secbtn_hcolor',
[
'label' => __( 'Button Hover Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .default-btn-two:hover' => 'color: {{VALUE}}',
],
'condition' => [
'choose_style' => '2',
]
]
);
$this->add_control(
'btn_hbg_head',
[
'label' => esc_html__( 'Section Button Hover Background Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
'condition' => [
'choose_style' => '2',
]
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'btn_hbg2_color',
'types' => ['gradient' ],
'selector' => '{{WRAPPER}} .default-btn-two::before',
'condition' => [
'choose_style' => '2',
]
]
);
$this->add_control(
'sec2divider',
[
'type' => Controls_Manager::DIVIDER,
]
);
$this->add_control(
'sec3divider',
[
'type' => Controls_Manager::DIVIDER,
]
);
$this->add_control(
'post_title_color',
[
'label' => esc_html__( 'Post Title Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-cyard-features-card h3 a, .single-infrastructure-card h3 a' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'post_title_typography',
'label' => __( 'Post Title Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-cyard-features-card h3 a, .single-infrastructure-card h3 a',
]
);
$this->add_control(
'sec_desc_color',
[
'label' => esc_html__( 'Excerpt Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-cyard-features-card p, .single-infrastructure-card p' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'sec_desc_typography',
'label' => __( 'Excerpt Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-cyard-features-card p, .single-infrastructure-card p',
]
);
$this->add_control(
'btn_color',
[
'label' => esc_html__( 'Button Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-cyard-features-card .features-btn' => 'color: {{VALUE}}',
],
'condition' => [
'choose_style' => '1',
]
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'btn_typography',
'label' => esc_html__( 'Button Typography', 'cyarb-toolkit' ),
'selector' => '{{WRAPPER}} .single-cyard-features-card .features-btn',
'condition' => [
'choose_style' => '1',
]
]
);
$this->add_control(
'icon_bg_color',
[
'label' => esc_html__( 'Icon Background Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-cyard-features-card .icon i' => 'background-color: {{VALUE}}',
],
'condition' => [
'choose_style' => '1',
]
]
);
$this->add_control(
'icon_color',
[
'label' => esc_html__( 'Icon Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-cyard-features-card .icon i, .single-infrastructure-card .icon i' => 'color: {{VALUE}}',
],
]
);
$this->add_control(
'icon_bg_head',
[
'label' => esc_html__( 'Icon Background Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
'condition' => [
'choose_style' => '2',
]
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'icon_bg2_color',
'types' => ['gradient' ],
'selector' => '{{WRAPPER}} .single-infrastructure-card .icon i',
'condition' => [
'choose_style' => '2',
]
]
);
$this->add_control(
'secdivider4',
[
'type' => Controls_Manager::DIVIDER,
]
);
$this->add_control(
'card_bg_head',
[
'label' => esc_html__( 'Card Background Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
'condition' => [
'choose_style' => '1',
]
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'card_bg2_color',
'types' => ['gradient' ],
'selector' => '{{WRAPPER}} .single-cyard-features-card',
'condition' => [
'choose_style' => '1',
]
]
);
$this->add_control(
'onedivider2',
[
'type' => Controls_Manager::DIVIDER,
]
);
$this->add_control(
'twodivider2',
[
'type' => Controls_Manager::DIVIDER,
]
);
$this->add_control(
'card_bg_hhead',
[
'label' => esc_html__( 'Card Hover Background Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'card_hbg2_color',
'types' => ['gradient' ],
'selector' => '{{WRAPPER}} .single-cyard-features-card::before, .single-infrastructure-card::before',
]
);
$this->add_control(
'ptitleh_color',
[
'label' => esc_html__( 'Title Hover Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-infrastructure-card:hover h3 a, .single-infrastructure-card:hover h1 a, .single-infrastructure-card:hover h2 a, .single-infrastructure-card:hover h4 a, .single-infrastructure-card:hover h5 a, .single-infrastructure-card:hover h6 a' => 'color: {{VALUE}}',
],
'condition' => [
'choose_style' => '2',
]
]
);
$this->add_control(
'pdesch_color',
[
'label' => esc_html__( 'Excerpt Hover Color', 'cyarb-toolkit' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-infrastructure-card:hover p' => 'color: {{VALUE}}',
],
'condition' => [
'choose_style' => '2',
]
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
// Card Columns
$columns = $settings['columns'];
if ($columns == '1') {
$column = 'col-lg-12 col-md-6';
}elseif ($columns == '2') {
$column = 'col-lg-6 col-md-6';
}elseif ($columns == '3') {
$column = 'col-lg-4 col-md-6';
}elseif ($columns == '4') {
$column = 'col-lg-3 col-md-6';
}
if( $settings['cat_name'] != '' ) {
$args = array(
'post_type' => 'service',
'posts_per_page' => $settings['count'],
'order' => $settings['order'],
'tax_query' => array(
array(
'taxonomy' => 'service_cat',
'field' => 'slug',
'terms' => $settings['cat_name'],
'hide_empty' => false
)
)
);
} else {
$args = array(
'post_type' => 'service',
'posts_per_page' => $settings['count'],
'order' => $settings['order'],
);
}
$services_array = new \WP_Query( $args );
$btn1_text = $settings['button_text'];
$link_source = '';
if( $settings['link_type'] == 1 ){
$link_source = get_page_link($settings['link_to_page']);
} else {
$link_source = $settings['external_link'];
}
?>
<?php if( $settings['choose_style'] == '1' ): ?>
<div class="cyard-features-area pb-75">
<div class="container">
<div class="row justify-content-center">
<?php while($services_array->have_posts()): $services_array->the_post();
if( function_exists('acf_add_options_page') && get_field('service_icon') != '' ) {
$icon_class = get_field('service_icon');
$div_class = '';
} else {
$icon_class = '';
$div_class = 'icon-pad-none';
}
?>
<div class="<?php echo esc_attr( $column );?>">
<div class="single-cyard-features-card <?php echo esc_attr( $div_class ); ?>">
<?php if( $icon_class != '') : ?>
<div class="icon">
<i class="<?php echo esc_attr( $icon_class ); ?>"></i>
</div>
<?php endif; ?>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<p><?php echo esc_html(wp_trim_words( get_the_excerpt(), $settings['excerpt_num'], '' )); ?></p>
<?php if( $settings['read_more_btntext'] != '' ) : ?>
<a href="<?php the_permalink(); ?>" class="features-btn"><?php echo esc_html( $settings['read_more_btntext'] ); ?> <i class="lni lni-arrow-right"></i></a>
<?php endif; ?>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
</div>
</div>
</div>
<?php else: ?>
<div class="infrastructure-area pt-100 pb-75">
<div class="container">
<?php if ( $settings['title'] != '' || $btn1_text != '' ) : ?>
<div class="section-title-wrap">
<div class="row align-items-center">
<?php if ( $settings['title'] != '' ) : ?>
<div class="col-lg-7 col-md-12">
<div class="wrap-title">
<<?php echo esc_attr($settings['title_tag']);?>><?php echo esc_html( $settings['title'] ); ?></<?php echo esc_attr($settings['title_tag']);?>>
</div>
</div>
<?php endif; ?>
<?php if($btn1_text != '') {
if ( 'yes' === $settings['target_page'] ) { ?>
<div class="col-lg-5 col-md-12">
<div class="wrap-btn">
<a target="_blank" href="<?php echo esc_url($link_source); ?>" class="default-btn-two">
<?php echo esc_html($btn1_text); ?>
</a>
</div>
</div>
<?php } else { ?>
<div class="col-lg-5 col-md-12">
<div class="wrap-btn">
<a href="<?php echo esc_url($link_source); ?>" class="default-btn-two">
<?php echo esc_html($btn1_text); ?>
</a>
</div>
</div>
<?php }
} ?>
</div>
</div>
<?php endif; ?>
<div class="row justify-content-center">
<?php while($services_array->have_posts()): $services_array->the_post();
if( function_exists('acf_add_options_page') && get_field('service_icon') != '' ) {
$icon_class = get_field('service_icon');
$div_class = '';
} else {
$icon_class = '';
$div_class = 'icon-pad-none';
}
?>
<div class="<?php echo esc_attr( $column );?>">
<div class="single-infrastructure-card <?php echo esc_attr( $div_class ); ?>">
<?php if( $icon_class != '') : ?>
<div class="icon">
<i class="<?php echo esc_attr( $icon_class ); ?>"></i>
</div>
<?php endif; ?>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<p><?php echo esc_html(wp_trim_words( get_the_excerpt(), $settings['excerpt_num'], '' )); ?></p>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
</div>
</div>
<?php if( $settings['shape1']['url'] != '') : ?>
<div class="infrastructure-shape">
<img src="<?php echo esc_url( $settings['shape1']['url'] ); ?>" alt="<?php echo esc_attr('image','cyarb-toolkit'); ?>">
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php
}
}
Plugin::instance()->widgets_manager->register_widget_type( new Cyarb_Servcies_Features );