Changeset 4808
- Timestamp:
- 01/27/2017 03:42:21 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/official-wordpress-events.php
r1799 r4808 1 1 <?php 2 2 3 /* 3 4 Plugin Name: Official WordPress Events … … 50 51 public function render_events() { 51 52 $events = $this->group_events_by_date( $this->get_all_events() ); 52 53 53 54 if ( $events ) { 54 55 require_once( __DIR__ . '/template-events.php' ); … … 58 59 /** 59 60 * Get all official events 60 * 61 * 61 62 * @return array 62 63 */ … … 66 67 67 68 // todo Cache results here too, to avoid processing the raw data on each request? If so, then no longer need to cache API call results? 68 69 69 70 return $events; 70 71 } 71 72 72 73 /** 73 * Sort events based on start timestamp 74 * 74 * Sort events based on start timestamp 75 * 75 76 * This is a callback for usort() 76 * 77 * 77 78 * @param $a 78 79 * @param $b 80 * 79 81 * @return int 80 82 */ … … 163 165 } 164 166 } 165 167 166 168 return $events; 167 169 } … … 178 180 return $events; 179 181 } 180 182 181 183 $response = $this->remote_get( sprintf( 182 184 '%s2/events?group_id=%s&time=0,1m&page=%d&key=%s', … … 201 203 $location = $this->format_reverse_geocode_address( $location->address_components ); 202 204 } 203 205 204 206 $events[] = new Official_WordPress_Event( array( 205 207 'type' => 'meetup', … … 207 209 'url' => $meetup->event_url, 208 210 'start_timestamp' => $start_timestamp, 209 'end_timestamp' => ( empty ( $meetup->duration ) ? $start_timestamp : $start_timestamp + ( $meetup->duration / 1000 ) ), 211 'end_timestamp' => ( empty ( $meetup->duration ) ? $start_timestamp : $start_timestamp + ( $meetup->duration / 1000 ) ), // convert to seconds 210 212 'location' => $location, 211 213 ) ); … … 215 217 return $events; 216 218 } 217 219 218 220 /* 219 221 * Gets the IDs of all of the meetup groups associated … … 225 227 return array(); 226 228 } 227 229 228 230 $response = $this->remote_get( sprintf( 229 231 '%s2/profiles?&member_id=%d&key=%s', … … 234 236 235 237 $group_ids = json_decode( wp_remote_retrieve_body( $response ) ); 236 238 237 239 if ( ! empty ( $group_ids->results ) ) { 238 240 $group_ids = wp_list_pluck( $group_ids->results, 'group' ); 239 241 $group_ids = wp_list_pluck( $group_ids, 'id' ); 240 242 } 241 243 242 244 if ( ! isset( $group_ids ) || ! is_array( $group_ids ) ) { 243 245 $group_ids = array(); 244 246 } 245 247 246 248 return $group_ids; 247 249 } … … 351 353 } elseif ( 200 != $response['response']['code'] ) { 352 354 // trigger_error() has a message limit of 1024 bytes, so we truncate $response['body'] to make sure that $body doesn't get truncated. 353 355 354 356 $error = sprintf( 355 357 'Received HTTP code: %s and body: %s. Request was to: %s; Arguments were: %s', … … 359 361 print_r( $args, true ) 360 362 ); 361 362 $response = new WP_Error( 'woe_invalid_http_response', 'Invalid HTTP response code', $response ); 363 } 364 363 364 $response = new WP_Error( 'woe_invalid_http_response', 'Invalid HTTP response code', $response ); 365 } 366 365 367 if ( $error ) { 366 368 $error = preg_replace( '/&key=[a-z0-9]+/i', '&key=[redacted]', $error ); 367 369 trigger_error( sprintf( '%s error for %s: %s', __METHOD__, parse_url( site_url(), PHP_URL_HOST ), sanitize_text_field( $error ) ), E_USER_WARNING ); 368 370 369 371 if ( $to = apply_filters( 'owe_error_email_addresses', array() ) ) { 370 372 wp_mail( $to, sprintf( '%s error for %s', __METHOD__, parse_url( site_url(), PHP_URL_HOST ) ), sanitize_text_field( $error ) );
Note: See TracChangeset
for help on using the changeset viewer.