prefix = framework_get_prefix(); /* Set up the widget options. */ $widget_options = array( 'classname' => 'recent-posts', 'description' => esc_html__( 'Display your site\'s recent posts.', 'wordsmith' ) ); /* Set up the widget control options. */ $control_options = array( 'width' => 200, 'height' => 350 ); /* Create the widget. */ $this->WP_Widget( "{$this->prefix}-recent-posts", __( 'Recent Posts', 'wordsmith' ), $widget_options, $control_options ); } /* Outputs the widget based on the arguments input through the widget controls. */ function widget( $args, $instance ) { extract( $args ); /* Arguments for the widget. */ $args['category'] = $instance['category']; $args['order'] = $instance['order']; $args['orderby'] = $instance['orderby']; /* Output the theme's $before_widget wrapper. */ echo $before_widget; /* If a title was input by the user, display it. */ if ( !empty( $instance['title'] ) ) echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title; ?> $instance['category'], 'order' => $instance['order'], 'orderby' => $instance['orderby'], 'post__not_in' => get_option( 'sticky_posts' ), 'posts_per_page' => intval( $instance['limit'] ), 'post_status' => 'publish', 'tax_query' => array( array( 'field' => 'slug', 'operator' => 'NOT IN', 'taxonomy' => 'post_format', 'terms' => array( 'post-format-aside', 'post-format-audio', 'post-format-chat', 'post-format-gallery', 'post-format-image', 'post-format-link', 'post-format-link', 'post-format-quote', 'post-format-status', 'post-format-video' ) ) ) ) ) ); } else { $wp_query = new WP_Query( apply_filters( 'widget_posts_args', array( 'cat' => $instance['category'], 'meta_key' => 'Views', 'order' => $instance['order'], 'orderby' => 'meta_value_num', 'post__not_in' => get_option( 'sticky_posts' ), 'posts_per_page' => intval( $instance['limit'] ), 'post_status' => 'publish', 'tax_query' => array( array( 'field' => 'slug', 'operator' => 'NOT IN', 'taxonomy' => 'post_format', 'terms' => array( 'post-format-aside', 'post-format-audio', 'post-format-chat', 'post-format-gallery', 'post-format-image', 'post-format-link', 'post-format-link', 'post-format-quote', 'post-format-status', 'post-format-video' ) ) ) ) ) ); } ?> have_posts() ) : ?> __( 'Recent Posts', 'wordsmith' ), 'order' => 'DESC', 'orderby' => 'date', 'limit' => '4' ); /* Merge the user-selected arguments with the defaults. */ $instance = wp_parse_args( (array) $instance, $defaults ); /* Select element options. */ $order = array( 'ASC' => esc_attr__( 'Ascending', 'wordsmith' ), 'DESC' => esc_attr__( 'Descending', 'wordsmith' ) ); $orderby = array( 'author' => esc_attr__( 'Author', 'wordsmith' ), 'comment_count' => esc_attr__( 'Comment Count', 'wordsmith' ), 'date' => esc_attr__( 'Date', 'wordsmith' ), 'ID' => esc_attr__( 'ID', 'wordsmith' ), 'name' => esc_attr__( 'Name', 'wordsmith' ), 'rand' => esc_attr__( 'Random', 'wordsmith' ), 'title' => esc_attr__( 'Title', 'wordsmith' ) ); ?>

'widefat', 'id' => $this->get_field_id( 'category' ), 'name' => $this->get_field_name( 'category' ), 'selected' => $instance['category'], 'show_option_all' => '– Select –', ) ); ?>