- Timestamp:
- 11/06/2017 09:03:28 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/events/1.0/index.php
r5559 r6078 148 148 149 149 $events = get_events( $event_args ); 150 $events = add_regional_wordcamps( $events, $_SERVER['HTTP_USER_AGENT'] ); 150 151 151 152 /* … … 785 786 786 787 /** 788 * Add regional WordCamps to the Events Widget in Core for extra promotion. 789 * 790 * @param array $local_events 791 * @param string $user_agent 792 * 793 * @return array 794 */ 795 function add_regional_wordcamps( $local_events, $user_agent ) { 796 $time = time(); 797 $regional_wordcamps = array(); 798 799 /* 800 * Limit effects to the Events Widget in Core. 801 * Otherwise this would return unexpected results to other clients. 802 * 803 * This is the closest we can get to detecting Core, so it'll still distort results for any 804 * plugins that are fetching events with `wp_remote_get()`. 805 */ 806 if ( false === strpos( $user_agent, 'WordPress/' ) ) { 807 return $local_events; 808 } 809 810 if ( $time <= strtotime( 'December 2nd, 2017' ) ) { 811 $regional_wordcamps[] = array( 812 'type' => 'wordcamp', 813 'title' => 'WordCamp US', 814 'url' => 'https://2017.us.wordcamp.org/', 815 'meetup' => '', 816 'meetup_url' => '', 817 'date' => '2017-12-01 00:00:00', 818 819 'location' => array( 820 'location' => 'Nashville, TN, USA', 821 'country' => 'US', 822 'latitude' => 36.1566085, 823 'longitude' => -86.7784909, 824 ) 825 ); 826 } 827 828 if ( $time >= strtotime( 'May 14th, 2018' ) && $time <= strtotime( 'June 15th, 2018' ) ) { 829 $regional_wordcamps[] = array( 830 'type' => 'wordcamp', 831 'title' => 'WordCamp Europe', 832 'url' => 'https://2018.europe.wordcamp.org/', 833 'meetup' => '', 834 'meetup_url' => '', 835 'date' => '2018-06-14 00:00:00', 836 837 'location' => array( 838 'location' => 'Belgrade, Serbia', 839 'country' => 'RS', 840 'latitude' => 44.808497, 841 'longitude' => 20.432285, 842 ) 843 ); 844 } 845 846 /** 847 * Remove duplicates events. 848 * Favor the regional event since it'll be pinned to the top. 849 */ 850 foreach ( $regional_wordcamps as $regional_event ) { 851 foreach ( $local_events as $local_key => $local_event ) { 852 if ( parse_url( $regional_event['url'], PHP_URL_HOST ) === parse_url( $local_event['url'], PHP_URL_HOST ) ) { 853 unset( $local_events[ $local_key ] ); 854 } 855 } 856 } 857 858 return array_merge( $regional_wordcamps, $local_events ); 859 } 860 861 /** 787 862 * Create a bounded latitude/longitude box of x KM around specific coordinates. 788 863 *
Note: See TracChangeset
for help on using the changeset viewer.