Guest User

Untitled

a guest
Jan 2nd, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. function get_current_time_status($listing_id) {
  2. $current = get_current_time();
  3. $current_day = strtolower($current['day']);
  4. $current_time = $current['time'];
  5. $hours = get_post_meta( $listing_id, '_job_hours', true );
  6. $days = get_day_hours($hours);
  7.  
  8. if ( !empty($days[$current_day]) ) {
  9. $times = $days[$current_day];
  10. if ( is_array($times) && count($times) == 2 ) {
  11. $opentime = strtotime($times[0]);
  12. $closedtime = strtotime($times[1]);
  13. if ( $current_time >= $opentime && $current_time <= $closedtime ) {
  14. return true;
  15. }
  16. }
  17. } else {
  18. return true;
  19. }
  20. return false;
  21. }
  22.  
  23. function display_time_status($listing_id = null) {
  24. if ( empty($listing_id) ) {
  25. $listing_id = get_the_ID();
  26. }
  27. $status = get_current_time_status( $listing_id );
  28. if ( $status ) { ?>
  29. <div class="listing-time opening">
  30. <?php esc_html_e( 'Open', 'findgo' ); ?>
  31. </div>
  32. <?php } else { ?>
  33. <div class="listing-time closed">
  34. <?php esc_html_e( 'Closed', 'findgo' ); ?>
  35. </div>
  36. <?php }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment