post_count; } elseif ( isset($args['list_data']) && !empty($args['list_data']) ) { // Data with post and count in array format // Converting retrived post data to array $result_data = wtpsw_object_to_array($result->posts); // Fetch data with count if( isset($args['list_data']) && !empty($args['list_data']) ) { $data_res = array(); $data_res['data'] = $result_data; // To get total count of post $data_res['total'] = isset($result->found_posts) ? $result->found_posts : ''; // Assigning it in to returned array $result_data = $data_res; } } else { // Simply pass whole query $result_data = $result; } return $result_data; } /** * Function to modify query where * * @package WP Trending Post Slider and Widget * @since 1.0.0 */ function wtpsw_query_where( $where = '' ) { global $wpdb, $wtpsw_options, $wtpsw_view_by; $current_date = current_time('timestamp'); $post_range = isset($wtpsw_options['post_range']) ? $wtpsw_options['post_range'] : ''; switch ($post_range) { case 'daily': $start_date = date( 'Y-m-d', $current_date ); $where_con = " AND DATE($wpdb->posts.post_date) = '{$start_date}' "; break; case 'last_day': $start_date = date( 'Y-m-d', strtotime( '-1 days', $current_date ) ); $where_con = " AND DATE($wpdb->posts.post_date) = '{$start_date}' "; break; case 'last_week': $start_date = date( 'Y-m-d', strtotime( '-7 days', $current_date ) ); $end_date = date( 'Y-m-d', $current_date ); $where_con = " AND DATE($wpdb->posts.post_date) > '{$start_date}' AND DATE($wpdb->posts.post_date) <= '{$end_date}'"; break; case 'last_month': $start_date = date( 'Y-m-d', strtotime( '-1 months', $current_date ) ); $end_date = date( 'Y-m-d', $current_date ); $where_con = " AND DATE($wpdb->posts.post_date) >= '{$start_date}' AND DATE($wpdb->posts.post_date) <= '{$end_date}'"; break; default: $where_con = ''; break; } // Append where condition if( isset($where_con) ){ $where .= $where_con; } if(!empty($wtpsw_view_by) && $wtpsw_view_by == 'comment_count'){ $where .= " AND $wpdb->posts.comment_count > 0"; } return $where; } } $wtpsw_model = new Wtpsw_Model();