Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter n00bctrl

    (@n00bctrl)

    Oh I think it just isn’t working for the latest version of wordpress.

    Plugin Author janizde

    (@janizde)

    Hello n00bctrl,

    I think this isn’t possible in any WordPress version yet. But not such a bad idea 😉
    You could certainly tell the widget to highlight the current weekday and then hide the days that don’t have the “highlighted” class with css (e.g. :not() selector)

    I hope this satisfies you 🙂

    Here’s a very quick custom function you can call from a template file to output the opening details for today:

    /**
     * todays_hours - Returns the a string with the opening hour details for today. Plugin wp-opening-hours required
     */
    function todays_hours () {
    	global $wp_opening_hours;
    
    	if (!is_object($wp_opening_hours))	$wp_opening_hours	= new OpeningHours;
    
    	$today		= strtolower( date('l', current_time('timestamp')) );
    
    	/* Check for Holidays */
    	foreach ((array) $wp_opening_hours->holidays as $holiday)
    		if ($holiday->isRunning())
    			return 'Store closed for '.$holiday->data['name'].'<br />'.'Reopens '.$holiday->data['end'];
    
    	/* Check for Special Openings */
    	foreach ((array) $wp_opening_hours->specialOpenings as $specialOpening) :
    		if ( $specialOpening->isToday() ) :
    			return 'Store hours today<br/>'.$specialOpening->data['name'].': '.date("g:i a", $specialOpening->start_ts).' - '.date("g:i a", $specialOpening->end_ts);
    		endif;
    	endforeach;
    
    	/* Check for regular Opening Periods */
    	foreach ((array) $wp_opening_hours->$today as $period)
    		if ($period->isRunning())
    			return 'Store hours today<br/>'.date("g:i a", $period->start_ts).' - '.date("g:i a", $period->end_ts);
    
    	return 'Store hours today<br/>'.date("g:i a", $period->start_ts).' - '.date("g:i a", $period->end_ts);
    }
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Print just the current day's time?’ is closed to new replies.