/** * Updates venue meta cache when event venues are retrieved. * * For backwards compatibility it adds the venue details to the taxonomy terms. * Hooked onto get_terms and get_event-venue * * @ignore * @access private * @since 1.5 * * @param array $terms Array of terms, * @param string $tax Should be (an array containing) 'event-venue'. * @param array Array of event-venue terms, */ function eventorganiser_update_venue_meta_cache($terms, $tax) { if (is_array($tax) && !in_array('event-venue', $tax)) { return $terms; } if (!is_array($tax) && $tax != 'event-venue') { return $terms; } $single = false; if (!is_array($terms)) { $single = true; $terms = array($terms); } if (empty($terms)) { return $terms; } //Check if its array of terms or term IDs $first_element = reset($terms); if (is_object($first_element)) { $term_ids = wp_list_pluck($terms, 'term_id'); } else { $term_ids = $terms; } update_meta_cache('eo_venue', $term_ids); //Backwards compatible. Depreciated - use the functions, not properties. foreach ($terms as $term) { if (!is_object($term)) { continue; } $term_id = (int) $term->term_id; if (!isset($term->venue_address)) { $address = eo_get_venue_address($term_id); foreach ($address as $key => $value) { $term->{'venue_' . $key} = $value; } } if (!isset($term->venue_lat) || !isset($term->venue_lng)) { $term->venue_lat = number_format(floatval(eo_get_venue_lat($term_id)), 6); $term->venue_lng = number_format(floatval(eo_get_venue_lng($term_id)), 6); } } if ($single) { return $terms[0]; } return $terms; }
/** * Ajax response for searcheing venues. Searches by venue name. * *@since 1.0 *@access private *@ignore */ function eventorganiser_search_venues() { // Query the venues with the given term $value = trim(esc_attr($_GET["term"])); $venues = eo_get_venues(array('search' => $value)); foreach ($venues as $venue) { $venue_id = (int) $venue->term_id; if (!isset($term->venue_address)) { /* This is all deprecated - use the API {@link http://codex.wp-event-organiser.com/function-eo_get_venue_address.html} */ $address = eo_get_venue_address($venue_id); $venue->venue_address = isset($address['address']) ? $address['address'] : ''; $venue->venue_postal = isset($address['postcode']) ? $address['postcode'] : ''; $venue->venue_postcode = isset($address['postcode']) ? $address['postcode'] : ''; $venue->venue_city = isset($address['city']) ? $address['city'] : ''; $venue->venue_country = isset($address['country']) ? $address['country'] : ''; $venue->venue_state = isset($address['state']) ? $address['state'] : ''; } if (!isset($venue->venue_lat) || !isset($venue->venue_lng)) { $venue->venue_lat = number_format(floatval(eo_get_venue_lat($venue_id)), 6); $venue->venue_lng = number_format(floatval(eo_get_venue_lng($venue_id)), 6); } } $tax = get_taxonomy('event-venue'); $novenue = array('term_id' => 0, 'name' => $tax->labels->no_item); $venues = array_merge(array($novenue), $venues); //echo JSON to page $response = $_GET["callback"] . "(" . json_encode($venues) . ")"; echo $response; exit; }
function eventorganiser_venue_location($venue) { $term_id = isset($venue->term_id) ? (int) $venue->term_id : 0; $address = eo_get_venue_address($term_id); ?> <div class="address-fields"> <table> <tbody> <?php $address_fields = _eventorganiser_get_venue_address_fields(); foreach ($address_fields as $key => $label) { //Keys are prefixed by '_'. $key = trim($key, '_'); printf('<tr> <th><label for="eo-venue-%2$s">%1$s:</label></th> <td><input type="text" name="eo_venue[%2$s]" class="eo_addressInput" id="eo-venue-%2$s" value="%3$s" /></td> </tr>', $label, esc_attr($key), esc_attr($address[$key])); } ?> </tbody> </table> <?php $latlng = eo_get_venue_latlng($term_id); ?> <small> <?php esc_html_e('Latitude/Longitude:', 'eventorganiser'); ?> <span id="eo-venue-latllng-text" data-eo-lat="<?php echo esc_attr($latlng['lat']); ?> " data-eo-lng="<?php echo esc_attr($latlng['lng']); ?> " contenteditable="true"> <?php echo esc_html(implode(',', $latlng)); ?> </span> </small> </div> <div id="venuemap"></div> <div class="clear"></div> <input type="hidden" name="eo_venue[latitude]" id="eo_venue_Lat" value="<?php echo esc_attr(eo_get_venue_lat($term_id)); ?> "/> <input type="hidden" name="eo_venue[longtitude]" id="eo_venue_Lng" value="<?php echo esc_attr(eo_get_venue_lng($term_id)); ?> "/> <?php }
function eventorganiser_venue_location($venue) { $term_id = isset($venue->term_id) ? (int) $venue->term_id : 0; $address = eo_get_venue_address($term_id); ?> <table class ="address"> <tbody> <?php $address_fields = _eventorganiser_get_venue_address_fields(); $tabindex = 2; foreach ($address_fields as $key => $label) { //Keys are prefixed by '_'. $key = trim($key, '_'); printf('<tr> <th><label>%1$s:</label></th> <td><input type="text" name="eo_venue[%2$s]" class="eo_addressInput" id="eo-venue-%2$s" value="%3$s" tabindex="%4$s"/></td> </tr>', $label, esc_attr($key), esc_attr($address[$key]), $tabindex++); } ?> </tbody> </table> <div id="venuemap" class="gmap3"></div> <div class="clear"></div> <input type="hidden" name="eo_venue[latitude]" id="eo_venue_Lat" value="<?php echo esc_attr(eo_get_venue_lat($term_id)); ?> "/> <input type="hidden" name="eo_venue[longtitude]" id="eo_venue_Lng" value="<?php echo esc_attr(eo_get_venue_lng($term_id)); ?> "/> <?php }
/** * Prints the latitude co-ordinate of a venue. * If used with any arguments uses the venue of the current event. * @uses eo_get_venue_lat() * @since 1.0.0 * * @param int|string $venue_slug_or_id The venue ID (as an integer) or slug (as a string). Uses venue of current event if empty. */ function eo_venue_lat($venue_slug_or_id = '') { echo eo_get_venue_lat($venue_slug_or_id); }
function eventorganiser_update_venue_meta_cache($terms, $tax) { if (is_array($tax) && !in_array('event-venue', $tax)) { return $terms; } if (!is_array($tax) && $tax != 'event-venue') { return $terms; } $single = false; if (!is_array($terms)) { $single = true; $terms = array($terms); } if (empty($terms)) { return $terms; } $term_ids = wp_list_pluck($terms, 'term_id'); update_meta_cache('eo_venue', $term_ids); $fields = array('venue_address', 'venue_postal', 'venue_country', 'venue_lng', 'venue_lat', 'venue_description'); //Backwards compatible. Depreciated - use the functions, not properties. foreach ($terms as $term) { if (!is_object($term)) { continue; } $term_id = (int) $term->term_id; if (!isset($term->venue_address)) { $address = eo_get_venue_address($term_id); $term->venue_address = isset($address['address']) ? $address['address'] : ''; $term->venue_postal = isset($address['postcode']) ? $address['postcode'] : ''; $term->venue_country = isset($address['country']) ? $address['country'] : ''; } if (!isset($term->venue_lat) || !isset($term->venue_lng)) { $term->venue_lat = number_format(floatval(eo_get_venue_lat($term_id)), 6); $term->venue_lng = number_format(floatval(eo_get_venue_lng($term_id)), 6); } if (!isset($term->venue_description)) { $term->venue_description = eo_get_venue_description($term_id); } } if ($single) { return $terms[0]; } return $terms; }
/** * Returns HTML mark-up for a list of event meta information. * * Uses microformat. * @since 1.7 * @ignore * @param int $post_id The event (post) ID. Uses current event if not supplied * @return string|bool HTML mark-up. False if an invalid $post_is provided. */ function eo_get_event_meta_list($event_id = 0) { $event_id = (int) (empty($event_id) ? get_the_ID() : $event_id); if (empty($event_id)) { return false; } $html = '<ul class="eo-event-meta" style="margin:10px 0px;">'; $venue = get_taxonomy('event-venue'); if (($venue_id = eo_get_venue($event_id)) && $venue) { $html .= sprintf('<li><strong>%s:</strong> <a href="%s"> <span itemprop="location" itemscope itemtype="http://data-vocabulary.org/Organization"> <span itemprop="name">%s</span> <span itemprop="geo" itemscope itemtype="http://data-vocabulary.org/Geo"> <meta itemprop="latitude" content="%f" /> <meta itemprop="longitude" content="%f" /> </span> </span> </a></li>', $venue->labels->singular_name, eo_get_venue_link($venue_id), eo_get_venue_name($venue_id), eo_get_venue_lat($venue_id), eo_get_venue_lng($venue_id)); } if (get_the_terms($event_id, 'event-category')) { $html .= sprintf('<li><strong>%s:</strong> %s</li>' . "\n", __('Categories', 'eventorganiser'), get_the_term_list($event_id, 'event-category', '', ', ', '')); } if (get_the_terms($event_id, 'event-tag') && !is_wp_error(get_the_terms($event_id, 'event-tag'))) { $html .= sprintf('<li><strong>%s:</strong> %s</li>' . "\n", __('Tags', 'eventorganiser'), get_the_term_list($event_id, 'event-tag', '', ', ', '')); } $html .= '</ul>'; /** * Filters mark-up for the event details list. * * The event details list is just a simple list containig details pertaining * to the event (venue, categories, tags) etc. * * @param array $html The generated mark-up * @param int $event_id Post ID of the event */ $html = apply_filters('eventorganiser_event_meta_list', $html, $event_id); return $html; }
/** * Returns HTML mark-up for a list of event meta information. * * Uses microformat. * @since 1.7 * @ignore * @param int $post_id The event (post) ID. Uses current event if not supplied * @return string|bool HTML mark-up. False if an invalid $post_is provided. */ function eo_get_event_meta_list($post_id = 0) { $post_id = (int) (empty($post_id) ? get_the_ID() : $post_id); if (empty($post_id)) { return false; } $html = '<ul class="eo-event-meta" style="margin:10px 0px;">'; if ($venue_id = eo_get_venue($post_id)) { $html .= sprintf('<li><strong>%s:</strong> <a href="%s"> <span itemprop="location" itemscope itemtype="http://data-vocabulary.org/Organization"> <span itemprop="name">%s</span> <span itemprop="geo" itemscope itemtype="http://data-vocabulary.org/Geo"> <meta itemprop="latitude" content="%f" /> <meta itemprop="longitude" content="%f" /> </span> </span></a></li>', __('Venue', 'eventorganiser'), eo_get_venue_link($venue_id), eo_get_venue_name($venue_id), eo_get_venue_lat($venue_id), eo_get_venue_lng($venue_id)); } if (get_the_terms(get_the_ID(), 'event-category')) { $html .= sprintf('<li><strong>%s:</strong> %s</li>', __('Categories', 'eventorganiser'), get_the_term_list(get_the_ID(), 'event-category', '', ', ', '')); } if (get_the_terms(get_the_ID(), 'event-tag') && !is_wp_error(get_the_terms(get_the_ID(), 'event-tag'))) { $html .= sprintf('<li><strong>%s:</strong> %s</li>', __('Tags', 'eventorganiser'), get_the_term_list(get_the_ID(), 'event-tag', '', ', ', '')); } $html .= '</ul>'; return apply_filters('eventorganiser_event_meta_list', $html, $post_id); }
function eventorganiser_search_venues() { // Query the venues with the given term $value = trim(esc_attr($_GET["term"])); $venues = eo_get_venues(array('search' => $value)); foreach ($venues as $venue) { $term_id = (int) $venue->term_id; if (!isset($term->venue_address)) { $address = eo_get_venue_address($term_id); $term->venue_address = isset($address['address']) ? $address['address'] : ''; $term->venue_postal = isset($address['postcode']) ? $address['postcode'] : ''; $term->venue_country = isset($address['country']) ? $address['country'] : ''; } if (!isset($term->venue_lat) || !isset($term->venue_lng)) { $term->venue_lat = number_format(floatval(eo_get_venue_lat($term_id)), 6); $term->venue_lng = number_format(floatval(eo_get_venue_lng($term_id)), 6); } if (!isset($term->venue_description)) { $term->venue_description = eo_get_venue_description($term_id); } } $novenue = array('term_id' => 0, 'name' => __('No Venue', 'eventorganiser')); $venues = array_merge(array($novenue), $venues); //echo JSON to page $response = $_GET["callback"] . "(" . json_encode($venues) . ")"; echo $response; exit; }
function eventorganiser_venue_location($venue) { $term_id = isset($venue->term_id) ? (int) $venue->term_id : 0; $address = eo_get_venue_address($term_id); ?> <table class ="address"> <tbody> <tr> <th><label><?php _e('Address', 'eventorganiser'); ?> :</label></th> <td><input name="eo_venue[address]" class="eo_addressInput" id="eo_venue_add" value="<?php echo esc_attr($address['address']); ?> "/></td> </tr> <tr> <th><label><?php _e('Post Code', 'eventorganiser'); ?> :</label></th> <td><input name="eo_venue[postcode]" class="eo_addressInput" id="eo_venue_pcode" value="<?php echo esc_attr($address['postcode']); ?> "/></td> </tr> <tr> <th><label><?php _e('Country', 'eventorganiser'); ?> :</label></th> <td><input name="eo_venue[country]" class="eo_addressInput" id="eo_venue_country" value="<?php echo esc_attr($address['country']); ?> "/></td> </tr> </tbody> </table> <div id="venuemap" class="gmap3"></div> <div class="clear"></div> <input type="hidden" name="eo_venue[latitude]" id="eo_venue_Lat" value="<?php echo esc_attr(eo_get_venue_lat($term_id)); ?> "/> <input type="hidden" name="eo_venue[longtitude]" id="eo_venue_Lng" value="<?php echo esc_attr(eo_get_venue_lng($term_id)); ?> "/> <?php }