esc_html__('This Widget show Category Posts On Tab.', 'allrounder-news') ) ); } /** * Helper function that holds widget fields * Array is used in update and form functions */ private function widget_fields() { $allrounder_news_Category_list = allrounder_news_Category_list($select = false); $fields = array( 'allrounder_news_section_title' => array( 'allrounder_news_widgets_name' => 'allrounder_news_section_title', 'allrounder_news_widgets_title' => esc_html__('Section Title', 'allrounder-news'), 'allrounder_news_widgets_field_type' => 'text', ), 'allrounder_news_blog_cat_category' => array( 'allrounder_news_widgets_name' => 'allrounder_news_blog_cat_category', 'allrounder_news_widgets_title' => esc_html__('Select Post Categories', 'allrounder-news'), 'allrounder_news_widgets_field_type' => 'multicheckboxes', 'allrounder_news_widgets_field_options' => $allrounder_news_Category_list ), 'allrounder_news_blog_posts' => array( 'allrounder_news_widgets_name' => 'allrounder_news_blog_posts', 'allrounder_news_widgets_title' => esc_html__('Posts Per Page', 'allrounder-news'), 'allrounder_news_widgets_field_type' => 'number', ), ); return $fields; } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { extract($args); $widget_title = apply_filters( 'widget_title', empty( $instance['allrounder_news_section_title'] ) ? '' : $instance['allrounder_news_section_title'], $instance, $this->id_base ); $allrounder_news_blog_cat_categories = isset( $instance['allrounder_news_blog_cat_category'] ) ? $instance['allrounder_news_blog_cat_category'] : '' ; $allrounder_news_blog_posts = isset( $instance['allrounder_news_blog_posts'] ) ? $instance['allrounder_news_blog_posts'] : '' ; if( empty( $allrounder_news_blog_posts ) ){ $allrounder_news_blog_posts = '5'; } echo $before_widget; if( $widget_title || $allrounder_news_blog_cat_categories ){ ?>
$value){ ?>
'post', 'posts_per_page' => $allrounder_news_blog_posts, 'category_name' => $key ) ); if( $tac_cat_query->have_posts() ){ $allrounder_news_content_post_count = '1'; while( $tac_cat_query->have_posts() ){ $tac_cat_query->the_post(); if($allrounder_news_content_post_count == '1'){ ?>
have_posts() ){ $tac_cat_query->the_post(); if($sec_loop_count != '1'){?>

widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $instance[$allrounder_news_widgets_name] = allrounder_news_widgets_updated_field_value($widget_field, $new_instance[$allrounder_news_widgets_name]); } return $instance; } public function form($instance) { $widget_fields = $this->widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $allrounder_news_widgets_field_value = !empty($instance[$allrounder_news_widgets_name]) ? $instance[$allrounder_news_widgets_name] : ''; allrounder_news_widgets_show_widget_field($this, $widget_field, $allrounder_news_widgets_field_value); } } }