- Timestamp:
- 05/09/2018 06:06:54 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/events/1.0/index.php
r7145 r7188 165 165 166 166 $events = get_events( $event_args ); 167 $events = maybe_add_wp15_promo( $events, $_SERVER['HTTP_USER_AGENT'], time() ); 167 168 $events = add_regional_wordcamps( $events, $_SERVER['HTTP_USER_AGENT'] ); 168 169 … … 982 983 983 984 /** 985 * Add a special WP15 meetup event to the Events Widget in Core if the user location doesn't already have a 986 * WP15 event in the list. 987 * 988 * @param array $local_events The list of events for a particular location. 989 * @param string $user_agent The User Agent string of the client requesting the events. 990 * @param int $time Unix timestamp. 991 * 992 * @return array 993 */ 994 function maybe_add_wp15_promo( $local_events, $user_agent, $time ) { 995 if ( ! is_client_core( $user_agent ) ) { 996 return $local_events; 997 } 998 999 if ( $time < strtotime( 'April 27th, 2018' ) || $time > strtotime( 'May 28th, 2018' ) ) { 1000 return $local_events; 1001 } 1002 1003 $wp15_events = array_filter( $local_events, function( $event ) { 1004 return is_wp15_event( $event['title'] ); 1005 } ); 1006 1007 if ( empty( $wp15_events ) ) { 1008 $promo = array( 1009 'type' => 'meetup', 1010 'title' => 'WP15', 1011 'url' => 'https://wordpress.org/news/2018/04/celebrate-the-wordpress-15th-anniversary-on-may-27/', 1012 'meetup' => null, 1013 'meetup_url' => null, 1014 'date' => '2018-05-27 12:00:00', 1015 'location' => array( 1016 'location' => 'Everywhere', 1017 ), 1018 ); 1019 1020 array_unshift( $local_events, $promo ); 1021 } 1022 1023 return $local_events; 1024 } 1025 1026 /** 1027 * Determine if a meetup event is a WP15 celebration, based on the event title. 1028 * 1029 * Note that unlike the version of this function in the `wp15-meetup-events` plugin, the event data we're parsing here 1030 * doesn't include a meetup event ID or a description, so we must rely on the title. In testing, this resulted in about 1031 * 10% fewer events identified. 1032 * 1033 * @see https://meta.trac.wordpress.org/browser/sites/trunk/wp15.wordpress.net/public_html/content/plugins/wp15-meetup-events/wp15-meetup-events.php#L141 1034 * 1035 * @param string $title 1036 * 1037 * @return bool 1038 */ 1039 function is_wp15_event( $title ) { 1040 $match = false; 1041 $keywords = array( 1042 'wp15', '15 year', '15 ano', '15 año', '15 candeline', 'wordt 15', 1043 'anniversary', 'aniversário', 'aniversario', 'birthday', 'cumpleaños', 1044 'Tanti auguri' 1045 ); 1046 1047 foreach ( $keywords as $keyword ) { 1048 if ( false !== stripos( $title, $keyword ) ) { 1049 $match = true; 1050 break; 1051 } 1052 } 1053 1054 return $match; 1055 } 1056 1057 /** 984 1058 * Create a bounded latitude/longitude box of x KM around specific coordinates. 985 1059 *
Note: See TracChangeset
for help on using the changeset viewer.