'widget-posts widget-posts__recent', 'description' => esc_html__( 'Displays the Recent posts.', 'dotspice' ) ) ); } /** * Outputs the content of the widget * * @param array $args * @param array $instance */ public function widget( $args, $instance ) { extract( $args ); $widget_title = ! empty( $instance['widget_title'] ) ? apply_filters( 'widget_title', $instance['widget_title'] ) : ''; $display_thumb = ! empty( $instance['display_thumb'] ) ? (bool) $instance['display_thumb'] : false; $display_date = ! empty( $instance['display_date'] ) ? (bool) $instance['display_date'] : false; $posts_per_page = ! empty( $instance['per_page'] ) ? absint( $instance['per_page'] ) : 4; $categories = ! empty( $instance['categories'] ) ? (array) $instance['categories'] : array( 'all' ); if ( $posts_per_page < 1 ) { $posts_per_page = 1; } echo wp_kses_post( $before_widget ); if ( $widget_title ) { echo wp_kses_post( $before_title . $widget_title . $after_title ); } // Set Query $query_args = array( 'posts_per_page' => $posts_per_page, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => 'date', 'order' => 'DESC', ); if ( ! empty( $categories ) && ! in_array( 'all', $categories ) ) { $query_args['cat'] = implode( ',', $categories ); } if( is_single() ){ $query_args['post__not_in'] = array( get_queried_object()->ID ); } $widget_query = new WP_Query( $query_args ); // Start the Loop if ( $widget_query->have_posts() ) : ?>
have_posts() ) : $widget_query->the_post(); ?>
> true ), array( 'class' => 'widget-post__img' ) ); } else { echo wp_get_attachment_image( 18, array( 70, 70, 'bfi_thumb' => true ) ); } ?>

' . wp_kses( __( 'Ready to publish your first post? Get started here.', 'dotspice' ), array( 'a' => array( 'href' => array() ) ) ) . '

', esc_url( admin_url( 'post-new.php' ) ) ); endif; wp_reset_postdata(); echo wp_kses_post( $after_widget ); } /** * Outputs the options form on admin * * @param array $instance The widget options */ public function form( $instance ) { $widget_title = isset( $instance['widget_title'] ) ? strip_tags( $instance['widget_title'] ) : esc_html__( 'Recent Posts', 'dotspice' ); $display_thumb = isset( $instance['display_thumb'] ) ? (bool) $instance['display_thumb'] : false; $display_date = isset( $instance['display_date'] ) ? (bool) $instance['display_date'] : false; $posts_per_page = isset( $instance['per_page'] ) ? intval( $instance['per_page'] ) : 4; $categories = isset( $instance['categories'] ) ? $instance['categories'] : array( 'all' ); $all_categories = get_categories( 'orderby=name&hide_empty=0' ); ?>

  />

  />