Changeset 4840
- Timestamp:
- 01/30/2017 04:36:01 PM (9 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
r4839 r4840 18 18 * @todo 19 19 * 20 * Add pausing to avoid rate limit21 20 * Meetups only pulling 1 week instead of full month 22 21 * Maybe pull more than 1 month of meetups 23 22 * Make meetups and wordcamps cut off on the same date, so it doesn't look like there aren't any meetups later in the year 23 * Always display cached results, and refresh stale cache asynchronously, to avoid visitors having to wait while the data is pulled 24 * After async cache refresh, bump remote_get timeout limit to 30 to avoid premature timeouts 24 25 * Ability to feature a camp in a hero area 25 26 * Add a "load more" button that retrieves more events via AJAX and updates the DOM. Have each click load the next month of events? … … 508 509 set_transient( $transient_key, $response, HOUR_IN_SECONDS ); 509 510 } 511 512 $this->maybe_pause( wp_remote_retrieve_headers( $response ) ); 510 513 } 511 514 } 512 515 513 516 return $response; 517 } 518 519 /** 520 * Maybe pause the script to avoid rate limiting 521 * 522 * @param array $headers 523 */ 524 protected function maybe_pause( $headers ) { 525 if ( ! isset( $headers['x-ratelimit-remaining'], $headers['x-ratelimit-reset'] ) ) { 526 return; 527 } 528 529 $remaining = absint( $headers['x-ratelimit-remaining'] ); 530 $period = absint( $headers['x-ratelimit-reset'] ); 531 532 // Pause more frequently than we need to, and for longer, just to be safe 533 if ( $remaining > 2 ) { 534 return; 535 } 536 537 if ( $period < 2 ) { 538 $period = 2; 539 } 540 541 sleep( $period ); 514 542 } 515 543 }
Note: See TracChangeset
for help on using the changeset viewer.