PATH:
home
/
letacommog
/
aperobusiness
/
wp-content
/
themes
/
deep
/
inc
/
core
/
elementor
/
widgets
<?php namespace Elementor; class Webnus_Element_Widgets_CategoryTab extends \Elementor\Widget_Base { /** * Retrieve Info Box widget name. * * @since 1.0.0 * @access public * * @return string Widget name. */ public function get_name() { return 'category_tab'; } /** * Retrieve Info Box widget title. * * @since 1.0.0 * @access public * * @return string Widget title. */ public function get_title() { return esc_html__( 'Webnus Category Tab', 'deep' ); } /** * Retrieve Info Box widget icon. * * @since 1.0.0 * @access public * * @return string Widget icon. */ public function get_icon() { return 'ti-layout-tab-v'; } /** * Set widget category. * * @since 1.0.0 * @access public * * @return array Widget category. */ public function get_categories() { return [ 'webnus' ]; } /** * enqueue JS * * @since 1.0.0 * @access public * */ public function get_script_depends() { return [ 'cat-tab' ]; } /** * Register Info Box widget controls. * * * @since 1.0.0 * @access protected */ protected function _register_controls() { $categories = array(); $categories = get_categories(); $category_slug_array = array(''); $category_name_array = array(''); foreach( $categories as $category ) { $category_slug_array[] = $category->name; $category_name_array[] = $category->slug; } $category_array = array_combine($category_name_array, $category_slug_array); // Content Tab $this->start_controls_section( 'content_sectiona', [ 'label' => esc_html__( 'General Options', 'deep' ), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'param_category', [ 'label' => esc_html__( 'Choose Categories', 'deep' ), 'type' => \Elementor\Controls_Manager::SELECT2, 'multiple' => true, 'options' => $category_array, ] ); $this->add_control( 'sort_order', //param_name [ 'label' => esc_html__( 'Sort order', 'deep' ), //heading 'type' => \Elementor\Controls_Manager::SELECT, //type 'default' => 'date', 'options' => [ //value 'date' => esc_html__( 'Date', 'deep' ), 'title' => esc_html__( 'Title', 'deep' ), 'comment_count' => esc_html__( 'Popular Post', 'deep' ), 'latest' => esc_html__( 'Recent Posts', 'deep' ), 'rand' => esc_html__( 'Random Post', 'deep' ), 'modified' => esc_html__( 'Last Modified Post', 'deep' ), ], ] ); $this->add_control( 'p_cat', //param_name [ 'label' => __( 'Post Category', 'deep' ), //heading 'type' => \Elementor\Controls_Manager::SWITCHER, //type 'label_on' => __( 'Show', 'deep' ), 'label_off' => __( 'Hide', 'deep' ), 'return_value' => 'show', ] ); $this->add_control( 'p_date', //param_name [ 'label' => __( 'Post Date', 'deep' ), //heading 'type' => \Elementor\Controls_Manager::SWITCHER, //type 'label_on' => __( 'Show', 'deep' ), 'label_off' => __( 'Hide', 'deep' ), 'return_value' => 'show', ] ); $this->end_controls_section(); // Class & ID Tab $this->start_controls_section( 'classid_section', [ 'label' => esc_html__( 'Class & ID', 'deep' ), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'shortcodeclass', [ 'label' => esc_html__( 'Extra Class', 'deep' ), 'type' => Controls_Manager::TEXT, ] ); $this->add_control( 'shortcodeid', [ 'label' => esc_html__( 'ID', 'deep' ), 'type' => Controls_Manager::TEXT, ] ); $this->end_controls_section(); // Custom css tab $this->start_controls_section( 'custom_css_section', [ 'label' => __( 'Custom CSS', 'deep' ), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'custom_css', [ 'label' => __( 'Custom CSS', 'deep' ), 'type' => \Elementor\Controls_Manager::CODE, 'language' => 'css', 'rows' => 20, 'show_label' => true, ] ); $this->end_controls_section(); } /** * Render Info Box widget output on the frontend. * * * @since 1.0.0 * @access protected */ protected function render() { $settings = $this->get_settings(); // glob variables global $post; $post_slug = $post->post_name; // Class & ID $shortcodeclass = $settings['shortcodeclass'] ? $settings['shortcodeclass'] : ''; $shortcodeid = $settings['shortcodeid'] ? ' id="' . $settings['shortcodeid'] . '"' : ''; $sort_order = !empty( $settings['sort_order'] ) ? $settings['sort_order'] : ''; $post_number = '8'; static $uniqid = 0; $uniqid++; $cat_ids = ''; if ( !empty( $settings['param_category'] ) ) : $arrayKeys = array_keys($settings['param_category']); $lastArrayKey = array_pop($arrayKeys); foreach ( $settings['param_category'] as $key => $value ) { $get_cat = get_category_by_slug($value); if($key == $lastArrayKey) { $get_cat_id = $get_cat->term_id; } else { $get_cat_id = $get_cat->term_id . ','; } $cat_ids .= $get_cat_id; } endif; $args = array( 'post_type' => 'post', 'posts_per_page' => -1, 'cat' => $cat_ids, 'orderby' => $sort_order ); $out = ''; $category_tab = new \WP_Query( $args ); $custom_css = $settings['custom_css']; if ( $custom_css != '' ) { echo '<style>'. $custom_css .'</style>'; } ?> <div class="wn-category-wrap clearfix <?php echo '' . $shortcodeclass; ?>" <?php echo $shortcodeid; ?>> <?php if ( !empty( $settings['param_category'] ) ) { ?> <ul class="wn-category-tab-nav"> <?php $category_list = ' <li class="active" data-cat-slug="all"> <a href="' . get_permalink( get_option( 'page_for_posts' ) ) . '" class="all cat-item colorf" data-param_category="all"> ' . esc_html__( 'All', 'deep' ) . ' </a> </li>'; ?> <?php foreach( $settings['param_category'] as $id => $cat_slug ) { $get_cats = get_category_by_slug($cat_slug); $get_cats_id = $get_cats->term_id; if ( $cat_slug != null ) { $category_list .=' <li data-cat-slug="' . $cat_slug . '"> <a href="' . get_category_link( $get_cats_id ) . '" data-cat-slug="all ' . $cat_slug . '" class="cat-item"> ' . get_the_category_by_ID( $get_cats_id ) . ' </a> </li>'; } } echo '' . $category_list; ?> </ul> <?php } ?> <div class="wn-category-posts clearfix" data-cat-slug="all"><?php if ( $category_tab->have_posts() ) { // The 2nd Loop while ( $category_tab->have_posts() ) { $category_tab->the_post(); // $cat_id = the_category_ID( $echo = false ); // thumbnail $thumbnail_url = get_the_post_thumbnail_url( $category_tab->post->ID ); $thumbnail_id = get_post_thumbnail_id( $category_tab->post->ID ); if( !empty( $thumbnail_url ) ) { // if main class not exist get it if ( !class_exists( 'Wn_Img_Maniuplate' ) ) { require_once DEEP_CORE_DIR . 'helper-classes/class_webnus_manuplate.php'; } $image = new \Wn_Img_Maniuplate; // instance from settor class $thumbnail_url = $image->m_image( $thumbnail_id, $thumbnail_url , '315' , '217' ); // set required and get result } ?> <div class="wn-category-tab <?php echo '' . $uniqid; ?> wn-pagination active" data-cat-slug="<?php echo get_the_terms( get_the_ID(), 'category' )[0]->slug; ?>"> <article class="wn-category"> <?php if( !empty($thumbnail_url) ): ?> <a href="<?php the_permalink() ?>"> <img src="<?php echo '' . $thumbnail_url; ?> " alt="<?php the_title($category_tab->post->ID); ?>"> </a> <?php endif ?> <div class="wn-tab-cat-content"> <?php if ( $settings['p_cat'] == 'show' ) { ?> <div class="wn-category-meta" style="background: <?php echo deep_category_color(); ?>;"> <?php echo the_category(', '); ?> </div> <?php } ?> <?php if ( $settings['p_date'] == 'show' ) { ?> <div class="wn-category-date"> <i class="pe-7s-clock"></i> <?php echo get_the_date(); ?> </div> <?php } ?> <h5 class="wn-category-title"><a class="hcolorf" href="<?php the_permalink($category_tab->post->ID); ?>"><?php the_title(); ?></a></h5> </div> </article> </div> <?php } // pagination // if ( $pagination ) { // echo ' // <div class="pagination"> // <a class="wn-cat-tab-previous" data-type="previous"><i class="ti-arrow-left"></i></a> // <a class="wn-cat-tab-next" data-type="next"><i class="ti-arrow-right"></i></a> // </div>'; // } // Restore original Post Data wp_reset_postdata(); }?> </div> </div> <?php } }
[+]
..
[-] our-client.php
[edit]
[-] icons.php
[edit]
[-] collection.php
[edit]
[-] testimonial-tab.php
[edit]
[-] teaserbox.php
[edit]
[-] instagram.php
[edit]
[-] our-team.php
[edit]
[-] content-carousel.php
[edit]
[-] videoteaser.php
[edit]
[-] like-view-share.php
[edit]
[-] courses-instructors.php
[edit]
[-] widget-flickr.php
[edit]
[-] reservation.php
[edit]
[-] list.php
[edit]
[-] road-map.php
[edit]
[-] max-counter.php
[edit]
[-] magazine.php
[edit]
[-] prayer-wall-items.php
[edit]
[-] facebook-button.php
[edit]
[-] icon-divider.php
[edit]
[-] featured-products.php
[edit]
[-] review-items.php
[edit]
[-] iconbox.php
[edit]
[-] widget-googleplus.php
[edit]
[-] content-slider.php
[edit]
[-] service-carousel.php
[edit]
[-] contact-form.php
[edit]
[-] twitter-feed.php
[edit]
[-] blog.php
[edit]
[-] process-carousel.php
[edit]
[-] course-category.php
[edit]
[-] virtual-coins.php
[edit]
[-] speakers.php
[edit]
[-] the-grid.php
[edit]
[-] custom-menu.php
[edit]
[-] widget-youtube.php
[edit]
[-] testimonial.php
[edit]
[-] callout.php
[edit]
[-] testimonial-slider.php
[edit]
[-] category-tab.php
[edit]
[-] testimonial-carousel.php
[edit]
[-] button.php
[edit]
[-] facebook-comments.php
[edit]
[-] widget-login.php
[edit]
[-] subscribe.php
[edit]
[-] googlemap.php
[edit]
[-] widget-social-icon.php
[edit]
[-] postslider.php
[edit]
[-] alert.php
[edit]
[-] video-play-button.php
[edit]
[-] quote.php
[edit]
[-] donate.php
[edit]
[-] dropcap.php
[edit]
[-] before-after-image.php
[edit]
[-] pricing-tables.php
[edit]
[-] facebook-page.php
[edit]
[-] shop-products.php
[edit]
[-] single-goal.php
[edit]
[-] info-box.php
[edit]
[-] latestfromblog.php
[edit]
[-] goals.php
[edit]
[-] revolution-slider.php
[edit]
[-] widget-subscribe.php
[edit]
[-] tablepress.php
[edit]
[-] tab-content.php
[edit]
[-] schedule.php
[edit]
[-] sermon-category.php
[edit]
[-] pricing-plan.php
[edit]
[-] tabs.php
[edit]
[-] widget-latest-posts.php
[edit]
[-] distance.php
[edit]
[-] widget-popular-posts.php
[edit]
[-] recipes.php
[edit]
[-] causes.php
[edit]
[-] widget-testimonial.php
[edit]
[-] widget-about.php
[edit]
[-] special-offers.php
[edit]
[-] tooltip.php
[edit]
[-] food-menu.php
[edit]
[-] wp-hotel-booking.php
[edit]
[-] widget-tab.php
[edit]
[-] courses.php
[edit]
[-] login.php
[edit]
[-] post-from-blog.php
[edit]
[-] socials.php
[edit]
[-] line.php
[edit]
[-] gallery.php
[edit]
[-] faq.php
[edit]
[-] piecharts.php
[edit]
[-] image-hotspot.php
[edit]
[-] link.php
[edit]
[-] prayer-wall-form.php
[edit]
[-] rooms.php
[edit]
[-] countdown.php
[edit]
[-] portfolio-carousel.php
[edit]
[-] facebook-embed.php
[edit]
[-] single-cause.php
[edit]
[-] review-form.php
[edit]
[-] buy-process.php
[edit]
[-] sermons.php
[edit]
[-] widget-facebook.php
[edit]
[-] single-sermon.php
[edit]
[-] single-course.php
[edit]
[-] image-carousel.php
[edit]
[-] toggle-box.php
[edit]
[-] our-process.php
[edit]
[-] svg.php
[edit]
[-] w-title.php
[edit]
[-] block-quote.php
[edit]