'widget_posts_in_box_format clearfix', 'description' => esc_html__( 'Display posts in box format', 'passport' ) ); parent::__construct( 'passport_posts_in_box_format_widget', esc_html__( 'Passport Posts in Box Format', 'passport' ), $widget_ops ); $this->alt_option_name = 'widget_posts_in_box_format'; } // Creating widget front-end // This is where the action happens public function widget( $args, $instance ) { global $passport_section_settings; global $passport_headline_column; $number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : 7; $category_name = ! empty( $instance['category_name'] ) ? $instance['category_name'] : 'uncategories'; $image_position = ! empty( $instance['image_position'] ) ? $instance['image_position'] : 'left' ; $exclude = ! empty( $instance['exclude'] ) ? $instance['exclude'] : ''; $excludeArry = explode( ',', $exclude); $image_position = ! empty( $instance['image_position'] ) ? $instance['image_position'] : 'left' ; $orderby = ! empty( $instance['orderby'] ) ? $instance['orderby'] : 'date'; $order = ! empty( $instance['order'] ) ? $instance['order'] : 'desc'; $tags = get_the_tags(); $theme_setting = get_theme_mod( 'passport_theme_setting', 'full_width_container' ); $big_box = 'full_width_container' == $theme_setting ? 'box-900-507' : 'box-760-400'; $small_box = 'full_width_container' == $theme_setting ? 'box-225-169' : 'box-240-168'; $widget_args = array( 'post_type' => 'post', 'category_name' => $category_name, 'posts_per_page' => $number, 'meta_key' => '_thumbnail_id', 'order' => $order, 'orderby' => $orderby, 'post__not_in' => $excludeArry ); $wp_query = new WP_Query( $widget_args ); ?>
have_posts() ) : ?> have_posts() ) : $wp_query->the_post(); ?> current_post == 0 ) : ?>
have_posts() ) : ?> have_posts() ) : $wp_query->the_post(); ?> current_post >= 1 ) : ?>
'7', 'category_name' => 'uncategories', 'exclude' => '', 'exclude' => '', 'image_position'=> 'left', 'orderby' => 'date', 'order' => 'desc' ) ); $number = $instance['number']; $exclude = $instance['exclude']; // Widget admin form ?>



slug . ''; } $image_position_array = array( 'left', 'right' ); $orderbyArry = array( 'none', 'date', 'author', 'title', 'name', 'parent', 'type', 'modified', 'rand' ); $orderArry = array( 'desc', 'asc' ); //Update new instances $instance['number'] = (int) $new_instance['number']; if ( in_array( $new_instance['category_name'], $catsArray ) ) { $instance['category_name'] = $new_instance['category_name']; } else { $instance['category_name'] = 'uncategories'; } $instance['exclude'] = wp_filter_nohtml_kses( $new_instance['exclude'] ); if ( in_array( $new_instance['image_position'], $image_position_array ) ) { $instance['image_position'] = $new_instance['image_position']; } else { $instance['image_position'] = 'left'; } if ( in_array( $new_instance['orderby'], $orderbyArry ) ) { $instance['orderby'] = $new_instance['orderby']; } else { $instance['orderby'] = 'date'; } if ( in_array( $new_instance['order'], $orderArry ) ) { $instance['order'] = $new_instance['order']; } else { $instance['order'] = 'desc'; } return $instance; } } // Class widget ends here // Register and load the widget function passport_posts_in_box_format_load_widget() { register_widget( 'Passport_Posts_In_Box_Format_Widget' ); } add_action( 'widgets_init', 'passport_posts_in_box_format_load_widget' );