diff --git a/includes/widgets.php b/includes/class-mashsb-shared-posts-widget.php similarity index 72% rename from includes/widgets.php rename to includes/class-mashsb-shared-posts-widget.php index c4badce6..c688b5e3 100644 --- a/includes/widgets.php +++ b/includes/class-mashsb-shared-posts-widget.php @@ -19,8 +19,9 @@ public function form( $instance ) { $count = esc_attr( $instance['count'] ); $showShares = esc_textarea( $instance['showShares'] ); $countLabel = esc_textarea( $instance['countLabel'] ); - //$separator = esc_textarea( $instance['separator'] ); // Maybe use this later when there is need + //$separator = esc_textarea( $instance['separator'] ); // Maybe use this later if there is need $wrapShares = esc_textarea( $instance['wrapShares'] ); + $period = esc_textarea( $instance['period'] ); } else { $title = 'Most Shared Posts'; $count = '10'; @@ -28,6 +29,7 @@ public function form( $instance ) { $countLabel = 'Shares'; //$separator = '|'; $wrapShares = 'false'; + $period = '7'; } ?> @@ -56,12 +58,23 @@ public function form( $instance ) {

//-->

- +

+

+ + +

' : ''; @@ -104,11 +119,20 @@ public function widget( $args, $instance ) { $args = array( 'posts_per_page' => $count, 'post_type' => 'post', + 'post_status' => 'publish', 'meta_key' => 'mashsb_shares', 'orderby' => 'meta_value_num', - 'order' => 'DESC' + 'order' => 'DESC', + 'date_query' => array( + array( + 'after' => $period . ' days ago', // or '-7 days' + 'inclusive' => true, + ), + ), ); - $wpq = new WP_Query( $args ); + //$wpq = new WP_Query( $args ); + $wpq = $this->get_qry_from_cache($args); + //var_dump($wpq); if( $wpq->have_posts() ) : echo '