Inventory_Presser_Shortcode_Hours_Today::find_hours_set_by_uid( string $uid )

find_hours_set_by_uid


Description Description

Get all sets of hours attached to a term in the location taxonomy by unique ID


Top ↑

Parameters Parameters

$uid

(string) (Required) A unique identifier assigned to a set of hours


Top ↑

Return Return

(array) A set of hours


Top ↑

Source Source

File: includes/class-shortcode-hours-today.php

	function find_hours_set_by_uid( $uid )
	{
		//get all term ids in the location taxonomy
		$location_term_ids = get_terms( array(
			'fields'     => 'ids',
			'orderby'    => 'term_id', //oldest first
			'taxonomy'   => 'location',
			'hide_empty' => false, //Dealers that don't tag each vehicle with a location will have no vehicles
		) );

		if( ! is_array( $location_term_ids ) )
		{
			return null;
		}

		foreach( $location_term_ids as $term_id )
		{
			$sets = Inventory_Presser_Taxonomies::get_hours( $term_id );
			if( empty( $sets ) )
			{
				continue;
			}
			foreach( $sets as $hours )
			{
				if( isset( $hours['uid'] ) && $uid == $hours['uid'] )
				{
					//these are the hours we want
					return $hours;
				}
			}
		}
		return null;
	}