Is there a means of having the venue field of a subscribed calendar feed parse its data into the actual location fields (street/city/state)? Currently I’m getting the following venue info from my feed but I’d like to have it actually populate the specific address fields versus just the venue title:
Venue: Panera Bread (2542 Albany Avenue, West Hartford, CT 06117) Categories: business, meetup, networking
-
This topic was modified 10 years, 1 month ago by Cliff Hirtle.
Cliff Hirtle
Hi Cliff,
If you are subscribing only to feeds which have a definitive format for venues. E.g.:
<Venue name> (<number> <street>, <city>, <post code>)
then yes. But otherwise the iCal specification does not state how to format venues or locations beyond text describing the location (e.g. Room A, Maxwell Building) and its latitude/longtitude co-ordinates. As such its not generally possible to extract venue particulars (street, town, etc) as these are not necessarily provided, or when they are, can be provided in any format.
With a set format you could parse the venue value, and create the venue (if it doesn’t already exist).
function my_ical_feed_parse_venue( $ical_parser ){
if( $ical_parser->events_parsed ){
foreach( $ical_parser->events_parsed as $index => $event ):
//Get venue of event
$venue = $this->events_parsed[$index]['event-venue'];
if ( !$venue ){
continue;
}
//TODO: Parse $venue in to $venue_name, $venue_address, etc.
//Check if venue already exists
$found_venue = eo_get_venue_by( 'name', sanitize_term_field( 'name', $venue_name, 0, 'event-venue', 'db' ) );
if( !$found_venue ){
//Set event-venue to venue name
$this->events_parsed[$index]['event-venue'] = $venue_name;
//Create venue if it doesn't exist
$args = array(
'address' => $venue_address,
'postcode' => $venue_postcode,
'city' => $venue_city,
'state' => $venue_state
);
if( isset( $ical->venue_meta[$venue]['latitude'] ) && isset( $ical->venue_meta[$venue]['longtitude'] ) ){
$args['latitude'] = $ical->venue_meta[$venue]['latitude'];
$args['longtitude'] = $ical->venue_meta[$venue]['longtitude'];
}
//Create venue
$new_venue = eo_insert_venue( $venue_name, $args );
}
endforeach;
}
}
add_action( 'eventorganiser_ical_feed_parsed', 'my_ical_feed_parse_venue' );
Stephen Harris