/**
  *    the_posts
  *
  * @access    public
  * @param          $posts
  * @param WP_Query $wp_query
  * @return    void
  */
 public function the_posts($posts, WP_Query $wp_query)
 {
     // automagically load the EEH_Venue_View helper so that it's functions are available
     if (isset(EE_Registry::instance()->CFG->map_settings->use_google_maps) && EE_Registry::instance()->CFG->map_settings->use_google_maps) {
         EEH_Maps::espresso_google_map_js();
     }
     remove_filter('the_posts', array($this, 'the_posts'), 1, 2);
     return $posts;
 }
 /**
  * Gets the HTML to display a static map of the venue
  * @param EE_Venue $venue
  * @param array $atts like EEH_Maps::google_map_link
  * @return string
  */
 public static function espresso_google_static_map(EE_Venue $venue, $atts = array())
 {
     EE_Registry::instance()->load_helper('Maps');
     $state = $venue->state_obj();
     $country = $venue->country_obj();
     $atts = shortcode_atts(array('id' => $venue->ID(), 'address' => $venue->get('VNU_address'), 'city' => $venue->get('VNU_city'), 'state' => $state instanceof EE_State ? $state->name() : '', 'zip' => $venue->get('VNU_zip'), 'country' => $country instanceof EE_Country ? $country->name() : '', 'type' => 'map', 'map_w' => 200, 'map_h' => 200), $atts);
     return EEH_Maps::google_map_link($atts);
 }
 /**
  * This retrieves the specified venue information
  * @param  string $what What to retrieve from database
  * @return string       What was retrieved!
  */
 private function _venue($db_ref)
 {
     if (!$this->_data instanceof EE_Event) {
         return '';
     }
     //we need the event in order to get a venue!
     $venue = $this->_data->get_first_related('Venue');
     if (empty($venue)) {
         return '';
     }
     //no venue so get out.
     switch ($db_ref) {
         case 'title':
             return $venue->get('VNU_name');
             break;
         case 'url':
             return $venue->get('VNU_url');
             break;
         case 'image':
             return '<img src="' . $venue->feature_image_url(array(200, 200)) . '" alt="' . $venue->get('VNU_name') . ' Feature Image" />';
             break;
         case 'phone':
             return $venue->get('VNU_phone');
             break;
         case 'address':
             return $venue->get('VNU_address');
             break;
         case 'address2':
             return $venue->get('VNU_address2');
             break;
         case 'city':
             return $venue->get('VNU_city');
             break;
         case 'state':
             $state = $venue->state_obj();
             return is_object($state) ? $state->get('STA_name') : '';
             break;
         case 'country':
             $country = $venue->country_obj();
             return is_object($country) ? $country->get('CNT_name') : '';
             break;
         case 'zip':
             return $venue->get('VNU_zip');
             break;
         case 'gmap_link':
         case 'gmap_link_img':
             EE_Registry::instance()->load_helper('Maps');
             $state = $venue->state_obj();
             $country = $venue->country_obj();
             $atts = array('id' => $venue->ID(), 'address' => $venue->get('VNU_address'), 'city' => $venue->get('VNU_city'), 'state' => is_object($state) ? $state->get('STA_name') : '', 'zip' => $venue->get('VNU_zip'), 'country' => is_object($country) ? $country->get('CNT_name') : '', 'type' => $db_ref == 'gmap_link' ? 'url' : 'map', 'map_w' => 200, 'map_h' => 200);
             return EEH_Maps::google_map_link($atts);
             break;
     }
 }
 /**
  * This retrieves the specified venue information
  * @param  string $what What to retrieve from database
  * @return string       What was retrieved!
  */
 private function _venue($db_ref)
 {
     //we need the EE_Event object to get the venue.
     $this->_event = $this->_data instanceof EE_Event ? $this->_data : null;
     //if no event, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the event from the reg_obj instead.
     if (empty($this->_event)) {
         $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : NULL;
         $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee;
         $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration ? $aee->reg_obj->event() : NULL;
         //if still empty do we have a ticket data item?
         $this->_event = empty($this->_event) && $this->_data instanceof EE_Ticket && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->tickets[$this->_data->ID()]['EE_Event'] : $this->_event;
         //if STILL empty event, let's try to get the first event in the list of events via EE_Messages_Addressee and use that.
         $event = $aee instanceof EE_Messages_Addressee ? reset($aee->events) : array();
         $this->_event = empty($this->_event) && !empty($events) ? $event : $this->_event;
     }
     //If there is no event objecdt by now then get out.
     if (!$this->_event instanceof EE_Event) {
         return '';
     }
     $venue = $this->_event->get_first_related('Venue');
     if (empty($venue)) {
         return '';
     }
     //no venue so get out.
     switch ($db_ref) {
         case 'title':
             return $venue->get('VNU_name');
             break;
         case 'description':
             return $venue->get('VNU_desc');
             break;
         case 'url':
             $url = $venue->get('VNU_url');
             return empty($url) ? $venue->get_permalink() : $url;
             break;
         case 'image':
             return '<img src="' . $venue->feature_image_url(array(200, 200)) . '" alt="' . sprintf(esc_attr__('%s Feature Image', 'event_espresso'), $venue->get('VNU_name')) . '" />';
             break;
         case 'phone':
             return $venue->get('VNU_phone');
             break;
         case 'address':
             return $venue->get('VNU_address');
             break;
         case 'address2':
             return $venue->get('VNU_address2');
             break;
         case 'city':
             return $venue->get('VNU_city');
             break;
         case 'state':
             $state = $venue->state_obj();
             return is_object($state) ? $state->get('STA_name') : '';
             break;
         case 'country':
             $country = $venue->country_obj();
             return is_object($country) ? $country->get('CNT_name') : '';
             break;
         case 'zip':
             return $venue->get('VNU_zip');
             break;
         case 'formatted_address':
             return EEH_Address::format($venue);
             break;
         case 'gmap_link':
         case 'gmap_link_img':
             $state = $venue->state_obj();
             $country = $venue->country_obj();
             $atts = array('id' => $venue->ID(), 'address' => $venue->get('VNU_address'), 'city' => $venue->get('VNU_city'), 'state' => is_object($state) ? $state->get('STA_name') : '', 'zip' => $venue->get('VNU_zip'), 'country' => is_object($country) ? $country->get('CNT_name') : '', 'type' => $db_ref == 'gmap_link' ? 'url' : 'map', 'map_w' => 200, 'map_h' => 200);
             return EEH_Maps::google_map_link($atts);
             break;
     }
 }