Inventory_Presser_Shortcode_Hours_Today::create_days_array_from_hours_array( array $hours_arr )
create_days_array_from_hours_array
On This Page
Description Description
Translate the hours termmeta data structure into Inventory_Presser_Business_Day objects
Parameters Parameters
- $hours_arr
-
(array) (Required)
Return Return
(array) And array of Inventory_Presser_Business_Day objects
Source Source
File: includes/shortcode/class-shortcode-hours-today.php
public static function create_days_array_from_hours_array( $hours_arr ) { $days = array(); $weekdays = array_keys( INVP::weekdays() ); for ( $d = 0; $d < 7; $d++ ) { if ( empty( $hours_arr[ $weekdays[ $d ] . '_open' ] ) || empty( $hours_arr[ $weekdays[ $d ] . '_close' ] ) ) { continue; } $day = new Inventory_Presser_Business_Day(); $day->weekday = $d + 1; // open hour, turn "9:00 AM" into 9 and "4:00 PM" into 15 $date_obj = self::create_date_object_from_hour_string( $hours_arr[ $weekdays[ $d ] . '_open' ] ); if ( ! $date_obj ) { continue; } $day->open_hour = $date_obj->format( 'G' ); $day->open_minute = $date_obj->format( 'i' ); // close hour $date_obj = self::create_date_object_from_hour_string( $hours_arr[ $weekdays[ $d ] . '_close' ] ); if ( ! $date_obj ) { continue; } $day->close_hour = $date_obj->format( 'G' ); $day->close_minute = $date_obj->format( 'i' ); array_push( $days, $day ); } return $days; }
Expand full source codeCollapse full source codeView on Github