esc_html__('This Widget show Random Category Posts.', '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 Column', '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'] : '5' ; if($allrounder_news_blog_posts == ''){ $allrounder_news_blog_posts = '5'; } echo $before_widget; if( $widget_title || $allrounder_news_blog_cat_categories ){ ?>