protected function _parser($shortcode) { EE_Registry::instance()->load_helper('Formatter'); $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 there is no event objecdt by now then get out. if (!$this->_event instanceof EE_Event) { return ''; } switch ($shortcode) { case '[EVENT_ID]': return $this->_event->ID(); break; case '[EVENT_IDENTIFIER]': return isset($this->_data['line_ref']) ? $this->_data['line_ref'] : ''; break; case '[EVENT]': case '[EVENT_NAME]': return $this->_event->get('EVT_name'); break; case '[EVENT_PHONE]': return $this->_event->get('EVT_phone'); break; case '[EVENT_DESCRIPTION]': return $this->_event->get('EVT_desc'); break; case '[EVENT_EXCERPT]': return $this->_event->get('EVT_short_desc'); break; case '[EVENT_LINK]': return $this->_get_event_link($this->_event); break; case '[EVENT_URL]': return $this->_get_event_link($this->_event, FALSE); break; case '[VIRTUAL_URL]': $venue = $this->_event->get_first_related('Venue'); if (empty($venue)) { return ''; } return $venue->get('VNU_virtual_url'); case '[VIRTUAL_PHONE]': $venue = $this->_event->get_first_related('Venue'); if (empty($venue)) { return ''; } return $venue->get('VNU_virtual_phone'); break; case '[EVENT_IMAGE]': $image = $this->_event->feature_image_url(array(600, 300)); // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned. return !empty($image) ? '<img src="' . $image . '" alt="' . sprintf(esc_attr__('%s Feature Image', 'event_espresso'), $this->_event->get('EVT_name')) . '" />' : ''; break; case '[EVENT_FACEBOOK_URL]': $facebook_url = $this->_event->get_post_meta('event_facebook', true); return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') : $facebook_url; break; case '[EVENT_TWITTER_URL]': $twitter_url = $this->_event->get_post_meta('event_twitter', true); return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') : $twitter_url; break; case '[EVENT_AUTHOR_EMAIL]': $author_id = $this->_event->get('EVT_wp_user'); $user_data = get_userdata((int) $author_id); return $user_data->user_email; break; case '[EVENT_TOTAL_SPOTS_TAKEN]': return EEM_Registration::instance()->count(array(array('EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved)), 'REG_ID', true); break; case '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]': EE_Registry::instance()->load_helper('URL'); return EEH_URL::add_query_args_and_nonce(array('event_id' => $this->_event->ID(), 'page' => 'espresso_registrations', 'action' => 'default'), admin_url('admin.php'), true); break; } if (strpos($shortcode, '[EVENT_META_*') !== false) { $shortcode = str_replace('[EVENT_META_*', '', $shortcode); $shortcode = trim(str_replace(']', '', $shortcode)); //pull the meta value from the event post $event_meta = $this->_event->get_post_meta($shortcode, true); return !empty($event_meta) ? $this->_event->get_post_meta($shortcode, true) : ''; } if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) { $attrs = $this->_get_shortcode_attrs($shortcode); $method = empty($attrs['method']) ? 'current' : $attrs['method']; $method = $method === 'current'; $available = $this->_event->total_available_spaces($method); return $available === INF ? '∞' : $available; } return ''; }
protected function _parser($shortcode) { EE_Registry::instance()->load_helper('Formatter'); $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 there is no event objecdt by now then get out. if (!$this->_event instanceof EE_Event) { return ''; } switch ($shortcode) { case '[EVENT_ID]': return $this->_event->ID(); break; case '[EVENT_IDENTIFIER]': return isset($this->_data['line_ref']) ? $this->_data['line_ref'] : ''; break; case '[EVENT]': case '[EVENT_NAME]': return $this->_event->get('EVT_name'); break; case '[EVENT_PHONE]': return $this->_event->get('EVT_phone'); break; case '[EVENT_DESCRIPTION]': return $this->_event->get('EVT_desc'); break; case '[EVENT_EXCERPT]': return $this->_event->get('EVT_short_desc'); break; case '[EVENT_LINK]': return $this->_get_event_link($this->_event); break; case '[EVENT_URL]': return $this->_get_event_link($this->_event, FALSE); break; case '[VIRTUAL_URL]': $venue = $this->_event->get_first_related('Venue'); if (empty($venue)) { return ''; } return $venue->get('VNU_virtual_url'); case '[VIRTUAL_PHONE]': $venue = $this->_event->get_first_related('Venue'); if (empty($venue)) { return ''; } return $venue->get('VNU_virtual_phone'); break; case '[EVENT_IMAGE]': $image = $this->_event->feature_image_url(array(600, 300)); // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned. return !empty($image) ? '<img src="' . $image . '" alt="' . sprintf(esc_attr__('%s Feature Image', 'event_espresso'), $this->_event->get('EVT_name')) . '" />' : ''; break; case '[EVENT_FACEBOOK_URL]': $facebook_url = $this->_event->get_post_meta('event_facebook', true); return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') : $facebook_url; break; case '[EVENT_TWITTER_URL]': $twitter_url = $this->_event->get_post_meta('event_twitter', true); return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') : $twitter_url; break; case '[EVENT_AUTHOR_EMAIL]': $author_id = $this->_event->get('EVT_wp_user'); $user_data = get_userdata((int) $author_id); return $user_data->user_email; break; } return ''; }