- Timestamp:
- 01/04/2021 11:41:06 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/events/1.0/index.php
r10548 r10549 235 235 ); 236 236 237 $events = pin_next_online_wordcamp( $events, $_SERVER['HTTP_USER_AGENT'], time() );237 $events = pin_next_online_wordcamp( $events, $_SERVER['HTTP_USER_AGENT'], time(), $location['country'] ?? '' ); 238 238 $events = pin_next_workshop_discussion_group( $events, $_SERVER['HTTP_USER_AGENT'] ); 239 239 $events = pin_one_off_events( $events, time() ); … … 1355 1355 * @param string $user_agent 1356 1356 * @param int $current_time 1357 * @param string $user_country 1357 1358 * 1358 1359 * @return array 1359 1360 */ 1360 function pin_next_online_wordcamp( $events, $user_agent, $current_time ) {1361 function pin_next_online_wordcamp( $events, $user_agent, $current_time, $user_country ) { 1361 1362 global $wpdb, $cache_group, $cache_life; 1362 1363 … … 1382 1383 status = 'scheduled' AND 1383 1384 location = 'online' AND 1384 date_utc BETWEEN CURDATE() AND CURDATE() + INTERVAL 2 WEEK1385 date_utc BETWEEN CURDATE() AND CURDATE() + INTERVAL 1 MONTH 1385 1386 ORDER BY `date_utc` ASC 1386 1387 LIMIT 1" … … 1429 1430 1430 1431 if ( isset( $next_online_camp['url'] ) ) { 1431 array_unshift( $events, $next_online_camp ); 1432 $camp_is_in_users_country = $user_country === $next_online_camp['location']['country']; 1433 1434 $camp_is_in_next_two_weeks = is_within_date_range( 1435 $current_time, 1436 $next_online_camp['start_unix_timestamp'] - ( 2 * WEEK_IN_SECONDS ), 1437 $next_online_camp['start_unix_timestamp'] 1438 ); 1439 1440 /* 1441 * Online WordCamps often represent the entire country, in contrast to offline camps, which are local 1442 * events. Because of that, they should be promoted to the entire country, even if that's outside the 1443 * normal `$event_distances['wordcamp']` range. 1444 * 1445 * If it's not the user's country, then 2 weeks is a good balance between promoting a 1446 * potentially-interesting event, and crowding out local events. 1447 */ 1448 if ( $camp_is_in_users_country || $camp_is_in_next_two_weeks ) { 1449 array_unshift( $events, $next_online_camp ); 1450 } 1432 1451 } 1433 1452
Note: See TracChangeset
for help on using the changeset viewer.