Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Elementor;
- if ( ! defined( 'ABSPATH' ) ) exit; # Exit if accessed directly
- class Widget_Themeum_Service extends Widget_Base {
- public function get_name() {
- return 'thm-service';
- }
- public function get_title() {
- return __( 'Service', 'structure' );
- }
- public function get_icon() {
- return 'eicon-inner-section wts-eae-pe';
- }
- public function get_categories() {
- return [ 'themeum-elementor' ];
- }
- protected function _register_controls() {
- $this->start_controls_section(
- 'section_title',
- [
- 'label' => __( 'Service Settings', 'structure' ),
- ]
- );
- $this->add_control(
- 'service_category',
- [
- 'label' => __( 'Select Service', 'structure' ),
- 'type' => Controls_Manager::SELECT,
- 'options' => themeum_cat_list('portfolio-cat'),
- 'multiple' => true,
- 'default' => 'All'
- ]
- );
- $this->add_control(
- 'service_layout',
- [
- 'label' => __( 'Order', 'structure' ),
- 'type' => Controls_Manager::SELECT,
- 'default' => 'layout_1',
- 'options' => [
- 'layout_1' => __( 'Layout 1', 'structure' ),
- 'layout_2' => __( 'Layout 2', 'structure' ),
- ],
- ]
- );
- $this->add_control(
- 'service_number',
- [
- 'label' => __( 'Number of Service', 'structure' ),
- 'type' => Controls_Manager::NUMBER,
- 'label_block' => true,
- 'default' => __( '6', 'structure' ),
- ]
- );
- $this->add_control(
- 'service_column',
- [
- 'label' => __( 'Number of Column', 'structure' ),
- 'type' => Controls_Manager::SELECT,
- 'default' => 4,
- 'options' => [
- '6' => __( 'Two Column', 'structure' ),
- '4' => __( 'Three Column', 'structure' ),
- '3' => __( 'Four Column', 'structure' ),
- ],
- ]
- );
- $this->add_control(
- 'service_order_by',
- [
- 'label' => __( 'Order', 'structure' ),
- 'type' => Controls_Manager::SELECT,
- 'default' => 'DESC',
- 'options' => [
- 'DESC' => __( 'Descending', 'structure' ),
- 'ASC' => __( 'Ascending', 'structure' ),
- ],
- ]
- );
- $this->add_control(
- 'service_show_title',
- [
- 'label' => __( 'Show Title', 'structure' ),
- 'type' => Controls_Manager::SWITCHER,
- 'default' => 'yes',
- 'label_on' => __( 'Yes', 'structure' ),
- 'label_off' => __( 'No', 'structure' ),
- ]
- );
- $this->add_control(
- 'service_show_category',
- [
- 'label' => __( 'Show Category', 'structure' ),
- 'type' => Controls_Manager::SWITCHER,
- 'default' => 'yes',
- 'label_on' => __( 'Yes', 'structure' ),
- 'label_off' => __( 'No', 'structure' ),
- ]
- );
- $this->add_control(
- 'main_title_color',
- [
- 'label' => __( 'Sub Title Hover Color', 'structure' ),
- 'type' => Controls_Manager::COLOR,
- 'scheme' => [
- 'type' => Scheme_Color::get_type(),
- 'value' => Scheme_Color::COLOR_1,
- ],
- 'selectors' => [
- '{{WRAPPER}} .service-item-content-in .service-title a' => 'color: {{VALUE}};',
- ],
- 'default' => '#293340',
- 'condition' => [
- 'service_layout' => ['layout_1','layout_2']
- ],
- ]
- );
- $this->add_control(
- 'main_sub_title_color',
- [
- 'label' => __( 'Sub Title Hover Color', 'structure' ),
- 'type' => Controls_Manager::COLOR,
- 'scheme' => [
- 'type' => Scheme_Color::get_type(),
- 'value' => Scheme_Color::COLOR_1,
- ],
- 'selectors' => [
- '{{WRAPPER}} .service-item-content-in .service-category' => 'color: {{VALUE}};',
- ],
- 'default' => '#6D7784',
- 'condition' => [
- 'service_layout' => ['layout_1','layout_2']
- ],
- ]
- );
- $this->end_controls_section();
- $this->start_controls_section(
- 'section_title_style',
- [
- 'label' => __( 'Service', 'structure' ),
- 'tab' => Controls_Manager::TAB_STYLE,
- ]
- );
- $this->add_control(
- 'spacing',
- [
- 'label' => __( 'Width', 'structure' ),
- 'type' => Controls_Manager::SLIDER,
- 'default' => [
- 'size' => 1,
- ],
- 'range' => [
- 'px' => [
- 'min' => 0,
- 'max' => 100,
- 'step' => 1,
- ],
- '%' => [
- 'min' => 0,
- 'max' => 100,
- ],
- ],
- 'size_units' => [ 'px', '%' ],
- 'selectors' => [
- '{{WRAPPER}} .service-items' => 'padding: {{SIZE}}{{UNIT}};',
- ],
- ]
- );
- $this->add_control(
- 'sub_text_bg',
- [
- 'label' => __( 'Sub Text Background Color', 'structure' ),
- 'type' => Controls_Manager::COLOR,
- 'scheme' => [
- 'type' => Scheme_Color::get_type(),
- 'value' => Scheme_Color::COLOR_1,
- ],
- 'selectors' => [
- '{{WRAPPER}} .service-item-content' => 'background-color: {{VALUE}};',
- ],
- 'default' => '',
- ]
- );
- $this->add_responsive_control(
- 'filter_align',
- [
- 'label' => __( 'Filter Alignment', 'structure' ),
- 'type' => Controls_Manager::CHOOSE,
- 'options' => [
- 'left' => [
- 'title' => __( 'Left', 'structure' ),
- 'icon' => 'fa fa-align-left',
- ],
- 'center' => [
- 'title' => __( 'Center', 'structure' ),
- 'icon' => 'fa fa-align-center',
- ],
- 'right' => [
- 'title' => __( 'Right', 'structure' ),
- 'icon' => 'fa fa-align-right',
- ],
- 'justify' => [
- 'title' => __( 'Justified', 'structure' ),
- 'icon' => 'fa fa-align-justify',
- ],
- ],
- 'default' => '',
- 'selectors' => [
- '{{WRAPPER}} .serviceFilter' => 'text-align: {{VALUE}};',
- ],
- ]
- );
- $this->add_responsive_control(
- 'align',
- [
- 'label' => __( 'Content Alignment', 'structure' ),
- 'type' => Controls_Manager::CHOOSE,
- 'options' => [
- 'left' => [
- 'title' => __( 'Left', 'structure' ),
- 'icon' => 'fa fa-align-left',
- ],
- 'center' => [
- 'title' => __( 'Center', 'structure' ),
- 'icon' => 'fa fa-align-center',
- ],
- 'right' => [
- 'title' => __( 'Right', 'structure' ),
- 'icon' => 'fa fa-align-right',
- ],
- 'justify' => [
- 'title' => __( 'Justified', 'structure' ),
- 'icon' => 'fa fa-align-justify',
- ],
- ],
- 'default' => '',
- 'selectors' => [
- '{{WRAPPER}} .service-item-content' => 'text-align: {{VALUE}};',
- ],
- ]
- );
- $this->add_control(
- 'title_color',
- [
- 'label' => __( 'Title Color', 'structure' ),
- 'type' => Controls_Manager::COLOR,
- 'scheme' => [
- 'type' => Scheme_Color::get_type(),
- 'value' => Scheme_Color::COLOR_1,
- ],
- 'selectors' => [
- '{{WRAPPER}} .service-title a,{{WRAPPER}} .overlay-cont2' => 'color: {{VALUE}};',
- ],
- 'default' => '#293340',
- ]
- );
- $this->add_control(
- 'title_hover_color',
- [
- 'label' => __( 'Title Hover Color', 'structure' ),
- 'type' => Controls_Manager::COLOR,
- 'scheme' => [
- 'type' => Scheme_Color::get_type(),
- 'value' => Scheme_Color::COLOR_1,
- ],
- 'selectors' => [
- '{{WRAPPER}} .service-title a:hover,{{WRAPPER}} .overlay-cont2:hover' => 'color: {{VALUE}};',
- ],
- 'default' => '#293340',
- ]
- );
- $this->add_control(
- 'sub_title_color',
- [
- 'label' => __( 'Sub Title Color', 'structure' ),
- 'type' => Controls_Manager::COLOR,
- 'scheme' => [
- 'type' => Scheme_Color::get_type(),
- 'value' => Scheme_Color::COLOR_1,
- ],
- 'selectors' => [
- '{{WRAPPER}} .service-category' => 'color: {{VALUE}};',
- ],
- 'default' => '#6D7784',
- ]
- );
- $this->add_control(
- 'sub_title_hover_color',
- [
- 'label' => __( 'Sub Title Hover Color', 'structure' ),
- 'type' => Controls_Manager::COLOR,
- 'scheme' => [
- 'type' => Scheme_Color::get_type(),
- 'value' => Scheme_Color::COLOR_1,
- ],
- 'selectors' => [
- '{{WRAPPER}} .service-category:hover' => 'color: {{VALUE}};',
- ],
- 'default' => '#6D7784',
- ]
- );
- $this->add_control(
- 'title_bg_color',
- [
- 'label' => __( 'Background Color', 'structure' ),
- 'type' => Controls_Manager::COLOR,
- 'scheme' => [
- 'type' => Scheme_Color::get_type(),
- 'value' => Scheme_Color::COLOR_1,
- ],
- 'default' => '#ffffff',
- ]
- );
- $this->add_control(
- 'title_bg_color_stop',
- [
- 'label' => __( 'Background Color Stop', 'structure' ),
- 'type' => Controls_Manager::COLOR,
- 'scheme' => [
- 'type' => Scheme_Color::get_type(),
- 'value' => Scheme_Color::COLOR_1,
- ],
- 'selectors' => [
- '{{WRAPPER}} .layout_3 .service-item-content-in,{{WRAPPER}} .overlay-cont2,{{WRAPPER}} .service-items:hover .caption-full-width,{{WRAPPER}} .service-items:hover .service-layout2' => ' background-image: linear-gradient(190deg, {{title_bg_color.VALUE}} 0%, {{title_bg_color_stop.VALUE}} 100%);;',
- ],
- 'default' => '#ffffff',
- ]
- );
- $this->add_group_control(
- Group_Control_Typography::get_type(),
- [
- 'name' => 'typography',
- 'scheme' => Scheme_Typography::TYPOGRAPHY_1,
- 'selector' => '{{WRAPPER}} .service-title',
- ]
- );
- $this->add_group_control(
- Group_Control_Typography::get_type(),
- [
- 'name' => 'typography_2',
- 'scheme' => Scheme_Typography::TYPOGRAPHY_1,
- 'selector' => '{{WRAPPER}} .service-category',
- ]
- );
- $this->end_controls_section();
- }
- protected function render( ) {
- $settings = $this->get_settings();
- $service_cat = $settings['service_category'];
- if ($service_cat == 'All') {
- $args = array(
- 'post_type' => 'portfolio',
- 'posts_per_page' => $settings['service_number'],
- 'order' => $settings['service_order_by'],
- );
- }else{
- $args = array(
- 'post_type' => 'portfolio',
- 'posts_per_page' => $settings['service_number'],
- 'order' => $settings['service_order_by'],
- 'tax_query' => array(
- array(
- 'taxonomy' => 'portfolio-cat',
- 'field' => 'slug',
- 'terms' => esc_attr($service_cat),
- ),
- ),
- );
- }
- $data = new \WP_Query( $args );
- global $post;
- ?>
- <div class="filterable-service <?php echo $settings['service_layout']; ?>">
- <div class="container">
- <div class="row">
- <?php
- if ( $data->have_posts() ) :
- while ( $data->have_posts() ) : $data->the_post();
- $external_link = esc_attr(get_post_meta( get_the_ID(),'external_link',true));
- # category list
- $terms = get_the_terms( get_the_ID(), 'portfolio-cat' );
- $term_name = '';
- if (is_array( $terms )){
- foreach ( $terms as $term )
- {
- $term_name .= $term->slug.', ';
- }
- }
- $term_name = substr($term_name, 0, -2);
- ?>
- <div class="service-items col-<?php echo $settings['service_column'];?> <?php echo $term_name; ?>">
- <div class="service-single-items">
- <div class="service-thumb">
- <?php if(has_post_thumbnail( get_the_ID())) {
- $thumb = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID()), 'structure-portfo'); ?>
- <img class="img-responsive" src="<?php echo esc_url($thumb[0]); ?>" alt="">
- <?php } else { ?>
- <img class="img-responsive" src="<?php echo get_template_directory_uri(); ?>'/images/recipes.jpg" alt="<?php _e('image','structure'); ?>">
- <?php } ?>
- <?php if( $settings['service_layout'] == 'layout_1' ){ ?>
- <div class="caption-full-width">
- <div class="overlay-cont">
- <?php if ( $settings['service_show_title'] == 'yes' ) { ?>
- <a class="overlay-btn" href="<?php the_permalink( get_the_ID() ); ?>"><?php _e( 'View Case Study','structure'); ?></a>
- <?php } ?>
- </div>
- </div>
- <?php } ?>
- </div>
- <!-- Style 1 -->
- <?php if( $settings['service_layout'] == 'layout_1' ){ ?>
- <div class="service-item-content">
- <div class="service-item-content-in">
- <div>
- <?php if ( $settings['service_show_title'] == 'yes' ) { ?>
- <h3 class="service-title"><a href="<?php the_permalink( get_the_ID() ); ?>"><?php echo get_the_title( get_the_ID()) ?></a></h3>
- <?php } ?>
- <?php if ( $settings['service_show_category'] == 'yes' ) {
- if($term_name != '') { ?>
- <span class="service-category"><?php echo $term_name; ?></span>
- <?php }
- } ?>
- </div>
- </div>
- </div>
- <?php } ?>
- <!-- Style 2 -->
- <?php if( $settings['service_layout'] == 'layout_2' ){ ?>
- <div class="service-layout2">
- <?php if(has_post_thumbnail( get_the_ID() )) {
- $photo = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ),'full' ); ?>
- <a class="plus-icon cloud-zooms" href="<?php echo esc_url($photo[0]); ?>"><i class="fa fa-eye"></i></a>
- <?php } ?>
- <div class="overlay-cont2">
- <a href="<?php echo get_permalink(); ?>" class="plus-icon"><i class="sl-eye"></i></a>
- <?php if ( $settings['service_show_title'] == 'yes' ) { ?>
- <h3 class="service-title"><a href="<?php the_permalink( get_the_ID() ); ?>"><?php echo get_the_title( get_the_ID()) ?></a></h3>
- <?php } ?>
- <?php if ( $settings['service_show_category'] == 'yes' ) {
- if($term_name != '') { ?>
- <span class="service-category"><?php echo $term_name; ?></span>
- <?php }
- } ?>
- </div>
- </div>
- <?php } ?>
- </div>
- </div>
- <?php endwhile; ?>
- </div>
- </div>
- </div>
- <?php wp_reset_postdata(); endif; ?>
- <?php }
- }
- Plugin::instance()->widgets_manager->register_widget_type( new Widget_Themeum_Service() );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement