INVP::get_hours( int $term_id )
Loads sets of hours from post meta into an array.
Parameters Parameters
- $term_id
-
(int) (Required) The location term ID from which to extract hours.
Return Return
(array) An array of hours arrays
Source Source
File: includes/class-invp.php
public static function get_hours( $term_id ) {
$hours = array();
$term_meta = get_term_meta( $term_id );
for ( $h = 1; $h <= self::LOCATION_MAX_HOURS; $h++ ) {
// Are there hours in this slot?
if ( empty( $term_meta[ 'hours_' . $h . '_uid' ][0] ) ) {
// No, we're done with this location.
break;
}
$set = array(
'uid' => $term_meta[ 'hours_' . $h . '_uid' ][0],
'title' => self::meta_array_value_single( $term_meta, 'hours_' . $h . '_title' ),
);
$days = array_keys( self::weekdays() );
for ( $d = 0; $d < 7; $d++ ) {
$set[ $days[ $d ] . '_appt' ] = self::meta_array_value_single( $term_meta, 'hours_' . $h . '_' . $days[ $d ] . '_appt' );
$set[ $days[ $d ] . '_open' ] = self::meta_array_value_single( $term_meta, 'hours_' . $h . '_' . $days[ $d ] . '_open' );
$set[ $days[ $d ] . '_close' ] = self::meta_array_value_single( $term_meta, 'hours_' . $h . '_' . $days[ $d ] . '_close' );
}
$hours[] = $set;
}
return $hours;
}
Expand full source codeCollapse full source codeView on Github