esc_html__('This Widget show masonry_post', 'buzmag') ) ); } /** * Helper function that holds widget fields * Array is used in update and form functions */ private function widget_fields() { $buzmag_cat_list = buzmag_Category_list_2(); $fields = array( 'bm_masonry_post_title' => array( 'buzmag_widgets_name' => 'bm_masonry_post_title', 'buzmag_widgets_title' => esc_html__('Masonory Secction Title', 'buzmag'), 'buzmag_widgets_field_type' => 'text', ), 'bm_masonry_post_category' => array( 'buzmag_widgets_name' => 'bm_masonry_post_category', 'buzmag_widgets_title' => esc_html__('Select Products Categorys', 'buzmag'), 'buzmag_widgets_field_type' => 'multicheckboxes', 'buzmag_widgets_field_options' => $buzmag_cat_list ), 'bm_masonry_post_posts' => array( 'buzmag_widgets_name' => 'bm_masonry_post_posts', 'buzmag_widgets_title' => esc_html__('Masonry Posts Number', 'buzmag'), 'buzmag_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); $bm_masonry_post_category_list = isset( $instance['bm_masonry_post_category'] ) ? $instance['bm_masonry_post_category'] : '' ; $bm_masonry_post_title = apply_filters( 'widget_title', empty( $instance['bm_masonry_post_title'] ) ? '' : $instance['bm_masonry_post_title'], $instance, $this->id_base ); $bm_masonry_post_posts = isset( $instance['bm_masonry_post_posts'] ) ? $instance['bm_masonry_post_posts'] : '' ; if($bm_masonry_post_posts == ''){ $bm_masonry_post_posts = -1; } echo $before_widget;?>
$bm_masonry_post_category){ $bm_term_get_name = get_cat_name($bm_masonry_post_cat_id); $bm_masonry_post_cat_slug_array[$bm_masonry_post_cat_id] = $bm_masonry_post_cat_id;?>
'post', 'order' => 'DESC', 'posts_per_page' => $bm_masonry_post_posts, 'post_status' => 'publish', 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'term_id', 'terms' => $bm_masonry_post_cat_slug_array, ), ), ); $buzmag_mas_post_query = new WP_Query($buzmag_mas_post_args); if($buzmag_mas_post_query->have_posts()){?>
have_posts()){ $buzmag_mas_post_query->the_post(); $buzmag_cats = get_the_category(); $buzmag_cat_list = ''; foreach ($buzmag_cats as $buzmag_cat) : $buzmag_cat_list .= 'category-' . $buzmag_cat->term_id . ' '; endforeach; $buzmag_img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'buzmag-portfolio-image'); ?>
widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $instance[$buzmag_widgets_name] = buzmag_widgets_updated_field_value($widget_field, $new_instance[$buzmag_widgets_name]); } return $instance; } public function form($instance) { $widget_fields = $this->widget_fields(); foreach ($widget_fields as $widget_field) { extract($widget_field); $buzmag_widgets_field_value = !empty($instance[$buzmag_widgets_name]) ? $instance[$buzmag_widgets_name] : ''; buzmag_widgets_show_widget_field($this, $widget_field, $buzmag_widgets_field_value); } } }