esc_html__( 'Displays latest posts or posts from a choosen category.', 'pridmag' ), ) // Args ); } /** * Back-end widget form. * * @see WP_Widget::form() * * @param array $instance Previously saved values from database. */ public function form( $instance ) { $defaults = array( 'title' => esc_html__( 'Latest Posts', 'pridmag' ), 'category' => 'all', 'number_posts' => 3, 'show_excerpt' => true, 'viewall_text' => esc_html__( 'View All', 'pridmag' ) ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>
$this->get_field_name('category'), 'selected' => $instance['category'], 'show_option_all' => esc_html__( 'Show latest posts', 'pridmag' ), 'class' => 'widefat' ) ); ?>
class="checkbox" id="get_field_id('show_excerpt'); ?>" name="get_field_name('show_excerpt'); ?>" />
id_base ); $category = ( ! empty( $instance['category'] ) ) ? absint( $instance['category'] ) : ''; $number_posts = ( ! empty( $instance['number_posts'] ) ) ? absint( $instance['number_posts'] ) : 3; $show_excerpt = ( isset( $instance['show_excerpt'] ) ) ? $instance['show_excerpt'] : true; $viewall_text = ( ! empty( $instance['viewall_text'] ) ) ? $instance['viewall_text'] : ''; // Latest Posts $latest_posts = new WP_Query( array( 'cat' => $category, 'posts_per_page' => $number_posts, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, ) ); echo $before_widget; if ( ! empty($title) ) { echo $before_title. $title . $after_title; } pridmag_viewall_link( $category, $viewall_text ); ?>