Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('atbdp_listing_search_query_argument', 'directorist_only_show_open_now_listings');
- add_filter('atbdp_all_listings_query_arguments', 'directorist_only_show_open_now_listings');
- function directorist_only_show_open_now_listings($args)
- {
- $view = atbdp_get_listings_current_view_name( 'grid' );
- if( $view == 'map' ){
- $args['posts_per_page'] = '-1';
- }
- if(is_page(11209)){
- $new_args = $args;
- $new_args['posts_per_page'] = '-1';
- $query = new WP_Query($new_args);
- $open = array();
- if ($query->have_posts()) {
- while ($query->have_posts()) {
- $query->the_post();
- $id = get_the_ID();
- $business_hours = get_post_meta($id, '_bdbh', true);
- $always_open = get_post_meta($id, '_enable247hour', true);
- $no_time = get_post_meta($id, '_disable_bz_hour_listing', true);
- $business_hours = !empty($business_hours) ? atbdp_sanitize_array($business_hours) : array();
- if ($no_time) continue;
- if ($always_open) $open[] = $id;
- $status = false;
- $day_ = date('D');
- $timezone = get_directorist_option('timezone');
- $timezone = !empty($timezone) ? $timezone : 'America/New_York';
- $listing_timezone = get_post_meta(get_the_ID(), '_timezone', true);
- $timezone = !empty($listing_timezone) ? $listing_timezone : $timezone;
- foreach ($business_hours as $day => $time) {
- if (empty($time) || empty( $business_hours[$day]['enable'])) continue; // do not print the day if time is not set
- switch ($day_) {
- case 'Sat':
- $status = business_open_close_status($business_hours, $time, 'saturday', $timezone);
- break;
- case 'Sun':
- $status = business_open_close_status($business_hours, $time, 'sunday', $timezone);
- break;
- case 'Mon':
- $status = business_open_close_status($business_hours, $time, 'monday', $timezone);
- break;
- case 'Tue':
- $status = business_open_close_status($business_hours, $time, 'tuesday', $timezone);
- break;
- case 'Wed':
- $status = business_open_close_status($business_hours, $time, 'wednesday', $timezone);
- break;
- case 'Thu':
- $status = business_open_close_status($business_hours, $time, 'thursday', $timezone);
- break;
- case 'Fri':
- $status = business_open_close_status($business_hours, $time, 'friday', $timezone);
- break;
- }
- }
- if ($status) {
- $open[] = get_the_ID();
- }
- }
- }
- wp_reset_postdata();
- if (count($open) > 0) {
- $args['post__in'] = $open;
- }
- }
- return $args;
- }
Advertisement
Add Comment
Please, Sign In to add comment