/** * get_venue * attempts to retrieve an EE_Venue object any way it can * * @access public * @param int $VNU_ID * @param bool $look_in_event * @param bool $privacy_check Defaults to true. When false, means even if the venue is private we return it * regardless of access. * @return EE_Venue | null */ public static function get_venue($VNU_ID = 0, $look_in_event = TRUE, $privacy_check = true) { $VNU_ID = absint($VNU_ID); // do we already have the Venue you are looking for? if (EEH_Venue_View::$_venue instanceof EE_Venue && EEH_Venue_View::$_venue->ID() == $VNU_ID) { return EEH_Venue_View::_get_venue($privacy_check); } // international newspaper? global $post; if ($post instanceof WP_Post) { switch ($post->post_type) { // if this is being called from an EE_Venue post, // and the EE_Venue post corresponds to the EE_Venue that is being asked for, // then we can try to just grab the attached EE_Venue object case 'espresso_venues': // the post already contains the related EE_Venue object AND one of the following is TRUE: // the requested Venue ID matches the post ID OR... // there was no specific Venue ID requested if (isset($post->EE_Venue) && ($VNU_ID == $post->ID || !$VNU_ID)) { // use existing related EE_Venue object EEH_Venue_View::$_venue = $post->EE_Venue; } else { if ($VNU_ID) { // there WAS a specific Venue ID requested, but it's NOT the current post object EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); } else { // no specific Venue ID requested, so use post ID to generate EE_Venue object EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($post->ID); } } break; case 'espresso_events': if ($look_in_event) { // grab the events related venues $venues = EEH_Venue_View::get_event_venues(); // make sure the result is an array $venues = is_array($venues) ? $venues : array(); // do we have an ID for a specific venue? if ($VNU_ID) { // loop thru the related venues foreach ($venues as $venue) { if ($venue instanceof EE_Venue) { // until we find the venue we're looking for if ($venue->ID() == $VNU_ID) { EEH_Venue_View::$_venue = $venue; break; } } // if the venue being asked for is not related to the global event post, // still return the venue being asked for } // no venue ID ? // then the global post is an events post and this function was called with no argument } else { // just grab the first related event venue EEH_Venue_View::$_venue = reset($venues); } } break; } } // now if we STILL do NOT have an EE_Venue model object, BUT we have a Venue ID... if (!EEH_Venue_View::$_venue instanceof EE_Venue && $VNU_ID) { // sigh... pull it from the db EEH_Venue_View::$_venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID); } return EEH_Venue_View::_get_venue($privacy_check); }
/** * espresso_event_venues * * @return array all venues related to an event */ function espresso_event_venues() { return EEH_Venue_View::get_event_venues(); }
/** * espresso_event_venues * * @return array all venues related to an event */ function espresso_event_venues() { EE_Registry::instance()->load_helper('Venue_View'); return EEH_Venue_View::get_event_venues(); }
public function venue() { return EEH_Venue_View::get_event_venues($this->ID); }