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 
}
/**
 * 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>";
}
/**
 * Handles city auto-fill request.
 *
 * Hooked onto admin_post_eo-autofillcity. Triggered when user clicks 'autofill' link.
 * This routine goes through all the venues, reverse geocodes to find their city and 
 * autofills the city field (added in 1.7).
 *
 *@ignore
 *@access private
 *@link https://github.com/stephenh1988/Event-Organiser/issues/18
 *@link http://open.mapquestapi.com/nominatim/ Nominatim Search Service
 */
function _eventorganiser_autofill_city()
{
    $seen_notices = get_option('eventorganiser_admin_notices', array());
    if (in_array('autofillvenue17', $seen_notices)) {
        return;
    }
    EO_Admin_Notice_Handler::dismiss_notice('autofillvenue17');
    $cities = array();
    $venues = eo_get_venues();
    foreach ($venues as $venue) {
        $venue_id = (int) $venue->term_id;
        $latlng = extract(eo_get_venue_latlng($venue_id));
        if (eo_get_venue_meta($venue_id, '_city', true)) {
            continue;
        }
        $response = wp_remote_get("http://open.mapquestapi.com/nominatim/v1/reverse?format=json&lat={$lat}&lon={$lng}&osm_type=N&limit=1");
        $geo = json_decode(wp_remote_retrieve_body($response));
        if (isset($geo->address->city)) {
            $cities[$venue_id] = $geo->address->city;
            eo_update_venue_meta($venue_id, '_city', $geo->address->city);
        }
        if (isset($geo->address->country_code) && 'gb' == $geo->address->country_code) {
            //For the UK use county not state.
            if (isset($geo->address->county)) {
                $cities[$venue_id] = $geo->address->county;
                eo_update_venue_meta($venue_id, '_state', $geo->address->county);
            }
        } else {
            if (isset($geo->address->state)) {
                $cities[$venue_id] = $geo->address->state;
                eo_update_venue_meta($venue_id, '_state', $geo->address->state);
            }
        }
    }
    wp_safe_redirect(admin_url('edit.php?post_type=event&page=venues'));
}
Beispiel #4
0
        $description = eventorganiser_escape_ical_text($description);
        if (!empty($description)) {
            echo eventorganiser_fold_ical_text("DESCRIPTION: {$description}") . "\r\n";
        }
        $description = wpautop(html_entity_decode(get_the_content(), ENT_COMPAT, 'UTF-8'));
        $description = str_replace("\r\n", '', $description);
        //Remove new lines
        $description = str_replace("\n", '', $description);
        $description = eventorganiser_escape_ical_text($description);
        echo eventorganiser_fold_ical_text("X-ALT-DESC;FMTTYPE=text/html: {$description}") . "\r\n";
        $cats = get_the_terms(get_the_ID(), 'event-category');
        if ($cats && !is_wp_error($cats)) {
            $cat_names = wp_list_pluck($cats, 'name');
            $cat_names = array_map('eventorganiser_escape_ical_text', $cat_names);
            echo 'CATEGORIES:' . implode(',', $cat_names) . "\r\n";
        }
        if (eo_get_venue()) {
            $venue = eo_get_venue_name(eo_get_venue());
            echo "LOCATION:" . eventorganiser_fold_ical_text(eventorganiser_escape_ical_text($venue)) . "\r\n";
            echo "GEO:" . implode(';', eo_get_venue_latlng($venue)) . "\r\n";
        }
        if (get_the_author_meta('ID')) {
            $author_name = eventorganiser_escape_ical_text(get_the_author());
            $author_email = eventorganiser_escape_ical_text(get_the_author_meta('user_email'));
            echo eventorganiser_fold_ical_text('ORGANIZER;CN="' . $author_name . '":MAILTO:' . $author_email) . "\r\n";
        }
        echo eventorganiser_fold_ical_text('URL;VALUE=URI:' . get_permalink()) . "\r\n";
        echo "END:VEVENT\r\n";
    }
}
echo "END:VCALENDAR\r\n";
/**
 * 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>";
}
 function get_venue_map($venue_id, $args)
 {
     self::$add_script = true;
     extract(shortcode_atts(array('zoom' => 15, 'width' => '100%', 'height' => '200px', 'class' => ''), $args));
     //Set zoom
     $zoom = (int) $zoom;
     //Set the attributes
     $width = esc_attr($width);
     $height = esc_attr($height);
     //If class is selected use that style, otherwise use specified height and width
     if (!empty($class)) {
         $class = esc_attr($class) . " eo-venue-map googlemap";
         $style = "";
     } else {
         $class = "eo-venue-map googlemap";
         $style = "style='height:" . $height . ";width:" . $width . ";' ";
     }
     //Get latlng value by slug
     $latlng = eo_get_venue_latlng($venue_id);
     self::$map[] = array('lat' => $latlng['lat'], 'lng' => $latlng['lng'], 'zoom' => $zoom);
     $id = count(self::$map);
     $return = "<div class='" . $class . "' id='eo_venue_map-{$id}' " . $style . "></div>";
     return $return;
 }