Making WordPress.org

Changeset 1096


Ignore:
Timestamp:
01/07/2015 07:32:23 PM (12 years ago)
Author:
iandunn
Message:

Official WordPress Events: Modularize the formatting of meetup venue locations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/official-wordpress-events.php

    r1095 r1096  
    164164                if ( $meetups ) {
    165165                        foreach ( $meetups as $meetup ) {
    166                                 $location        = array();
    167166                                $start_timestamp = ( $meetup->time / 1000 ) + ( $meetup->utc_offset / 1000 );    // convert to seconds
    168167
    169168                                if ( isset( $meetup->venue ) ) {
    170                                         foreach ( array( 'city', 'state', 'country' ) as $part ) {
    171                                                 if ( ! empty( $meetup->venue->$part ) ) {
    172                                                         if ( in_array( $part, array( 'state', 'country' ) ) ) {
    173                                                                 $location[] = strtoupper( $meetup->venue->$part );
    174                                                         } else {
    175                                                                 $location[] = $meetup->venue->$part;
    176                                                         }
    177                                                 }
    178                                         }
    179                                         $location = implode( ', ', $location );
     169                                        $location = $this->format_meetup_venue_location( $meetup->venue );
    180170                                } else {
    181171                                        $location = $this->reverse_geocode( $meetup->group->group_lat, $meetup->group->group_lon );
     
    275265
    276266        /**
     267         * Format a meetup venue's location
     268         *
     269         * @param object $venue
     270         *
     271         * @return string
     272         */
     273        protected function format_meetup_venue_location( $venue ) {
     274                $location = array();
     275
     276                foreach ( array( 'city', 'state', 'country' ) as $part ) {
     277                        if ( ! empty( $venue->$part ) ) {
     278                                if ( in_array( $part, array( 'state', 'country' ) ) ) {
     279                                        $location[] = strtoupper( $venue->$part );
     280                                } else {
     281                                        $location[] = $venue->$part;
     282                                }
     283                        }
     284                }
     285
     286                return implode( ', ', $location );
     287        }
     288
     289        /**
    277290         * Wrapper for wp_remote_get()
    278291         *
Note: See TracChangeset for help on using the changeset viewer.