Changeset 11850
- Timestamp:
- 05/17/2022 11:25:58 PM (3 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/meetup
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/meetup/class-api-client.php
r9765 r11850 36 36 * @var array A list of integer response codes that should break the "tenacious" remote request loop. 37 37 */ 38 protected $breaking_response_codes = [];38 protected $breaking_response_codes = array(); 39 39 40 40 /** … … 60 60 * } 61 61 */ 62 public function __construct( array $settings = []) {62 public function __construct( array $settings = array() ) { 63 63 $this->error = new WP_Error(); 64 64 65 $defaults = [65 $defaults = array( 66 66 'throttle_callback' => '', 67 'breaking_response_codes' => [ 400, 401, 404, 429 ],68 ];67 'breaking_response_codes' => array( 400, 401, 404, 429 ), 68 ); 69 69 70 70 $settings = wp_parse_args( $settings, $defaults ); … … 86 86 * @return array|WP_Error 87 87 */ 88 protected function tenacious_remote_request( $url, array $args = []) {88 protected function tenacious_remote_request( $url, array $args = array() ) { 89 89 $attempt_count = 0; 90 90 $max_attempts = 3; … … 172 172 * @return array|WP_Error 173 173 */ 174 public function tenacious_remote_get( $url, array $args = []) {174 public function tenacious_remote_get( $url, array $args = array() ) { 175 175 $args['method'] = 'GET'; 176 176 … … 186 186 * @return array|WP_Error 187 187 */ 188 public function tenacious_remote_post( $url, array $args = []) {188 public function tenacious_remote_post( $url, array $args = array() ) { 189 189 $args['method'] = 'POST'; 190 190 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/meetup/class-meetup-client.php
r11399 r11850 35 35 * @var string The GraphQL field that must be present for pagination to work. 36 36 */ 37 public $pag eInfo= 'pageInfo { hasNextPage endCursor }';37 public $pagination = 'pageInfo { hasNextPage endCursor }'; 38 38 39 39 /** … … 56 56 * } 57 57 */ 58 public function __construct( array $settings = []) {58 public function __construct( array $settings = array() ) { 59 59 parent::__construct( array( 60 60 /* … … 74 74 401, // Unauthorized (invalid key). 75 75 429, // Too many requests (rate-limited). 76 404, // Unable to find group 77 76 404, // Unable to find group. 78 77 503, // Timeout between API cache & GraphQL Server. 79 78 ), … … 92 91 93 92 if ( $this->debug ) { 94 self::cli_message( "Meetup Client debug is on. Results will be truncated.");95 } 96 97 $this->oauth_client = new Meetup_OAuth2_Client ;93 self::cli_message( 'Meetup Client debug is on. Results will be truncated.' ); 94 } 95 96 $this->oauth_client = new Meetup_OAuth2_Client(); 98 97 99 98 if ( ! empty( $this->oauth_client->error->get_error_messages() ) ) { … … 139 138 * 140 139 * This automatically paginates requests and will repeat requests to ensure all results are retrieved. 141 * For pagination to work, $this->pag eInfomust be present within the string, and a 'cursor' variable defined.142 * 143 * @param string $ request_urlThe API endpoint URL to send the request to.144 * @param array $variables 140 * For pagination to work, $this->pagination must be present within the string, and a 'cursor' variable defined. 141 * 142 * @param string $query The API endpoint URL to send the request to. 143 * @param array $variables The Query variables used in the query. 145 144 * 146 145 * @return array|WP_Error The results of the request. … … 152 151 $is_paginated_request = ! empty( $variables ) && 153 152 array_key_exists( 'cursor', $variables ) && 154 false !== stripos( $query, $this->pag eInfo);153 false !== stripos( $query, $this->pagination ); 155 154 156 155 do { … … 195 194 array_walk_recursive( 196 195 $new_data, 197 function ( $value, $key ) use( &$has_next_page, &$end_cursor ) {196 function ( $value, $key ) use ( &$has_next_page, &$end_cursor ) { 198 197 // NOTE: This will be truthful and present on the final page causing paged 199 198 // requests to always make an additional request to a final empty page. 200 if ( $key === 'hasNextPage') {199 if ( 'hasNextPage' === $key ) { 201 200 $has_next_page = $value; 202 201 } elseif ( 'endCursor' === $key ) { … … 225 224 } while ( $has_next_page ); 226 225 227 if ( ! empty( $this->error->get_error_messages() ) ) { 226 $errors = implode( '. ', $this->error->get_error_messages() ); 227 if ( ! empty( $errors ) ) { 228 trigger_error( "Request error(s): $errors", E_USER_WARNING ); 229 228 230 return $this->error; 229 231 } … … 241 243 242 244 foreach ( $array2 as $key => &$value ) { 243 // Merge numeric arrays 245 // Merge numeric arrays. 244 246 if ( is_array( $value ) && wp_is_numeric_array( $value ) && isset( $merged[ $key ] ) ) { 245 247 $merged[ $key ] = array_merge( $merged[ $key ], $value ); … … 277 279 'Authorization' => "Bearer $oauth_token", 278 280 ), 279 'body' => wp_json_encode( compact( 'query', 'variables' ) ) 281 'body' => wp_json_encode( compact( 'query', 'variables' ) ), 280 282 ); 281 283 } … … 284 286 * Check the rate limit status in an API response and delay further execution if necessary. 285 287 * 286 * @param array $ headers288 * @param array $response 287 289 * 288 290 * @return void … … 352 354 } 353 355 354 $datetime_formats = [355 'Y-m-d\TH:iP', // 2021-11-20T17:00+05:30356 'Y-m-d\TH:i:sP', // 2021-11-20T17:00:00+05:30356 $datetime_formats = array( 357 'Y-m-d\TH:iP', // '2021-11-20T17:00+05:30'. 358 'Y-m-d\TH:i:sP', // '2021-11-20T17:00:00+05:30'. 357 359 // DateTime::createFromFormat() doesn't handle the final `]` character in the following timezone format. 358 'Y-m-d\TH:i\[e', // 2021-11-20T06:30[US/Eastern]360 'Y-m-d\TH:i\[e', // '2021-11-20T06:30[US/Eastern]'. 359 361 'c', // ISO8601, just incase the above don't cover it. 360 'Y-m-d\TH:i:s', // timezoneless 2021-11-20T17:00:00361 'Y-m-d\TH:i', // timezoneless 2021-11-20T17:00362 ];362 'Y-m-d\TH:i:s', // timezoneless '2021-11-20T17:00:00'. 363 'Y-m-d\TH:i', // timezoneless '2021-11-20T17:00'. 364 ); 363 365 364 366 // See above, just keep one timezone if the timezone format is `P\[e\]`. Simpler matching, assume the timezones are the same. … … 468 470 */ 469 471 public function get_groups( array $args = array() ) { 470 $fields = $this->get_default_fields( 'group' ); 471 472 if ( !empty( $args['fields'] ) && is_array( $args['fields'] ) ) { 472 $filters = array(); 473 $fields = $this->get_default_fields( 'group' ); 474 475 if ( ! empty( $args['fields'] ) && is_array( $args['fields'] ) ) { 473 476 $fields = array_merge( $fields, $args['fields'] ); 474 477 } 475 478 476 $filters = [];477 479 /* 478 480 * See https://www.meetup.com/api/schema/#GroupAnalyticsFilter for valid filters. … … 491 493 } 492 494 493 $variables = [495 $variables = array( 494 496 'urlname' => 'wordpress', 495 497 'perPage' => 200, 496 498 'cursor' => null, 497 ];499 ); 498 500 499 501 $query = ' … … 502 504 groupsSearch( input: { first: $perPage, after: $cursor }, filter: { ' . implode( ', ', $filters ) . '} ) { 503 505 count 504 ' . $this->pag eInfo. '506 ' . $this->pagination . ' 505 507 edges { 506 508 node { … … 518 520 } 519 521 520 $ results = array_column(522 $groups = array_column( 521 523 $result['proNetworkByUrlname']['groupsSearch']['edges'], 522 524 'node' 523 525 ); 524 526 525 $ results = $this->apply_backcompat_fields( 'groups', $results );526 527 return $ results;527 $groups = $this->apply_backcompat_fields( 'groups', $groups ); 528 529 return $groups; 528 530 } 529 531 … … 578 580 * @return array 579 581 */ 580 function get_event_details( $event_id ) { 581 582 public function get_event_details( $event_id ) { 582 583 $fields = $this->get_default_fields( 'event' ); 583 584 584 585 // Accepts, slug / id / slugId as the query-by fields. 585 $query = '586 $query = ' 586 587 query ( $eventId: ID ) { 587 588 event( id: $eventId ) { … … 589 590 } 590 591 }'; 591 $variables = [592 $variables = array( 592 593 'eventId' => $event_id, 593 ];594 ); 594 595 595 596 $result = $this->send_paginated_request( $query, $variables ); … … 617 618 /* $events = [ id => $meetupID, id2 => $meetupID2 ] */ 618 619 619 $return = [];620 $return = array(); 620 621 $chunks = array_chunk( $event_ids, 250, true ); 621 622 622 623 foreach ( $chunks as $chunked_events ) { 623 $keys = [];624 $query 624 $keys = array(); 625 $query = ''; 625 626 626 627 foreach ( $chunked_events as $id => $event_id ) { 627 $key = 'e' . md5( $id );628 $key = 'e' . md5( $id ); 628 629 $keys[ $key ] = $id; 629 630 … … 659 660 */ 660 661 public function get_group_details( $group_slug, $args = array() ) { 661 $fields = $this->get_default_fields( 'group' ); ;662 663 $events_fields = [662 $fields = $this->get_default_fields( 'group' ); 663 664 $events_fields = array( 664 665 'dateTime', 665 666 'going', 666 ];667 668 if ( ! empty( $args['fields'] ) && is_array( $args['fields'] ) ) {667 ); 668 669 if ( ! empty( $args['fields'] ) && is_array( $args['fields'] ) ) { 669 670 $fields = array_merge( $fields, $args['fields'] ); 670 671 } 671 if ( ! empty( $args['events_fields'] ) && is_array( $args['events_fields'] ) ) {672 if ( ! empty( $args['events_fields'] ) && is_array( $args['events_fields'] ) ) { 672 673 $events_fields = array_merge( $events_fields, $args['events_fields'] ); 673 } elseif ( ! empty( $args['events_fields'] ) && true === $args['events_fields'] ) {674 } elseif ( ! empty( $args['events_fields'] ) && true === $args['events_fields'] ) { 674 675 $events_fields = array_merge( $events_fields, $this->get_default_fields( 'events' ) ); 675 676 } … … 678 679 // Instead, we fetch the details for every past event instead. 679 680 680 $query = '681 $query = ' 681 682 query ( $urlname: String!, $perPage: Int!, $cursor: String ) { 682 683 groupByUrlname( urlname: $urlname ) { 683 684 ' . implode( ' ', $fields ) . ' 684 685 pastEvents ( input: { first: $perPage, after: $cursor } ) { 685 ' . $this->pag eInfo. '686 ' . $this->pagination . ' 686 687 edges { 687 688 node { … … 692 693 } 693 694 }'; 694 $variables = [695 $variables = array( 695 696 'urlname' => $group_slug, 696 697 'perPage' => 200, 697 698 'cursor' => null, 698 ];699 ); 699 700 700 701 $result = $this->send_paginated_request( $query, $variables ); … … 704 705 } 705 706 706 // Format it similar to previous response payload?? 707 $result = $result['groupByUrlname']; 708 709 $result = $this->apply_backcompat_fields( 'group', $result ); 710 711 return $result; 707 // Format it similar to previous response payload. 708 $group = $this->apply_backcompat_fields( 'group', $result['groupByUrlname'] ); 709 710 return $group; 712 711 } 713 712 … … 730 729 } 731 730 732 // Filters 733 $filters = [];731 // Filters. 732 $filters = array(); 734 733 if ( isset( $args['role'] ) && 'leads' === $args['role'] ) { 735 734 // See https://www.meetup.com/api/schema/#MembershipStatus for valid statuses. … … 744 743 745 744 // 'memberships' => 'GroupUserConnection' not documented. 746 $query = '745 $query = ' 747 746 query ( $urlname: String!, $perPage: Int!, $cursor: String ) { 748 747 groupByUrlname( urlname: $urlname ) { 749 748 memberships ( input: { first: $perPage, after: $cursor }, filter: { ' . implode( ', ', $filters ) . ' } ) { 750 ' . $this->pag eInfo. '749 ' . $this->pagination . ' 751 750 edges { 752 751 node { … … 757 756 } 758 757 }'; 759 $variables = [758 $variables = array( 760 759 'urlname' => $group_slug, 761 760 'perPage' => 200, 762 761 'cursor' => null, 763 ];762 ); 764 763 765 764 $results = $this->send_paginated_request( $query, $variables ); … … 768 767 } 769 768 770 // Select memberships.edges[*].node 769 // Select memberships.edges[*].node. 771 770 $results = array_column( 772 771 $results['groupByUrlname']['memberships']['edges'], … … 781 780 */ 782 781 public function get_network_events( array $args = array() ) { 783 $defaults = [784 'filters' => [],782 $defaults = array( 783 'filters' => array(), 785 784 'max_event_date' => time() + YEAR_IN_SECONDS, 786 785 'min_event_date' => false, 787 'online_events' => null, // true: only online events, false: only IRL events 788 'status' => 'upcoming', // UPCOMING, PAST, CANCELLED786 'online_events' => null, // true: only online events, false: only IRL events. 787 'status' => 'upcoming', // UPCOMING, PAST, CANCELLED. 789 788 'sort' => '', 790 ];791 $args = wp_parse_args( $args, $defaults );789 ); 790 $args = wp_parse_args( $args, $defaults ); 792 791 793 792 $fields = $this->get_default_fields( 'event' ); 794 793 795 // See https://www.meetup.com/api/schema/#ProNetworkEventsFilter 796 $filters = [];794 // See https://www.meetup.com/api/schema/#ProNetworkEventsFilter. 795 $filters = array(); 797 796 798 797 if ( $args['min_event_date'] ) { … … 807 806 } 808 807 809 // See https://www.meetup.com/api/schema/#ProNetworkEventStatus 810 if ( $args['status'] && in_array( $args['status'], [ 'cancelled', 'upcoming', 'past' ]) ) {808 // See https://www.meetup.com/api/schema/#ProNetworkEventStatus. 809 if ( $args['status'] && in_array( $args['status'], array( 'cancelled', 'upcoming', 'past' ) ) ) { 811 810 $filters['status'] = 'status: ' . strtoupper( $args['status'] ); 812 811 } 813 812 814 813 if ( $args['filters'] ) { 815 foreach ( $args['filters'] as $key => $filter ) {814 foreach ( $args['filters'] as $key => $filter ) { 816 815 $filters[ $key ] = "{$key}: {$filter}"; 817 816 } 818 817 } 819 818 820 $query = '819 $query = ' 821 820 query ( $urlname: String!, $perPage: Int!, $cursor: String ) { 822 821 proNetworkByUrlname( urlname: $urlname ) { 823 822 eventsSearch ( input: { first: $perPage, after: $cursor }, filter: { ' . implode( ', ', $filters ) . ' } ) { 824 ' . $this->pag eInfo. '823 ' . $this->pagination . ' 825 824 edges { 826 825 node { … … 831 830 } 832 831 }'; 833 $variables = [832 $variables = array( 834 833 'urlname' => 'wordpress', 835 'perPage' => 1000, // More per-page to avoid hitting request limits 834 'perPage' => 1000, // More per-page to avoid hitting request limits. 836 835 'cursor' => null, 837 ]; 838 836 ); 839 837 840 838 $results = $this->send_paginated_request( $query, $variables ); … … 845 843 846 844 if ( empty( $results['proNetworkByUrlname']['eventsSearch'] ) ) { 847 return [];848 } 849 850 // Select edges[*].node 851 $ results = array_column(845 return array(); 846 } 847 848 // Select edges[*].node. 849 $events = array_column( 852 850 $results['proNetworkByUrlname']['eventsSearch']['edges'], 853 851 'node' 854 852 ); 855 853 856 $ results = $this->apply_backcompat_fields( 'events', $results );857 858 return $ results;854 $events = $this->apply_backcompat_fields( 'events', $events ); 855 856 return $events; 859 857 860 858 } … … 869 867 */ 870 868 public function get_group_events( $group_slug, array $args = array() ) { 871 $defaults = [869 $defaults = array( 872 870 'status' => 'upcoming', 873 871 'no_earlier_than' => '', 874 872 'no_later_than' => '', 875 'fields' => [],876 ];877 $args = wp_parse_args( $args, $defaults );873 'fields' => array(), 874 ); 875 $args = wp_parse_args( $args, $defaults ); 878 876 879 877 /* … … 892 890 */ 893 891 if ( false !== strpos( $args['status'], ',' ) ) { 894 $events = [];892 $events = array(); 895 893 foreach ( explode( ',', $args['status'] ) as $status ) { 896 894 $args['status'] = $status; … … 906 904 907 905 // Resort all items. 908 usort( $events, function( $a, $b ) { 909 if ( $a['time'] == $b['time'] ) { 910 return 0; 911 } 912 913 return ( $a['time'] < $b['time'] ) ? -1 : 1; 914 } ); 906 usort( 907 $events, 908 function( $a, $b ) { 909 if ( $a['time'] == $b['time'] ) { 910 return 0; 911 } 912 913 return ( $a['time'] < $b['time'] ) ? -1 : 1; 914 } 915 ); 915 916 916 917 return $events; … … 918 919 919 920 $fields = $this->get_default_fields( 'event' ); 920 921 // TODO: Check the above list against Official_WordPress_Events::parse_meetup_events()922 921 923 922 if ( ! empty( $args['fields'] ) && is_array( $args['fields'] ) ) { … … 937 936 default: 938 937 // We got nothing. 939 return [];938 return array(); 940 939 } 941 940 942 941 // No filters defined, as we have to do it ourselves. See above. 943 942 944 $query = '943 $query = ' 945 944 query ( $urlname: String!, $perPage: Int!, $cursor: String ) { 946 945 groupByUrlname( urlname: $urlname ) { 947 946 ' . $event_field . ' ( input: { first: $perPage, after: $cursor } ) { 948 ' . $this->pag eInfo. '947 ' . $this->pagination . ' 949 948 edges { 950 949 node { … … 955 954 } 956 955 }'; 957 $variables = [956 $variables = array( 958 957 'urlname' => $group_slug, 959 958 'perPage' => 200, 960 959 'cursor' => null, 961 ];960 ); 962 961 963 962 $results = $this->send_paginated_request( $query, $variables ); … … 966 965 } 967 966 968 // Select {$event_field}.edges[*].node 969 $ results = array_column(967 // Select {$event_field}.edges[*].node. 968 $events = array_column( 970 969 $results['groupByUrlname'][ $event_field ]['edges'], 971 970 'node' 972 971 ); 973 972 974 $ results = $this->apply_backcompat_fields( 'events', $results );973 $events = $this->apply_backcompat_fields( 'events', $events ); 975 974 976 975 // Apply filters. … … 979 978 $args['no_later_than'] = $this->datetime_to_time( $args['no_later_than'] ) ?: PHP_INT_MAX; 980 979 981 $ results = array_filter(982 $ results,983 function ( $event ) use( $args ) {984 return 980 $events = array_filter( 981 $events, 982 function ( $event ) use ( $args ) { 983 return ( 985 984 $event['time'] >= $args['no_earlier_than'] && 986 $event['time'] < $args['no_later_than']; 985 $event['time'] < $args['no_later_than'] 986 ); 987 987 } 988 988 ); 989 989 } 990 990 991 return $ results;991 return $events; 992 992 } 993 993 … … 1002 1002 public function get_result_count( $route, array $args = array() ) { 1003 1003 $result = false; 1004 $filters = [];1004 $filters = array(); 1005 1005 1006 1006 // Number of groups in the Pro Network. … … 1009 1009 } 1010 1010 1011 // https://www.meetup.com/api/schema/#GroupAnalyticsFilter 1011 // https://www.meetup.com/api/schema/#GroupAnalyticsFilter. 1012 1012 if ( ! empty( $args['pro_join_date_max'] ) ) { 1013 1013 $filters['proJoinDateMax'] = 'proJoinDateMax: ' . $this->datetime_to_time( $args['pro_join_date_max'] ) * 1000; … … 1025 1025 $query = ' 1026 1026 query { 1027 proNetworkByUrlname( urlname: " wordpress" ) {1027 proNetworkByUrlname( urlname: "WordPress" ) { 1028 1028 groupsSearch( filter: { ' . implode( ', ', $filters ) . ' } ) { 1029 1029 count … … 1049 1049 if ( 'event' === $type ) { 1050 1050 // See https://www.meetup.com/api/schema/#Event for valid fields. 1051 return [1051 return array( 1052 1052 'id', 1053 1053 'title', … … 1067 1067 }', 1068 1068 'venue { 1069 id 1070 lat 1071 lng 1072 name 1073 city 1074 state 1075 country 1076 }' 1077 ]; 1069 ' . implode( ' ', $this->get_default_fields( 'venue' ) ) . ' 1070 }', 1071 ); 1078 1072 } elseif ( 'memberships' === $type ) { 1079 1073 // See https://www.meetup.com/api/schema/#User for valid fields. 1080 return [1074 return array( 1081 1075 'id', 1082 1076 'name', 1083 1077 'email', 1084 ];1078 ); 1085 1079 } elseif ( 'group' === $type ) { 1086 return [1080 return array( 1087 1081 'id', 1088 1082 'name', … … 1101 1095 'latitude', 1102 1096 'longitude', 1103 ]; 1097 ); 1098 } elseif ( 'venue' === $type ) { 1099 return array( 1100 'id', 1101 'lat', 1102 'lng', 1103 'name', 1104 'city', 1105 'state', 1106 'country', 1107 ); 1104 1108 } 1105 1109 } … … 1112 1116 * @param string $type The type of result object. 1113 1117 * @param array $result The result to back-compat. 1118 * 1114 1119 * @return The $result with back-compat. 1115 1120 */ … … 1125 1130 1126 1131 // Parse an ISO DateInterval into seconds. 1127 $now = time();1132 $now = time(); 1128 1133 $result['duration'] = ( DateTimeImmutable::createFromFormat( 'U', $now ) )->add( new DateInterval( $result['duration'] ) )->getTimestamp() - $now; 1129 1134 … … 1164 1169 1165 1170 $result['status'] = strtolower( $result['status'] ); 1166 if ( in_array( $result['status'], [ 'published', 'past', 'active', 'autosched' ]) ) {1167 $result['status'] = 'upcoming'; // Right, past is upcoming in this context 1171 if ( in_array( $result['status'], array( 'published', 'past', 'active', 'autosched' ) ) ) { 1172 $result['status'] = 'upcoming'; // Right, past is upcoming in this context. 1168 1173 } 1169 1174 … … 1192 1197 1193 1198 if ( ! empty( $result['pastEvents']['edges'] ) ) { 1194 $result['last_event'] = [1199 $result['last_event'] = array( 1195 1200 'time' => $this->datetime_to_time( end( $result['pastEvents']['edges'] )['node']['dateTime'] ), 1196 1201 'yes_rsvp_count' => end( $result['pastEvents']['edges'] )['node']['going'], 1197 ];1202 ); 1198 1203 $result['past_event_count'] = count( $result['pastEvents']['edges'] ); 1199 1204 } elseif ( ! empty( $result['groupAnalytics']['lastEventDate'] ) ) { … … 1218 1223 * Generate a localised location name. 1219 1224 * 1220 * For the US this is 'City, ST, USA' 1221 * For Canada this is 'City, ST, Canada' 1222 * For the rest of world, this is 'City, CountryName' 1225 * For the US this is 'City, ST, USA'. 1226 * For Canada this is 'City, ST, Canada'. 1227 * For the rest of world, this is 'City, CountryName'. 1223 1228 */ 1224 1229 protected function localise_location( $args = array() ) { 1225 // Hard-code the Online event location 1230 // Hard-code the Online event location. 1226 1231 if ( ! empty( $args['id'] ) && self::ONLINE_VENUE_ID == $args['id'] ) { 1227 1232 return 'online'; … … 1243 1248 $country = $this->localised_country_name( $country ); 1244 1249 1245 return implode( ', ', array_filter( [ $city, $state, $country ]) ) ?: false;1250 return implode( ', ', array_filter( array( $city, $state, $country ) ) ) ?: false; 1246 1251 } 1247 1252 … … 1257 1262 1258 1263 // Shortcut, CLDR isn't always what we expect here. 1259 $shortcut = [1264 $shortcut = array( 1260 1265 'US' => 'USA', 1261 1266 'HK' => 'Hong Kong', 1262 1267 'SG' => 'Singapore', 1263 ];1268 ); 1264 1269 if ( ! empty( $shortcut[ $country ] ) ) { 1265 1270 return $shortcut[ $country ]; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/meetup/class-meetup-oauth2-client.php
r11498 r11850 128 128 /** 129 129 * Request one of various types of tokens from the Meetup OAuth API. 130 * 130 * 131 131 * Setting $type to 'access_token' is for step 2 of the oAuth flow. This takes a code that has been previously set 132 132 * through a user-initiated oAuth authentication. 133 * 133 * 134 134 * Setting $type to 'refresh_token' will request a new access_token generated through the above access_token method. 135 135 * … … 150 150 $request_body = array(); 151 151 152 switch ( $type ) {152 switch ( $type ) { 153 153 case 'access_token': // Request a new access token. 154 154 $args = wp_parse_args( $args, array( … … 156 156 ) ); 157 157 158 $request_url = self::URL_ACCESS_TOKEN;159 $request_body = array(158 $request_url = self::URL_ACCESS_TOKEN; 159 $request_body = array( 160 160 'client_id' => self::CONSUMER_KEY, 161 161 'client_secret' => self::CONSUMER_SECRET, … … 238 238 if ( ! $_GET['code'] ) { 239 239 $message = sprintf( 240 "Meetup.com oAuth expired. Please access the following url while logged into the %s meetup.com account: \n\n%s\n\n" . 240 "Meetup.com oAuth expired. Please access the following url while logged into the %s meetup.com account: \n\n%s\n\n" . 241 241 "For sites other than WordCamp Central, the ?code=... parameter will need to be stored on this site via wp-cli and this task run again: `wp --url=%s site option update '%s' '...'`", 242 242 self::EMAIL, … … 265 265 delete_site_option( self::SITE_OPTION_KEY_AUTHORIZATION, false ); 266 266 } 267 268 267 } elseif ( $this->is_expired_token( $token ) ) { 269 268 $token = $this->request_token( 'refresh_token', $token );
Note: See TracChangeset
for help on using the changeset viewer.