MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/cafsindia/public_html/wp-content/themes/excitor/framework/widgets/news_tabs.php
<?php
class excitor_New_Tabs_Widget extends WP_Widget {
    function __construct() {
        parent::__construct(
                'excitor_news_tabs_widget', // Base ID
                esc_html__('News Tabs', 'excitor'), // Name
                array('description' => esc_html__('News Tabs Widget', 'excitor'),) // Args
        );
    }
    function widget($args, $instance) {
	
        extract($args);
		
        $posts = $instance['posts'];

        $extra_class = !empty($instance['extra_class']) ? $instance['extra_class'] : "";

        // no 'class' attribute - add one with the value of width
        if( strpos($before_widget, 'class') === false ) {
            $before_widget = str_replace('>', 'class="'. $extra_class . '"', $before_widget);
        }
        // there is 'class' attribute - append width value to it
        else {
            $before_widget = str_replace('class="', 'class="'. $extra_class . ' ', $before_widget);
        }

        echo apply_filters('bt_before_widget_filter', $before_widget);
        ?>
        <div class="tab-holder">
            <div class="tab-hold tabs-wrapper">
                <ul id="tabs" class="nav nav-tabs">
					<li class="active bt-tab" ><a href="#tab1" data-toggle="tab" ><?php esc_html_e('Recent Post', 'excitor'); ?></a></li>
					<li class="bt-tab"><a href="#tab2" data-toggle="tab" ><?php esc_html_e('Popular Post', 'excitor'); ?></a></li>
                </ul>
                <div class="tab-content">
					<div id="tab1" class="tab-pane active">
						<?php
							$recent_posts = new WP_Query('showposts=' . $posts);
							if ($recent_posts->have_posts()):
						?>
							<ul class="bt-news-list bt-recent">
								<?php while ($recent_posts->have_posts()): $recent_posts->the_post(); ?>
									<li>
										<div class="bt-thumb">
											<a class="post-featured-img" href="<?php the_permalink(); ?>">
											   <?php if(has_post_thumbnail()) the_post_thumbnail('thumbnail'); ?>
											</a>
										</div>
										<div class="bt-details">
											<div class="bt-inner">
												<h3 class="bt-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
												<ul class="bt-meta">
													<li class="bt-author"><?php echo esc_html__('By ', 'excitor').get_the_author(); ?></li>
													<li class="bt-public"><?php echo get_the_date('d M, Y'); ?></li>
												</ul>
											</div>
										</div>
									</li>
								<?php endwhile; ?>
							</ul>
						<?php endif; ?>
					</div>
					<div id="tab2" class="tab-pane">
						<?php
							$popular_posts = new WP_Query('showposts=' . $posts . '&orderby=comment_count&order=DESC');
							if ($popular_posts->have_posts()):
						?>
							<ul class="bt-news-list bt-popular">
								<?php while ($popular_posts->have_posts()): $popular_posts->the_post(); ?>
									<li>
										<div class="bt-thumb">
											<a class="post-featured-img" href="<?php the_permalink(); ?>">
											   <?php if(has_post_thumbnail()) the_post_thumbnail('thumbnail'); ?>
											</a>
										</div>
										<div class="bt-details">
											<div class="bt-inner">
												<h3 class="bt-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
												<ul class="bt-meta">
													<li class="bt-author"><?php echo esc_html__('By ', 'excitor').get_the_author(); ?></li>
													<li class="bt-public"><?php echo get_the_date('d M, Y'); ?></li>
												</ul>
											</div>
										</div>
									</li>
								<?php endwhile; ?>
							</ul>
						<?php endif; ?>
					</div>
                </div>
            </div>
        </div>
        <?php
        echo apply_filters('bt_after_widget_filter', $after_widget);
    }

    function update($new_instance, $old_instance) {
        $instance = $old_instance;

        $instance['posts'] = $new_instance['posts'];
        $instance['extra_class'] = $new_instance['extra_class'];

        return $instance;
    }

    function form($instance) {
        $defaults = array('posts' => 3);
        $instance = wp_parse_args((array) $instance, $defaults);
        ?>
        <p>
            <label for="<?php echo esc_attr($this->get_field_id('posts')); ?>">Number of popular posts:</label>
            <input class="widefat" style="width: 30px;" id="<?php echo esc_attr($this->get_field_id('posts')); ?>" name="<?php echo esc_attr($this->get_field_name('posts')); ?>" value="<?php echo esc_attr($instance['posts']); ?>" />
        </p>
        <?php
    }
}
/**
 * Class excitor_New_Tabs_Widget
 */
function register_new_tabs_widget() {
    register_widget('excitor_New_Tabs_Widget');
}
add_action('widgets_init', 'register_new_tabs_widget');
?>