esc_html__('A widget that shows category Posts with single large images list view', 'black-magazine') ) ); } /** * Helper function that holds widget fields * Array is used in update and form functions */ private function widget_fields() { $args = array( 'type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'taxonomy' => 'category', ); $multi_categories = get_categories( $args ); $mag_categories_lists = array(); foreach( $multi_categories as $multi_categorie ) { $mag_categories_lists[$multi_categorie->term_id] = $multi_categorie->name; } $fields = array( 'six_block_title' => array( 'spidermag_widgets_name' => 'six_block_title', 'spidermag_widgets_title' => esc_html__('Title', 'black-magazine'), 'spidermag_widgets_field_type' => 'title', ), 'six_block_list_category' => array( 'spidermag_widgets_name' => 'six_block_list_category', 'spidermag_mulicheckbox_title' => esc_html__('Select Block Category', 'black-magazine'), 'spidermag_widgets_field_type' => 'multicheckboxes', 'spidermag_widgets_field_options' => $mag_categories_lists ), 'six_block_post_order' => array( 'spidermag_widgets_name' => 'six_block_post_order', 'spidermag_widgets_title' => esc_html__('Display Posts Order', 'black-magazine'), 'spidermag_widgets_field_type' => 'select', 'spidermag_widgets_field_options' => array('desc' => 'Deaccessing Order', 'asc' => 'Accessing Order' ) ) ); return $fields; } public function widget($args, $instance) { extract($args); extract($instance); $six_block_title = empty( $instance['six_block_title'] ) ? '' : $instance['six_block_title']; $six_block_post_order = empty( $instance['six_block_post_order'] ) ? 'des ' : $instance['six_block_post_order']; $six_block_list_category = empty($instance['six_block_list_category']) ? 0 : $instance['six_block_list_category']; $multi_left_cat_id = array(); if(!empty($six_block_list_category)){ $multi_left_cat_id = array_keys( unserialize($six_block_list_category)); } $get_grid_list_posts = get_posts( array( 'posts_per_page' => 9, 'post_type' => 'post', 'category__in' => $multi_left_cat_id, 'order' => $six_block_post_order, 'ignore_sticky_posts' => true ) ); $first_column_posts = $mid_column_posts = $last_column_posts = array(); if($get_grid_list_posts){ $first_column_posts = array_slice($get_grid_list_posts, 0, 2); $mid_column_posts = array_slice($get_grid_list_posts, 2, 1); $last_column_posts = array_slice($get_grid_list_posts, 3, 6); } echo $before_widget; ?>