Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get_current_time_status($listing_id) {
- $current = get_current_time();
- $current_day = strtolower($current['day']);
- $current_time = $current['time'];
- $hours = get_post_meta( $listing_id, '_job_hours', true );
- $days = get_day_hours($hours);
- if ( !empty($days[$current_day]) ) {
- $times = $days[$current_day];
- if ( is_array($times) && count($times) == 2 ) {
- $opentime = strtotime($times[0]);
- $closedtime = strtotime($times[1]);
- if ( $current_time >= $opentime && $current_time <= $closedtime ) {
- return true;
- }
- }
- } else {
- return true;
- }
- return false;
- }
- function display_time_status($listing_id = null) {
- if ( empty($listing_id) ) {
- $listing_id = get_the_ID();
- }
- $status = get_current_time_status( $listing_id );
- if ( $status ) { ?>
- <div class="listing-time opening">
- <?php esc_html_e( 'Open', 'findgo' ); ?>
- </div>
- <?php } else { ?>
- <div class="listing-time closed">
- <?php esc_html_e( 'Closed', 'findgo' ); ?>
- </div>
- <?php }
- }
Advertisement
Add Comment
Please, Sign In to add comment