예제 #1
0
 /**
  * Fetches the JSON-LD data for this type of object
  *
  * @param  int|WP_Post|null $post The post/venue
  * @param  array  $args
  * @return array
  */
 public function get_data($post = null, $args = array('context' => false))
 {
     $data = parent::get_data($post, $args);
     // If we have an Empty data we just skip
     if (empty($data)) {
         return array();
     }
     // Fetch first key
     $post_id = key($data);
     // Fetch first Value
     $data = reset($data);
     $data->address = array();
     $data->address['streetAddress'] = tribe_get_address($post_id);
     $data->address['addressLocality'] = tribe_get_city($post_id);
     $data->address['addressRegion'] = tribe_get_region($post_id);
     $data->address['postalCode'] = tribe_get_zip($post_id);
     $data->address['addressCountry'] = tribe_get_country($post_id);
     // Filter empty entries and convert to object
     $data->address = (object) array_filter($data->address);
     $geo = tribe_get_coordinates($post_id);
     if (!empty($geo['lat']) && !empty($geo['lng'])) {
         $data->geo = (object) array('@type' => 'GeoCoordinates', 'latitude' => $geo['lat'], 'longitude' => $geo['lng']);
     }
     $data->telephone = tribe_get_phone($post_id);
     $data->sameAs = tribe_get_venue_website_url($post_id);
     return array($post_id => $data);
 }
예제 #2
0
 /**
  * Get the link for the venue website.
  *
  * @param null $post_id
  * @param null $label
  *
  * @return string Formatted link to the venue website
  */
 function tribe_get_venue_website_link($post_id = null, $label = null)
 {
     $url = tribe_get_venue_website_url($post_id);
     if (!empty($url)) {
         $label = is_null($label) ? $url : $label;
         if (!empty($url)) {
             $parseUrl = parse_url($url);
             if (empty($parseUrl['scheme'])) {
                 $url = "http://{$url}";
             }
         }
         $html = sprintf('<a href="%s" target="%s">%s</a>', esc_attr(esc_url($url)), apply_filters('tribe_get_venue_website_link_target', '_self'), apply_filters('tribe_get_venue_website_link_label', esc_html($label)));
     } else {
         $html = '';
     }
     return apply_filters('tribe_get_venue_website_link', $html);
 }