'suki_widget_posts', 'description' => esc_html__( 'Posts list with thumbnail images', 'suki' ), 'customize_selective_refresh' => true, ) ); } public function widget( $args, $instance ) { if ( ! isset( $args['widget_id'] ) ) { $args['widget_id'] = $this->id; } $cats = get_categories(); $category_default = array(); foreach ( $cats as $cat ) $category_default[] = $cat->term_id; $title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) : ''; $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; $orderby = isset( $instance['orderby'] ) ? sanitize_key( $instance['orderby'] ) : 'post_date'; $all_categories = isset( $instance['all_categories'] ) ? (bool) $instance['all_categories'] : false; $category = isset( $instance['category'] ) ? $instance['category'] : $category_default; $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false; $query_args = array( 'post_type' => 'post', 'posts_per_page' => $number, 'ignore_sticky_posts' => 1, 'orderby' => $orderby, ); if ( ! $all_categories ) $query_args['cat'] = implode( ',', $category ); $query = new WP_Query( $query_args ); if ( $query->have_posts() ) : ob_start(); echo $args['before_widget']; // WPCS: XSS OK echo ! empty( $title ) ? $args['before_title'] . $title . $args['after_title'] : ''; // WPCS: XSS OK ?> esc_html__( 'Recent Published', 'suki' ), 'rand' => esc_html__( 'Random', 'suki' ), ); $title = isset( $instance['title'] ) ? sanitize_text_field( $instance['title'] ) : ''; $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; $orderby = isset( $instance['orderby'] ) ? sanitize_key( $instance['orderby'] ) : 'post_date'; $all_categories = isset( $instance['all_categories'] ) ? (bool) $instance['all_categories'] : false; $category = isset( $instance['category'] ) ? $instance['category'] : array(); $show_date = isset( $instance['show_date'] ) ? (bool) $instance['show_date'] : false; ?>