Parse venue to actual location fields?

WordPress Event Management, Calendars & Registration Forums iCal Extension Parse venue to actual location fields?

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 9 years, 6 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #12808

    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 9 years, 6 months ago by  Cliff Hirtle.
    Cliff Hirtle
    #12826

    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
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.