예제 #1
0
/**
 * 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;
}
예제 #2
0
/**
 * Retrieve array of venues. Acts as a wrapper for get_terms, except hide_empty defaults to false.
 * @since 1.0.0
 * @deprecated 1.6
 * @see eo_get_venues()
 *
 * @param string|array $args The values of what to search for when returning venues
 * @return array List of Term (venue) Objects
 */
function eo_get_the_venues($args = array())
{
    _deprecated_function(__FUNCTION__, '1.6', 'eo_get_venues()');
    return eo_get_venues($args);
}
예제 #3
0
/**
* Sets up the event data metabox
* This allows user to enter date / time, reoccurrence and venue data for the event
* @ignore
* @since 1.0.0
*/
function _eventorganiser_details_metabox($post)
{
    global $wp_locale;
    //Sets the format as php understands it, and textual.
    $phpFormat = eventorganiser_get_option('dateformat');
    if ('d-m-Y' == $phpFormat) {
        $format = 'dd-mm-yyyy';
        //Human form
    } elseif ('Y-m-d' == $phpFormat) {
        $format = 'yyyy-mm-dd';
        //Human form
    } else {
        $format = 'mm-dd-yyyy';
        //Human form
    }
    $is24 = eventorganiser_blog_is_24();
    $time_format = $is24 ? 'H:i' : 'g:ia';
    //Get the starting day of the week
    $start_day = intval(get_option('start_of_week'));
    $ical_days = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
    //Retrieve event details
    extract(eo_get_event_schedule($post->ID));
    $venues = eo_get_venues();
    $venue_id = (int) eo_get_venue($post->ID);
    //$sche_once is used to disable date editing unless the user specifically requests it.
    //But a new event might be recurring (via filter), and we don't want to 'lock' new events.
    //See https://wordpress.org/support/topic/wrong-default-in-input-element
    $sche_once = $schedule == 'once' || !empty(get_current_screen()->action);
    if (!$sche_once) {
        $notices = '<strong>' . __('This is a reoccurring event', 'eventorganiser') . '</strong>. ' . __('Check to edit this event and its reoccurrences', 'eventorganiser') . ' <input type="checkbox" id="HWSEvent_rec" name="eo_input[AlterRe]" value="yes">';
    } else {
        $notices = '';
    }
    //Start of meta box
    /**
     * Filters the notice at the top of the event details metabox.
     * 
     * @param string  $notices The message text.
     * @param WP_Post $post    The corresponding event (post).
     */
    $notices = apply_filters('eventorganiser_event_metabox_notice', $notices, $post);
    if ($notices) {
        echo '<div class="updated below-h2"><p>' . $notices . '</p></div>';
    }
    ?>
	<div class="<?php 
    echo $sche_once ? 'onetime' : 'reoccurence';
    ?>
">
		<p>
		<?php 
    if ($is24) {
        printf(__('Ensure dates are entered in %1$s format and times in 24 hour format', 'eventorganiser'), '<strong>' . $format . '</strong>');
    } else {
        printf(__('Ensure dates are entered in %1$s format and times in 12 hour format', 'eventorganiser'), '<strong>' . $format . '</strong>');
    }
    ?>
 		</p>

		<table id="eventorganiser_event_detail" class="form-table">
				<tr valign="top" class="event-date">
					<td class="eo-label"><?php 
    echo __('Start Date/Time', 'eventorganiser') . ':';
    ?>
 </td>
					<td> 
						<input class="ui-widget-content ui-corner-all" name="eo_input[StartDate]" size="10" maxlength="10" id="from_date" <?php 
    disabled(!$sche_once);
    ?>
 value="<?php 
    echo $start->format($phpFormat);
    ?>
"/>
						<?php 
    printf('<input name="eo_input[StartTime]" class="eo_time ui-widget-content ui-corner-all" size="6" maxlength="8" id="HWSEvent_time" %s value="%s"/>', disabled(!$sche_once || $all_day, true, false), eo_format_datetime($start, $time_format));
    ?>
						

					</td>
				</tr>

				<tr valign="top" class="event-date">
					<td class="eo-label"><?php 
    echo __('End Date/Time', 'eventorganiser') . ':';
    ?>
 </td>
					<td> 
						<input class="ui-widget-content ui-corner-all" name="eo_input[EndDate]" size="10" maxlength="10" id="to_date" <?php 
    disabled(!$sche_once);
    ?>
  value="<?php 
    echo $end->format($phpFormat);
    ?>
"/>
					
						<?php 
    printf('<input name="eo_input[FinishTime]" class="eo_time ui-widget-content ui-corner-all" size="6" maxlength="8" id="HWSEvent_time2" %s value="%s"/>', disabled(!$sche_once || $all_day, true, false), eo_format_datetime($end, $time_format));
    ?>
	

					<label>
					<input type="checkbox" id="eo_allday"  <?php 
    checked($all_day);
    ?>
 name="eo_input[allday]"  <?php 
    disabled(!$sche_once);
    ?>
 value="1"/>
						<?php 
    _e('All day', 'eventorganiser');
    ?>
					 </label>
			
					</td>
				</tr>

				<tr class="event-date">
					<td class="eo-label"><?php 
    _e('Reoccurence:', 'eventorganiser');
    ?>
 </td>
					<td> 
					<?php 
    $reoccurrence_schedules = array('once' => __('once', 'eventorganiser'), 'daily' => __('daily', 'eventorganiser'), 'weekly' => __('weekly', 'eventorganiser'), 'monthly' => __('monthly', 'eventorganiser'), 'yearly' => __('yearly', 'eventorganiser'), 'custom' => __('custom', 'eventorganiser'));
    ?>

					<select id="HWSEventInput_Req" name="eo_input[schedule]">
						<?php 
    foreach ($reoccurrence_schedules as $index => $val) {
        ?>
							<option value="<?php 
        echo $index;
        ?>
" <?php 
        selected($schedule, $index);
        ?>
><?php 
        echo $val;
        ?>
</option>
						<?php 
    }
    //End foreach $allowed_reoccurs
    ?>
					</select>
					</td>
				</tr>

				<tr valign="top"  class="event-date reocurrence_row">
					<td></td>
					<td>
						<p><?php 
    _e('Repeat every', 'eventorganiser');
    ?>
 
						<input <?php 
    disabled(!$sche_once || $all_day);
    ?>
 class="ui-widget-content ui-corner-all" name="eo_input[event_frequency]" id="HWSEvent_freq" type="number" min="1" max="365" maxlength="4" size="4" disabled="disabled" value="<?php 
    echo $frequency;
    ?>
" /> 
						<span id="recpan" >  </span>				
						</p>

						<p id="dayofweekrepeat">
						<?php 
    _e('on', 'eventorganiser');
    ?>
	
						<?php 
    for ($i = 0; $i <= 6; $i++) {
        $d = ($start_day + $i) % 7;
        $ical_d = $ical_days[$d];
        $day = $wp_locale->weekday_abbrev[$wp_locale->weekday[$d]];
        $schedule_days = is_array($schedule_meta) ? $schedule_meta : array();
        ?>
							<input type="checkbox" id="day-<?php 
        echo $day;
        ?>
"  <?php 
        checked(in_array($ical_d, $schedule_days), true);
        ?>
  value="<?php 
        echo esc_attr($ical_d);
        ?>
" class="daysofweek" name="eo_input[days][]" disabled="disabled" />
							<label for="day-<?php 
        echo $day;
        ?>
" > <?php 
        echo $day;
        ?>
</label>
						<?php 
    }
    ?>
						</p>

						<p id="dayofmonthrepeat">
						<label for="bymonthday" >	
							<input type="radio" id="bymonthday" disabled="disabled" name="eo_input[schedule_meta]" <?php 
    checked($occurs_by, 'BYMONTHDAY');
    ?>
 value="BYMONTHDAY=" /> 
							<?php 
    _e('day of month', 'eventorganiser');
    ?>
						</label>
						<label for="byday" >
							<input type="radio" id="byday" disabled="disabled" name="eo_input[schedule_meta]"  <?php 
    checked($occurs_by != 'BYMONTHDAY', true);
    ?>
 value="BYDAY=" /> 
							<?php 
    _e('day of week', 'eventorganiser');
    ?>
						</label>
						</p>

						<p class="reoccurrence_label">
						<?php 
    _e('until', 'eventorganiser');
    ?>
 
						<input <?php 
    disabled(!$sche_once || $all_day);
    ?>
 class="ui-widget-content ui-corner-all" name="eo_input[schedule_end]" id="recend" size="10" maxlength="10" disabled="disabled" value="<?php 
    echo $until->format($phpFormat);
    ?>
"/>
						</p>

						<p id="event_summary"> </p>
					</td>
				</tr>

				<tr valign="top" id="eo_occurrence_picker_row" class="event-date">
					<td class="eo-label">	
						<?php 
    esc_html_e('Include/Exclude occurrences', 'eventorganiser');
    ?>
					</td>
					<td>
						<?php 
    submit_button(__('Show dates', 'eventorganiser'), 'hide-if-no-js eo_occurrence_toggle button small', 'eo_date_toggle', false);
    ?>
						
						<div id="eo_occurrence_datepicker"></div>
						<?php 
    //var_dump($include);
    if (!empty($include)) {
        $include_str = array_map('eo_format_datetime', $include, array_fill(0, count($include), 'Y-m-d'));
        $include_str = esc_textarea(sanitize_text_field(implode(',', $include_str)));
    } else {
        $include_str = '';
    }
    ?>
						<textarea style="display:none;" name="eo_input[include]" id="eo_occurrence_includes"><?php 
    echo $include_str;
    ?>
</textarea>

						<?php 
    if (!empty($exclude)) {
        $exclude_str = array_map('eo_format_datetime', $exclude, array_fill(0, count($exclude), 'Y-m-d'));
        $exclude_str = esc_textarea(sanitize_text_field(implode(',', $exclude_str)));
    } else {
        $exclude_str = '';
    }
    ?>
						<textarea style="display:none;" name="eo_input[exclude]" id="eo_occurrence_excludes"><?php 
    echo $exclude_str;
    ?>
</textarea>

					</td>
				</tr>
				<?php 
    $tax = get_taxonomy('event-venue');
    if (taxonomy_exists('event-venue')) {
        ?>
		
					
						<tr valign="top" class="eo-venue-combobox-select">
							<td class="eo-label"> <?php 
        echo esc_html($tax->labels->singular_name_colon);
        ?>
 </td>
							<td> 	
								<select size="50" id="venue_select" name="eo_input[event-venue]">
									<option><?php 
        _e('Select a venue', 'eventorganiser');
        ?>
</option>
									<?php 
        foreach ($venues as $venue) {
            ?>
										<option <?php 
            selected($venue->term_id, $venue_id);
            ?>
 value="<?php 
            echo intval($venue->term_id);
            ?>
"><?php 
            echo esc_html($venue->name);
            ?>
</option>
									<?php 
        }
        ?>
								</select>
							</td>
						</tr>
		
						<!-- Add New Venue --> 
						<tr valign="top" class="eo-add-new-venue">
							<td class="eo-label"><label><?php 
        _e('Venue Name', 'eventorganiser');
        ?>
:</label></td>
							<td><input type="text" name="eo_venue[name]" id="eo_venue_name"  value=""/></td>
						</tr>
						<?php 
        $address_fields = _eventorganiser_get_venue_address_fields();
        foreach ($address_fields as $key => $label) {
            printf('<tr valign="top" class="eo-add-new-venue">
									<td class="eo-label"><label>%1$s:</label></td>
									<td><input type="text" name="eo_venue[%2$s]" class="eo_addressInput" id="eo_venue_add"  value=""/></td>
								</tr>', $label, esc_attr(trim($key, '_')));
        }
        ?>
						<tr valign="top" class="eo-add-new-venue" >
							<td class="eo-label"></td>
							<td>
								<a class="button eo-add-new-venue-cancel" href="#"><?php 
        esc_html_e('Cancel', 'eventorganiser');
        ?>
 </a>
							</td>
						</tr>

						<!-- Venue Map --> 
						<tr valign="top"  class="venue_row <?php 
        if (!$venue_id) {
            echo 'novenue';
        }
        ?>
" >
							<td class="eo-label"></td>
							<td>
								<div id="eventorganiser_venue_meta" style="display:none;">
									<input type="hidden" id="eo_venue_Lat" name="eo_venue[latitude]" value="<?php 
        eo_venue_lat($venue_id);
        ?>
" />
									<input type="hidden" id="eo_venue_Lng" name="eo_venue[longtitude]" value="<?php 
        eo_venue_lng($venue_id);
        ?>
" />
								</div>
								<div id="venuemap" class="ui-widget-content ui-corner-all gmap3"></div>
								<div class="clear"></div>
							</td>
						</tr>
				<?php 
    }
    //endif venue's supported
    ?>
			</table>
		</div>
	<?php 
    // create a custom nonce for submit verification later
    wp_nonce_field('eventorganiser_event_update_' . get_the_ID() . '_' . get_current_blog_id(), '_eononce');
}
예제 #4
0
function eventorganiser_posterboard_shortcode_handler($atts = array())
{
    $defaults = array('filters' => '');
    $query = array_diff_key((array) $atts, $defaults);
    $atts = shortcode_atts($defaults, $atts);
    $query = array_merge(array('posts_per_page' => 10), $query);
    //Get template
    ob_start();
    eo_locate_template('single-event-board-item.html', true, false);
    $template = ob_get_contents();
    ob_end_clean();
    //Load & 'localize' script
    if (!eventorganiser_get_option('disable_css')) {
        wp_enqueue_style('eo_posterboard');
    }
    wp_enqueue_script('eo_posterboard');
    wp_localize_script('eo_posterboard', 'eventorganiser_posterboard', array('url' => admin_url('admin-ajax.php'), 'loading' => __('Loading...', 'event-organiser-posterboard'), 'load_more' => __('Load more', 'event-organiser-posterboard'), 'template' => $template, 'query' => $query));
    //Handle filters
    $filters = explode(',', $atts['filters']);
    $filers_markup = '';
    $venues = eo_get_venues();
    $cats = get_terms(array('event-category'), array('hide_empty' => false));
    //'state'/'country'/'city' functions only available in Pro
    $is_pro_active = in_array('event-organiser-pro/event-organiser-pro.php', (array) get_option('active_plugins', array()));
    if ($filters) {
        foreach ($filters as $filter) {
            $filter = strtolower(trim($filter));
            switch ($filter) {
                case 'venue':
                    if ($venues) {
                        foreach ($venues as $venue) {
                            $filers_markup .= sprintf('<a href="#" class="eo-eb-filter eo-eb-filter-venue eo-eb-filter-venue-%1$d" data-filter-type="venue" data-venue="%1$d" data-filter-on="false">%2$s</a>', $venue->term_id, $venue->name);
                        }
                    }
                    break;
                case 'category':
                    if ($cats) {
                        foreach ($cats as $cat) {
                            $filers_markup .= sprintf('<a href="#" class="eo-eb-filter eo-eb-filter-category eo-eb-filter-category-%1$d" data-filter-type="category" data-category="%1$d" data-filter-on="false">%2$s</a>', $cat->term_id, $cat->name);
                        }
                    }
                    $filers_markup .= sprintf('<a href="#" class="eo-eb-filter eo-eb-filter-category eo-eb-filter-category-%1$d" data-filter-type="category" data-category="%1$d" data-filter-on="false">%2$s</a>', 0, __('Uncategorised', 'event-organiser-posterboard'));
                    break;
                case 'city':
                case 'state':
                case 'country':
                    //If Pro isn't active, this won't work
                    if (!$is_pro_active) {
                        break;
                    }
                    if ('city' == $filter) {
                        $terms = eo_get_venue_cities();
                    } elseif ('state' == $filter) {
                        $terms = eo_get_venue_states();
                    } else {
                        $terms = eo_get_venue_countries();
                    }
                    if ($terms) {
                        foreach ($terms as $term) {
                            $filers_markup .= sprintf('<a href="#" class="eo-eb-filter eo-eb-filter-%1$s eo-eb-filter-%1$s-%2$s" data-filter-type="%1$s" data-%1$s="%2$s" data-filter-on="false">%2$s</a>', $filter, $term);
                        }
                    }
                    break;
            }
        }
    }
    return '<div id="event-board">' . '<div id="event-board-filters" data-filters="">' . $filers_markup . '</div>' . '<div id="event-board-items"></div>' . '<div id="event-board-more"></div>' . '</div>';
}
예제 #5
0
    function display()
    {
        //Get the time 'now' according to blog's timezone
        $now = new DateTime(null, eo_get_blog_timezone());
        $venues = eo_get_venues();
        ?>

	<div class="wrap">  
		<?php 
        screen_icon('edit');
        ?>
		<h2><?php 
        _e('Events Calendar', 'eventorganiser');
        ?>
</h2>

		<?php 
        $current = !empty($_COOKIE['eo_admin_cal_last_view']) ? $_COOKIE['eo_admin_cal_last_view'] : 'month';
        $views = array('agendaDay' => __('Day', 'eventorganiser'), 'agendaWeek' => __('Week', 'eventorganiser'), 'month' => __('Month', 'eventorganiser'));
        ?>
		<div id="calendar-view">
			<span id='loading' style='display:none'><?php 
        _e('Loading&#8230;', 'eventorganiser');
        ?>
</span>
			<?php 
        foreach ($views as $id => $label) {
            printf('<a href="#" class="nav-tab view-button %s" id="%s">%s</a>', $id == $current ? 'nav-tab-active' : '', $id, $label);
        }
        ?>
		</div>

		<div id='eo_admin_calendar'></div>
		<span><?php 
        _e('Current date/time', 'eventorganiser');
        ?>
: <?php 
        echo $now->format('Y-m-d G:i:s \\G\\M\\TP');
        ?>
</span>

		<?php 
        eventorganiser_event_detail_dialog();
        ?>

		<?php 
        if (current_user_can('publish_events') || current_user_can('edit_events')) {
            ?>
			<div id='eo_event_create_cal' style="display:none;" class="eo-dialog" title="<?php 
            esc_attr_e('Create an event', 'eventorganiser');
            ?>
">
			<form name="eventorganiser_calendar" method="post" class="eo_cal">

				<table class="form-table">
				<tr>
					<th><?php 
            _e('When', 'eventorganiser');
            ?>
: </th>
					<td id="date"></td>
				</tr>
				<tr>
					<th><?php 
            _e('Event Title', 'eventorganiser');
            ?>
: </th>
					<td><input name="eo_event[event_title]" class="eo-event-title ui-autocomplete-input ui-widget-content ui-corner-all" ></td>
				</tr>
				
				<?php 
            if (taxonomy_exists('event-venue')) {
                ?>
						<tr>
							<th><?php 
                _e('Where', 'eventorganiser');
                ?>
: </th>
							<td><!-- If javascript is disabed, a simple drop down menu box is displayed to choose venue.
									Otherwise, the user is able to search the venues by typing in the input box.-->		
								<select size="30" id="venue_select" name="eo_event[venue_id]">
									<option>Select a venue </option>
									<?php 
                foreach ($venues as $venue) {
                    ?>
										<option value="<?php 
                    echo intval($venue->term_id);
                    ?>
"><?php 
                    echo esc_html($venue->name);
                    ?>
</option>
									<?php 
                }
                ?>
								</select>
							</td>
						</tr>
					<?php 
            }
            ?>
				<tr>
					<th></th>
					<td><textarea rows="4" name="eo_event[event_content]" style="width: 220px;"></textarea></td>
				</tr>
				</table>
			<p class="submit">
			<input type="hidden" name="eo_event[StartDate]">
			<input type="hidden" name="eo_event[EndDate]">
			<input type="hidden" name="eo_event[StartTime]">
			<input type="hidden" name="eo_event[FinishTime]">
			<input type="hidden" name="eo_event[allday]">
		  	<?php 
            wp_nonce_field('eventorganiser_calendar_save');
            ?>
			<?php 
            if (current_user_can('publish_events')) {
                ?>
				<input type="submit" class="button" tabindex="4" value="<?php 
                _e('Save Draft', 'eventorganiser');
                ?>
" id="event-draft" name="save">
				<input type="reset" class="button" id="reset" value="<?php 
                _e('Cancel', 'eventorganiser');
                ?>
">

				<span id="publishing-action">
					<input type="submit" accesskey="p" tabindex="5" value="<?php 
                _e('Publish Event', 'eventorganiser');
                ?>
" class="button-primary" id="publish" name="publish">
				</span>

			<?php 
            } elseif (current_user_can('edit_events')) {
                ?>
				<input type="reset" class="button" id="reset" value="<?php 
                _e('Cancel', 'eventorganiser');
                ?>
">
				<span id="publishing-action">
					<input type="submit" accesskey="p" tabindex="5" value="<?php 
                _e('Submit for Review', 'eventorganiser');
                ?>
" class="eo_alignright button-primary" id="submit-for-review" name="publish">
				</span>
			<?php 
            }
            ?>
			
			<br class="clear">
			</form>
		</div>
		<?php 
        }
        ?>
	</div><!-- .wrap -->
<?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'));
}
 /**
  * Sync EO venues to CiviEvent locations
  *
  * @since 0.1
  *
  * @return void
  */
 public function sync_venues_to_locations()
 {
     // get all venues
     $all_venues = eo_get_venues();
     // sync EO to Civi
     if (count($all_venues) > 0) {
         // loop
         foreach ($all_venues as $venue) {
             // update Civi location - or create if it doesn't exist
             $location = $this->plugin->civi->update_location($venue);
             // store in EO venue
             $this->plugin->eo_venue->store_civi_location($venue->term_id, $location);
         }
     }
 }
/**
 * 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 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;
}
/**
* Wrapper for get_terms. Maybe depcreciate in favour of eo_get_venues?
*/
function eo_get_the_venues($args = array())
{
    return eo_get_venues($args);
}