'maizzy_widget_tabbed', 'description' => esc_html__('Tabbed widget.', 'maizzy'), ); $fields = array( 'popular_heading' => array( 'label' => esc_html__('Popular', 'maizzy'), 'type' => 'heading', ), 'popular_post_title' => array( 'label' => esc_html__('Popular Posts Title', 'maizzy'), 'type' => 'text', 'default' => esc_html__('Popular', 'maizzy'), ), 'popular_number' => array( 'label' => esc_html__('No. of Posts:', 'maizzy'), 'type' => 'number', 'css' => 'max-width:60px;', 'default' => 5, 'min' => 1, 'max' => 10, ), 'select_image_size' => array( 'label' => esc_html__('Select Image Size Featured Post:', 'maizzy'), 'type' => 'select', 'default' => 'medium', 'options' => array( 'thumbnail' => esc_html__('Thumbnail', 'maizzy'), 'medium' => esc_html__( 'Medium', 'maizzy' ), 'large' => esc_html__( 'Large', 'maizzy' ), 'full' => esc_html__( 'Full', 'maizzy' ), ), ), 'excerpt_length' => array( 'label' => esc_html__('Excerpt Length:', 'maizzy'), 'description' => esc_html__('Number of words', 'maizzy'), 'default' => 10, 'css' => 'max-width:60px;', 'min' => 0, 'max' => 200, ), 'recent_heading' => array( 'label' => esc_html__('Recent', 'maizzy'), 'type' => 'heading', ), 'recent_post_title' => array( 'label' => esc_html__('Recent Posts Title', 'maizzy'), 'type' => 'text', 'default' => esc_html__('Recent', 'maizzy'), ), 'recent_number' => array( 'label' => esc_html__('No. of Posts:', 'maizzy'), 'type' => 'number', 'css' => 'max-width:60px;', 'default' => 5, 'min' => 1, 'max' => 10, ), 'comments_heading' => array( 'label' => esc_html__('Comments', 'maizzy'), 'type' => 'heading', ), 'comments_post_title' => array( 'label' => esc_html__('Comments Posts Title', 'maizzy'), 'type' => 'text', 'default' => esc_html__('Comments', 'maizzy'), ), 'comments_number' => array( 'label' => esc_html__('No. of Comments:', 'maizzy'), 'type' => 'number', 'css' => 'max-width:60px;', 'default' => 5, 'min' => 1, 'max' => 10, ), ); parent::__construct( 'maizzy-tabbed', esc_html__( 'MP: Tab Posts Widget', 'maizzy' ), $opts, array(), $fields ); } /** * Outputs the content for the current widget instance. * * @since 1.0.0 * * @param array $args Display arguments. * @param array $instance Settings for the current widget instance. */ function widget( $args, $instance ) { $params = $this->get_params( $instance ); $tab_id = 'tabbed-'.$this->number; echo $args['before_widget']; ?>
$params['popular_number'], 'no_found_rows' => true, 'orderby' => 'comment_count', 'category_name' => $cat_slug, ); break; case 'recent': $cat_slug = ''; if( isset( $params['tab_cat'] ) ){ $cat_slug = $params['tab_cat']; } $qargs = array( 'posts_per_page' => $params['recent_number'], 'no_found_rows' => true, 'category_name' => $cat_slug, ); break; default: break; } $tab_posts_query = new WP_Query( $qargs ); if ( $tab_posts_query->have_posts() ): ?> 10, 'no_found_rows' => true, 'category_name' => $cat_slug, ); $tab_posts_query = new WP_Query( $qargs ); if ( $tab_posts_query->have_posts() ){ while ( $tab_posts_query->have_posts() ){ $tab_posts_query->the_post(); $post_array[] = get_the_ID(); } wp_reset_postdata(); } } $comment_args = array( 'number' => $params['comments_number'], 'status' => 'approve', 'post_status' => 'publish', 'post__in' => $post_array, ); $comments = get_comments( $comment_args ); ?>