function column_default($item, $column_name) { $term_id = (int) $item->term_id; $address = eo_get_venue_address($term_id); switch ($column_name) { case 'venue_slug': return esc_html($item->slug); case 'posts': return intval($item->count); default: $address_keys = array_keys($address); foreach ($address_keys as $key) { if ('venue_' . $key == $column_name) { return esc_html($address[$key]); } } //TODO Hook for extra columns? return print_r($item, true); //Show the whole array for troubleshooting purposes } }
function column_default($item, $column_name) { $term_id = (int) $item->term_id; switch ($column_name) { case 'venue_address': $address = eo_get_venue_address($term_id); return esc_html($address['address']); case 'venue_postal': $address = eo_get_venue_address($term_id); return esc_html($address['postcode']); case 'venue_country': $address = eo_get_venue_address($term_id); return esc_html($address['country']); case 'venue_slug': return esc_html($item->slug); case 'posts': return intval($item->count); default: return print_r($item, true); //Show the whole array for troubleshooting purposes } }
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 }
/** * 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_posterboard_ajax_response() { $page = isset($_GET['page']) ? (int) $_GET['page'] : 1; $query = empty($_GET['query']) ? array() : $_GET['query']; foreach (array('category', 'tag', 'venue') as $tax) { if (isset($query['event_' . $tax])) { $query['event-' . $tax] = $query['event_' . $tax]; unset($query['event_' . $tax]); } } if (isset($query['event-venue']) && '%this%' == $query['event-venue']) { if (eo_get_venue_slug()) { $query['event-venue'] = eo_get_venue_slug(); } else { unset($query['event-venue']); } } if (isset($query['users_events']) && 'true' == strtolower($query['users_events'])) { $query['bookee_id'] = get_current_user_id(); } $query = array_merge(array('event_start_after' => 'today', 'posts_per_page' => 10), $query, array('post_type' => 'event', 'paged' => $page, 'post_status' => array('publish', 'private'), 'perm' => 'readable', 'supress_filters' => false)); $event_query = new WP_Query($query); $response = array(); if ($event_query->have_posts()) { global $post; while ($event_query->have_posts()) { $event_query->the_post(); $start_format = get_option('time_format'); if (eo_get_the_start('Y-m-d') == eo_get_the_end('Y-m-d')) { $end_format = get_option('time_format'); } else { $end_format = 'j M ' . get_option('time_format'); } $venue_id = eo_get_venue(); $categories = get_the_terms(get_the_ID(), 'event-category'); $colour = eo_get_event_color() ? eo_get_event_color() : '#1e8cbe'; $address = eo_get_venue_address($venue_id); $event = array('event_id' => get_the_ID(), 'occurrence_id' => $post->occurrence_id, 'event_title' => get_the_title(), 'event_color' => $colour, 'event_color_light' => eo_color_luminance($colour, 0.3), 'event_start_day' => eo_get_the_start('j'), 'event_start_month' => eo_get_the_start('M'), 'event_content' => get_the_content(), 'event_excerpt' => get_the_excerpt(), 'event_thumbnail' => get_the_post_thumbnail(get_the_ID(), array('200', '200'), array('class' => 'aligncenter')), 'event_permalink' => get_permalink(), 'event_categories' => get_the_term_list(get_the_ID(), 'event-category', '#', ', #', ''), 'event_venue' => $venue_id ? eo_get_venue_name($venue_id) : false, 'event_venue_id' => $venue_id, 'event_venue_city' => $venue_id ? $address['city'] : false, 'event_venue_state' => $venue_id ? $address['state'] : false, 'event_venue_country' => $venue_id ? $address['country'] : false, 'event_venue_url' => $venue_id ? eo_get_venue_link($venue_id) : false, 'event_is_all_day' => eo_is_all_day(), 'event_cat_ids' => $categories ? array_values(wp_list_pluck($categories, 'term_id')) : array(0), 'event_range' => eo_get_the_start($start_format) . ' - ' . eo_get_the_end($end_format)); $event = apply_filters('eventorganiser_posterboard_item', $event, $event['event_id'], $event['occurrence_id']); $response[] = $event; } } wp_reset_postdata(); echo json_encode($response); exit; }
/** * Returns the mark-up for a Google map of the venue (and enqueues scripts). * Accepts an arguments array corresponding to the attributes supported by the shortcode. * * ### Examples * <code> * // Display map of two venues * <?php echo eo_get_venue_map(array('london-eye','edinburgh-castle')); ?> * </code> * @since 1.6 * @link http://wp-event-organiser.com/blog/tutorial/changing-the-venue-map-icon/ Changing the venue map icon * @link http://www.stephenharris.info/2012/event-organiser-1-6-whats-new/ Examples of using eo_get_venue_map() * @param mixed $venue_slug_or_id The venue ID as an integer. Or Slug as string. Uses venue of current event if empty. * @return string The markup of the map. False is no venue found. */ function eo_get_venue_map($venue_slug_or_id = '', $args = array()) { //Cast as array to allow multi venue support if ($venue_slug_or_id == '%all%' || is_array($venue_slug_or_id) && in_array('%all%', $venue_slug_or_id)) { $all_venues = eo_get_venues(); if ($all_venues) { $venue_slug_or_id = array_map('intval', wp_list_pluck($all_venues, 'term_id')); } } if (!is_array($venue_slug_or_id)) { $venue_slug_or_id = array($venue_slug_or_id); } $venue_ids = array_map('eo_get_venue_id_by_slugorid', $venue_slug_or_id); //Map properties $args = shortcode_atts(array('zoom' => 15, 'scrollwheel' => true, 'zoomcontrol' => true, 'rotatecontrol' => true, 'pancontrol' => true, 'overviewmapcontrol' => true, 'streetviewcontrol' => true, 'maptypecontrol' => true, 'draggable' => true, 'maptypeid' => 'ROADMAP', 'width' => '100%', 'height' => '200px', 'class' => '', 'tooltip' => true, 'styles' => array()), $args); //Cast zoom as integer $args['zoom'] = (int) $args['zoom']; //Escape attributes $width = esc_attr($args['width']); $height = esc_attr($args['height']); $class = esc_attr($args['class']); $args['maptypeid'] = strtoupper($args['maptypeid']); //If class is selected use that style, otherwise use specified height and width if (!empty($class)) { $class .= " eo-venue-map googlemap"; $style = ""; } else { $class = "eo-venue-map googlemap"; $style = "style='height:" . $height . ";width:" . $width . ";' "; } $venue_ids = array_filter($venue_ids); if (empty($venue_ids)) { return false; } //Set up venue locations for map foreach ($venue_ids as $venue_id) { //Venue lat/lng array $latlng = eo_get_venue_latlng($venue_id); //Venue tooltip description $tooltip_content = '<strong>' . eo_get_venue_name($venue_id) . '</strong>'; $address = array_filter(eo_get_venue_address($venue_id)); if (!empty($address)) { $tooltip_content .= '<br />' . implode(', ', $address); } /** * Filters the tooltip content for a venue. * * ### Example * * //Adds a link to the venue page to the tooltip * add_filter( 'eventorganiser_venue_tooltip', 'my_venue_tooltip_content_link_to_venue', 10, 2 ); * function my_venue_tooltip_content_link_to_venue( $description, $venue_id ){ * $description .= sprintf('<p><a href="%s"> Visit the venue page! </a> </p>', eo_get_venue_link($venue_id)); * return $description; * } * * @link https://gist.github.com/stephenharris/4988307 Add upcoming events to the the tooltip * @param string $tooltip_content The HTML content for the venue tooltip. * @param int $venue_id The ID of the venue. * @param array $args An array of map options. See documentation for `eo_get_venue_map()`. */ $tooltip_content = apply_filters('eventorganiser_venue_tooltip', $tooltip_content, $venue_id, $args); /** * Filters the url of the venue map marker. Set to `null` for default. * * @link http://wp-event-organiser.com/extensions/event-organiser-venue-markers Custom venue markers * @param string|null $icon Url to the icon image. Null to use default. * @param int $venue_id The ID of the venue. * @param array $args An array of map options. See documentation for `eo_get_venue_map()`. */ $icon = apply_filters('eventorganiser_venue_marker', null, $venue_id, $args); $locations[] = array('venue_id' => $venue_id, 'lat' => $latlng['lat'], 'lng' => $latlng['lng'], 'tooltipContent' => $tooltip_content, 'icon' => $icon); } $map = array_merge($args, array('locations' => $locations)); /** * Filters the tooltip content for a venue. * * ### Example * * //Styles your google map * add_filter( 'eventorganiser_venue_map_options', 'style_my_google_map', 10 ); * function style_my_google_map( $map_args ){ * $map_args['styles'] = {set styles};; * return $map_args; * } * * @link https://developers.google.com/maps/documentation/javascript/styling#styling_the_default_map * @param array $map Array of map properties, including the key 'location' (array of locations) * height, width, zoom and styles. */ $map = apply_filters('eventorganiser_venue_map_options', $map); //This could be improved EventOrganiser_Shortcodes::$map[] = $map; EventOrganiser_Shortcodes::$add_script = true; $id = count(EventOrganiser_Shortcodes::$map); return "<div class='" . $class . "' id='eo_venue_map-{$id}' " . $style . "></div>"; }
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; }
static function parse_template($matches) { global $post; $replacement = ''; switch ($matches[1]) { case 'event_title': $replacement = get_the_title(); break; case 'start': case 'end': case 'schedule_start': case 'schedule_last': case 'schedule_end': switch (count($matches)) { case 2: $dateFormat = get_option('date_format'); $dateTime = get_option('time_format'); break; case 3: $dateFormat = self::eo_clean_input($matches[2]); $dateTime = ''; break; case 5: $dateFormat = self::eo_clean_input($matches[3]); $dateTime = self::eo_clean_input($matches[4]); break; } $format = eo_is_all_day(get_the_ID()) ? $dateFormat : $dateFormat . $dateTime; switch ($matches[1]) { case 'start': $replacement = eo_get_the_start($format); break; case 'end': $replacement = eo_get_the_end($format); break; case 'schedule_start': $replacement = eo_get_schedule_start($format); break; case 'schedule_last': case 'schedule_end': $replacement = eo_get_schedule_end($format); break; } break; case 'event_duration': $start = eo_get_the_start(DATETIMEOBJ); $end = clone eo_get_the_end(DATETIMEOBJ); if (eo_is_all_day()) { $end->modify('+1 minute'); } if (function_exists('date_diff')) { $duration = date_diff($start, $end); $replacement = $duration->format($matches[2]); } else { $replacement = eo_date_interval($start, $end, $matches[2]); } $replacement = false; break; case 'event_tags': $replacement = get_the_term_list(get_the_ID(), 'event-tag', '', ', ', ''); break; case 'event_cats': $replacement = get_the_term_list(get_the_ID(), 'event-category', '', ', ', ''); break; case 'event_venue': $replacement = eo_get_venue_name(); break; case 'event_venue_map': if (eo_get_venue()) { $class = isset($matches[2]) ? self::eo_clean_input($matches[2]) : ''; $class = !empty($class) ? 'class=' . $class : ''; $replacement = eo_get_venue_map(eo_get_venue(), compact('class')); } break; case 'event_venue_url': $venue_link = eo_get_venue_link(); $replacement = !is_wp_error($venue_link) ? $venue_link : ''; break; case 'event_venue_address': $address = eo_get_venue_address(); $replacement = $address['address']; break; case 'event_venue_postcode': $address = eo_get_venue_address(); $replacement = $address['postcode']; break; case 'event_venue_city': $address = eo_get_venue_address(); $replacement = $address['city']; break; case 'event_venue_country': $address = eo_get_venue_address(); $replacement = $address['country']; break; case 'event_venue_state': $address = eo_get_venue_address(); $replacement = $address['state']; break; case 'event_venue_city': $address = eo_get_venue_address(); $replacement = $address['city']; break; case 'event_thumbnail': $size = isset($matches[2]) ? self::eo_clean_input($matches[2]) : ''; $size = !empty($size) ? $size : 'thumbnail'; $attr = isset($matches[3]) ? self::eo_clean_input($matches[3]) : ''; //Decode HTML entities as shortcode encodes them $attr = html_entity_decode($attr); $replacement = get_the_post_thumbnail(get_the_ID(), $size, $attr); break; case 'event_url': $replacement = get_permalink(); break; case 'event_custom_field': $field = $matches[2]; $meta = get_post_meta(get_the_ID(), $field); $replacement = implode($meta); break; case 'event_excerpt': $length = isset($matches[2]) ? intval($matches[2]) : 55; //Using get_the_excerpt adds a link.... if (post_password_required($post)) { $output = __('There is no excerpt because this is a protected post.'); } else { $output = $post->post_excerpt; } $replacement = eventorganiser_trim_excerpt($output, $length); break; case 'event_content': $replacement = get_the_content(); break; case 'cat_color': $replacement = eo_get_event_color(); break; case 'event_title_attr': $replacement = get_the_title(); break; } return $replacement; }
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 the mark-up for a Google map of the venue (and enqueues scripts). * Accepts an arguments array corresponding to the attributes supported by the shortcode. * * ### Examples * <code> * // Display map of two venues * <?php echo eo_get_venue_map(array('london-eye','edinburgh-castle')); ?> * </code> * @since 1.6 * @link http://wp-event-organiser.com/blog/tutorial/changing-the-venue-map-icon/ Changing the venue map icon * @link http://www.stephenharris.info/2012/event-organiser-1-6-whats-new/ Examples of using eo_get_venue_map() * @param mixed $venue_slug_or_id The venue ID as an integer. Or Slug as string. Uses venue of current event if empty. * @return string The markup of the map. False is no venue found. */ function eo_get_venue_map($venue_slug_or_id = '', $args = array()) { //Cast as array to allow multi venue support if ($venue_slug_or_id == '%all%' || is_array($venue_slug_or_id) && in_array('%all%', $venue_slug_or_id)) { $all_venues = eo_get_venues(); if ($all_venues) { $venue_slug_or_id = array_map('intval', wp_list_pluck($all_venues, 'term_id')); } } if (!is_array($venue_slug_or_id)) { $venue_slug_or_id = array($venue_slug_or_id); } $venue_ids = array_map('eo_get_venue_id_by_slugorid', $venue_slug_or_id); //Map properties $args = shortcode_atts(array('zoom' => 15, 'scrollwheel' => true, 'zoomcontrol' => true, 'rotatecontrol' => true, 'pancontrol' => true, 'overviewmapcontrol' => true, 'streetviewcontrol' => true, 'maptypecontrol' => true, 'draggable' => true, 'maptypeid' => 'ROADMAP', 'width' => '100%', 'height' => '200px', 'class' => '', 'tooltip' => true), $args); //Cast zoom as integer $args['zoom'] = (int) $args['zoom']; //Escape attributes $width = esc_attr($args['width']); $height = esc_attr($args['height']); $class = esc_attr($args['class']); $args['maptypeid'] = strtoupper($args['maptypeid']); //If class is selected use that style, otherwise use specified height and width if (!empty($class)) { $class .= " eo-venue-map googlemap"; $style = ""; } else { $class = "eo-venue-map googlemap"; $style = "style='height:" . $height . ";width:" . $width . ";' "; } $venue_ids = array_filter($venue_ids); if (empty($venue_ids)) { return false; } //Set up venue locations for map foreach ($venue_ids as $venue_id) { //Venue lat/lng array $latlng = eo_get_venue_latlng($venue_id); //Venue tooltip description $tooltip_content = '<strong>' . eo_get_venue_name($venue_id) . '</strong>'; $address = array_filter(eo_get_venue_address($venue_id)); if (!empty($address)) { $tooltip_content .= '<br />' . implode(', ', $address); } $tooltip_content = apply_filters('eventorganiser_venue_tooltip', $tooltip_content, $venue_id, $args); $icon = apply_filters('eventorganiser_venue_marker', null, $venue_id, $args); $locations[] = array('venue_id' => $venue_id, 'lat' => $latlng['lat'], 'lng' => $latlng['lng'], 'tooltipContent' => $tooltip_content, 'icon' => $icon); } //This could be improved EventOrganiser_Shortcodes::$map[] = array_merge($args, array('locations' => $locations)); EventOrganiser_Shortcodes::$add_script = true; $id = count(EventOrganiser_Shortcodes::$map); return "<div class='" . $class . "' id='eo_venue_map-{$id}' " . $style . "></div>"; }
/** * Check that the upgrade routine run for users updating EO after * updating to WP 4.2 is able to recover 'lost' data. */ public function testPostSplitTermsUpgrade() { global $wpdb; if (version_compare(get_bloginfo('version'), '4.2-alpha-31007-src', '<')) { $this->markTestSkipped(sprintf('This test applies only to 4.2-alpha-31007-src+, running %s', get_bloginfo('version'))); return; } remove_action('split_shared_term', '_eventorganiser_handle_split_shared_terms', 10); register_taxonomy('wptests_tax', 'event'); //Create terms - they'll have unique term IDs $t1 = wp_insert_term('Foo', 'wptests_tax'); $t2 = eo_insert_venue('Foo', array('address' => 'Edinburgh Castle', 'city' => 'Edinburgh', 'country' => 'UK')); $t3 = wp_insert_term('Foo', 'event-category'); //Manually modify the terms so they share term IDs $wpdb->update($wpdb->term_taxonomy, array('term_id' => $t1['term_id']), array('term_taxonomy_id' => $t2['term_taxonomy_id']), array('%d'), array('%d')); $wpdb->update($wpdb->term_taxonomy, array('term_id' => $t1['term_id']), array('term_taxonomy_id' => $t3['term_taxonomy_id']), array('%d'), array('%d')); //Insert/move data so it is assigned to 'pre-split ID'. update_option('eo-event-category_' . $t1['term_id'], array('colour' => '#ff0000')); $wpdb->update($wpdb->eo_venuemeta, array('eo_venue_id' => $t1['term_id']), array('eo_venue_id' => $t2['term_id'])); //Create event and assign terms so we can retrieve term IDs $events = $this->factory->event->create_many(3); wp_set_object_terms($events[0], array('Foo'), 'wptests_tax'); wp_set_object_terms($events[1], array('Foo'), 'event-venue'); wp_set_object_terms($events[2], array('Foo'), 'event-category'); // Verify that the term IDs are shared. $t1_terms = wp_get_object_terms($events[0], 'wptests_tax'); $t2_terms = wp_get_object_terms($events[1], 'event-venue'); $t3_terms = wp_get_object_terms($events[2], 'event-category'); $this->assertSame($t1_terms[0]->term_id, $t2_terms[0]->term_id); $this->assertSame($t1_terms[0]->term_id, $t3_terms[0]->term_id); //Split by updating venue eo_update_venue($t2_terms[0]->term_id, array('name' => 'Venue Foo')); wp_update_term($t3_terms[0]->term_id, 'event-category', array('name' => 'Category Foo')); //Check meta data is "lost" $t2_terms = wp_get_object_terms($events[1], 'event-venue'); $t3_terms = wp_get_object_terms($events[2], 'event-category'); $address = eo_get_venue_address($t2_terms[0]->term_id); $this->assertEquals('', ''); $meta = get_option('eo-event-category_' . $t3_terms[0]->term_id); $this->assertEquals(false, $meta); //Run upgrade routine eventorganiser_021200_update(); //Check data is recovered $t2_terms = wp_get_object_terms($events[1], 'event-venue'); $t3_terms = wp_get_object_terms($events[2], 'event-category'); $address = eo_get_venue_address($t2_terms[0]->term_id); $this->assertEquals('Edinburgh', $address['city']); $meta = get_option('eo-event-category_' . $t3_terms[0]->term_id); $this->assertEquals('#ff0000', $meta['colour']); add_action('split_shared_term', '_eventorganiser_handle_split_shared_terms', 10, 4); }
/** * Returns a the url which adds a particular occurrence of an event to * a google calendar. * * Returns an url which adds a particular occurrence of an event to a Google calendar. This function can only be used inside the loop. * An entire series cannot be added to a Google calendar - however users can subscribe to your events. Please note that, unlike * subscribing to events, changes made to an event will not be reflected on an event added to the Google calendar. * * ### Examples * Add a 'add this event to Google' link: * <code> * <?php * //Inside the loop * $url = eo_get_add_to_google_link(); * echo '<a href="'.esc_url($url).'" title="Click to add this event to a Google calendar"> Add to Google </a>'; * ?> * </code> * @since 2.3 * @param int $post_id Post ID of the event. * @param int $occurrence_id The occurrence ID. * @return string Url which adds event to a google calendar */ function eo_get_add_to_google_link($event_id = 0, $occurrence_id = 0) { global $post; $event = $post; $event_id = (int) ($event_id ? $event_id : get_the_ID()); $occurrence_id = (int) (!$occurrence_id && isset($event->occurrence_id) ? $event->occurrence_id : $occurrence_id); $post = get_post($event_id); if (!$occurrence_id || !$post || 'event' != get_post_type($post)) { wp_reset_postdata(); return false; } setup_postdata($post); $start = clone eo_get_the_start(DATETIMEOBJ, $event_id, null, $occurrence_id); $end = clone eo_get_the_end(DATETIMEOBJ, $event_id, null, $occurrence_id); if (eo_is_all_day()) { $end->modify('+1 second'); $format = 'Ymd'; } else { $format = 'Ymd\\THis\\Z'; $start->setTimezone(new DateTimeZone('UTC')); $end->setTimezone(new DateTimeZone('UTC')); } /** * @ignore */ $excerpt = apply_filters('the_excerpt_rss', get_the_excerpt()); $url = add_query_arg(array('text' => get_the_title(), 'dates' => $start->format($format) . '/' . $end->format($format), 'trp' => false, 'details' => esc_html($excerpt), 'sprop' => get_bloginfo('name')), 'http://www.google.com/calendar/event?action=TEMPLATE'); $venue_id = eo_get_venue(); if ($venue_id) { $venue = eo_get_venue_name($venue_id) . ", " . implode(', ', eo_get_venue_address($venue_id)); $url = add_query_arg('location', $venue, $url); } wp_reset_postdata(); return $url; }
/** * Returns a the url which adds a particular occurrence of an event to * a google calendar. * Must be used inside the loop * * @since 1.2.0 */ function eo_get_the_GoogleLink() { global $post; setup_postdata($post); if (empty($post) || get_post_type($post) != 'event') { return false; } $startDT = new DateTime($post->StartDate . ' ' . $post->StartTime, eo_get_blog_timezone()); $endDT = new DateTime($post->EndDate . ' ' . $post->FinishTime, eo_get_blog_timezone()); if (eo_is_allday()) { $endDT->modify('+1 second'); $format = 'Ymd'; } else { $format = 'Ymd\\THis\\Z'; $startDT->setTimezone(new DateTimeZone('UTC')); $endDT->setTimezone(new DateTimeZone('UTC')); } $excerpt = get_the_excerpt(); $excerpt = apply_filters('the_excerpt_rss', $excerpt); $excerpt = esc_html($excerpt); $url = add_query_arg(array('text' => $post->post_title, 'dates' => $startDT->format($format) . '/' . $endDT->format($format), 'trp' => false, 'details' => $excerpt, 'sprop' => get_bloginfo('name')), 'http://www.google.com/calendar/event?action=TEMPLATE'); if ($post->Venue) { $venue = eo_get_venue_name((int) $post->Venue) . ", " . implode(', ', eo_get_venue_address((int) $post->Venue)); $url = add_query_arg('location', $venue, $url); } wp_reset_postdata(); return $url; }
function parse_template($matches) { global $post; $replacement = ''; $col = array('start' => array('date' => 'StartDate', 'time' => 'StartTime'), 'end' => array('date' => 'EndDate', 'time' => 'FinishTime'), 'schedule_start' => array('date' => 'reoccurrence_start', 'time' => 'StartTime'), 'schedule_end' => array('date' => 'reoccurrence_end', 'time' => 'FinishTime')); switch ($matches[1]) { case 'event_title': $replacement = get_the_title(); break; case 'start': case 'end': case 'schedule_start': case 'schedule_end': switch (count($matches)) { case 2: $dateFormat = get_option('date_format'); $dateTime = get_option('time_format'); break; case 3: $dateFormat = self::eo_clean_input($matches[2]); $dateTime = ''; break; case 5: $dateFormat = self::eo_clean_input($matches[3]); $dateTime = self::eo_clean_input($matches[4]); break; } if (eo_is_all_day(get_the_ID())) { $replacement = eo_format_date($post->{$col}[$matches[1]]['date'] . ' ' . $post->{$col}[$matches[1]]['time'], $dateFormat); } else { $replacement = eo_format_date($post->{$col}[$matches[1]]['date'] . ' ' . $post->{$col}[$matches[1]]['time'], $dateFormat . $dateTime); } break; case 'event_tags': $replacement = get_the_term_list(get_the_ID(), 'event-tag', '', ', ', ''); break; case 'event_cats': $replacement = get_the_term_list(get_the_ID(), 'event-category', '', ', ', ''); break; case 'event_venue': $replacement = eo_get_venue_name(); break; case 'event_venue_map': if (eo_get_venue()) { $class = isset($matches[2]) ? self::eo_clean_input($matches[2]) : ''; $class = !empty($class) ? 'class=' . $class : ''; $replacement = do_shortcode('[eo_venue_map ' . $class . ']'); } break; case 'event_venue_url': $venue_link = eo_get_venue_link(); $replacement = !is_wp_error($venue_link) ? $venue_link : ''; break; case 'event_venue_address': $address = eo_get_venue_address(); $replacement = $address['address']; break; case 'event_venue_postcode': $address = eo_get_venue_address(); $replacement = $address['postcode']; break; case 'event_venue_country': $address = eo_get_venue_address(); $replacement = $address['country']; break; case 'event_thumbnail': $size = isset($matches[2]) ? self::eo_clean_input($matches[2]) : ''; $size = !empty($size) ? $size : 'thumbnail'; $replacement = get_the_post_thumbnail(get_the_ID(), $size); break; case 'event_url': $replacement = get_permalink(); break; case 'event_custom_field': $field = $matches[2]; $meta = get_post_meta(get_the_ID(), $field); $replacement = implode($meta); break; case 'event_excerpt': //Using get_the_excerpt adds a link.... if (post_password_required($post)) { $output = __('There is no excerpt because this is a protected post.'); } else { $output = $post->post_excerpt; } $replacement = wp_trim_excerpt($output); break; case 'cat_color': $replacement = eo_event_color(); break; } return $replacement; }
echo eo_get_schedule_start($time_format); ?> </li> <li><strong><?php _e('Address', 'eventorganiser'); ?> :</strong> <?php $address_details = eo_get_venue_address(); echo $address_details['address']; ?> </li> <li><strong><?php _e('Location', 'eventorganiser'); ?> :</strong> <?php $address_details = eo_get_venue_address(); echo $address_details['city'] . ', ' . $address_details['state'] . ' ' . $address_details['postcode']; ?> </li> <li class="event-list-rules-link"><strong><a href="<?php echo get_page_link(get_page_by_title(Rules)->ID); ?> ">Auction Rules</a></strong></li> <?php } ?> <?php if (get_the_terms(get_the_ID(), 'event-category')) { ?>
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 }
/** * 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; }
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 }