Making WordPress.org

Changeset 11850


Ignore:
Timestamp:
05/17/2022 11:25:58 PM (3 years ago)
Author:
iandunn
Message:

Official WP Events: Sync with wordcamp.org forks.

This includes some linting since that made it easier to compare them manually

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  
    3636     * @var array A list of integer response codes that should break the "tenacious" remote request loop.
    3737     */
    38     protected $breaking_response_codes = [];
     38    protected $breaking_response_codes = array();
    3939
    4040    /**
     
    6060     * }
    6161     */
    62     public function __construct( array $settings = [] ) {
     62    public function __construct( array $settings = array() ) {
    6363        $this->error = new WP_Error();
    6464
    65         $defaults = [
     65        $defaults = array(
    6666            'throttle_callback'       => '',
    67             'breaking_response_codes' => [ 400, 401, 404, 429 ],
    68         ];
     67            'breaking_response_codes' => array( 400, 401, 404, 429 ),
     68        );
    6969
    7070        $settings = wp_parse_args( $settings, $defaults );
     
    8686     * @return array|WP_Error
    8787     */
    88     protected function tenacious_remote_request( $url, array $args = [] ) {
     88    protected function tenacious_remote_request( $url, array $args = array() ) {
    8989        $attempt_count  = 0;
    9090        $max_attempts   = 3;
     
    172172     * @return array|WP_Error
    173173     */
    174     public function tenacious_remote_get( $url, array $args = [] ) {
     174    public function tenacious_remote_get( $url, array $args = array() ) {
    175175        $args['method'] = 'GET';
    176176
     
    186186     * @return array|WP_Error
    187187     */
    188     public function tenacious_remote_post( $url, array $args = [] ) {
     188    public function tenacious_remote_post( $url, array $args = array() ) {
    189189        $args['method'] = 'POST';
    190190
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/meetup/class-meetup-client.php

    r11399 r11850  
    3535     * @var string The GraphQL field that must be present for pagination to work.
    3636     */
    37     public $pageInfo = 'pageInfo { hasNextPage endCursor }';
     37    public $pagination = 'pageInfo { hasNextPage endCursor }';
    3838
    3939    /**
     
    5656     * }
    5757     */
    58     public function __construct( array $settings = [] ) {
     58    public function __construct( array $settings = array() ) {
    5959        parent::__construct( array(
    6060            /*
     
    7474                401, // Unauthorized (invalid key).
    7575                429, // Too many requests (rate-limited).
    76                 404, // Unable to find group
    77 
     76                404, // Unable to find group.
    7877                503, // Timeout between API cache & GraphQL Server.
    7978            ),
     
    9291
    9392        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();
    9897
    9998        if ( ! empty( $this->oauth_client->error->get_error_messages() ) ) {
     
    139138     *
    140139     * This automatically paginates requests and will repeat requests to ensure all results are retrieved.
    141      * For pagination to work, $this->pageInfo must be present within the string, and a 'cursor' variable defined.
    142      *
    143      * @param string $request_url The API endpoint URL to send the request to.
    144      * @param array  $variables   The Query variables used in the query.
     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.
    145144     *
    146145     * @return array|WP_Error The results of the request.
     
    152151        $is_paginated_request = ! empty( $variables ) &&
    153152            array_key_exists( 'cursor', $variables ) &&
    154             false !== stripos( $query, $this->pageInfo );
     153            false !== stripos( $query, $this->pagination );
    155154
    156155        do {
     
    195194                array_walk_recursive(
    196195                    $new_data,
    197                     function( $value, $key ) use( &$has_next_page, &$end_cursor ) {
     196                    function ( $value, $key ) use ( &$has_next_page, &$end_cursor ) {
    198197                        // NOTE: This will be truthful and present on the final page causing paged
    199198                        // requests to always make an additional request to a final empty page.
    200                         if ( $key === 'hasNextPage' ) {
     199                        if ( 'hasNextPage' === $key ) {
    201200                            $has_next_page = $value;
    202201                        } elseif ( 'endCursor' === $key ) {
     
    225224        } while ( $has_next_page );
    226225
    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
    228230            return $this->error;
    229231        }
     
    241243
    242244        foreach ( $array2 as $key => &$value ) {
    243             // Merge numeric arrays
     245            // Merge numeric arrays.
    244246            if ( is_array( $value ) && wp_is_numeric_array( $value ) && isset( $merged[ $key ] ) ) {
    245247                $merged[ $key ] = array_merge( $merged[ $key ], $value );
     
    277279                'Authorization' => "Bearer $oauth_token",
    278280            ),
    279             'body' => wp_json_encode( compact( 'query', 'variables' ) )
     281            'body' => wp_json_encode( compact( 'query', 'variables' ) ),
    280282        );
    281283    }
     
    284286     * Check the rate limit status in an API response and delay further execution if necessary.
    285287     *
    286      * @param array $headers
     288     * @param array $response
    287289     *
    288290     * @return void
     
    352354        }
    353355
    354         $datetime_formats = [
    355             'Y-m-d\TH:iP',   // 2021-11-20T17:00+05:30
    356             'Y-m-d\TH:i:sP', // 2021-11-20T17:00:00+05:30
     356        $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'.
    357359            // 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]'.
    359361            'c',             // ISO8601, just incase the above don't cover it.
    360             'Y-m-d\TH:i:s',  // timezoneless 2021-11-20T17:00:00
    361             'Y-m-d\TH:i',    // timezoneless 2021-11-20T17:00
    362         ];
     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        );
    363365
    364366        // See above, just keep one timezone if the timezone format is `P\[e\]`. Simpler matching, assume the timezones are the same.
     
    468470     */
    469471    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'] ) ) {
    473476            $fields = array_merge( $fields, $args['fields'] );
    474477        }
    475478
    476         $filters = [];
    477479        /*
    478480         *  See https://www.meetup.com/api/schema/#GroupAnalyticsFilter for valid filters.
     
    491493        }
    492494
    493         $variables = [
     495        $variables = array(
    494496            'urlname' => 'wordpress',
    495497            'perPage' => 200,
    496498            'cursor'  => null,
    497         ];
     499        );
    498500
    499501        $query = '
     
    502504                groupsSearch( input: { first: $perPage, after: $cursor }, filter: { ' . implode( ', ', $filters ) . '} ) {
    503505                    count
    504                     '  . $this->pageInfo . '
     506                    '  . $this->pagination . '
    505507                    edges {
    506508                        node {
     
    518520        }
    519521
    520         $results = array_column(
     522        $groups = array_column(
    521523            $result['proNetworkByUrlname']['groupsSearch']['edges'],
    522524            'node'
    523525        );
    524526
    525         $results = $this->apply_backcompat_fields( 'groups', $results );
    526 
    527         return $results;
     527        $groups = $this->apply_backcompat_fields( 'groups', $groups );
     528
     529        return $groups;
    528530    }
    529531
     
    578580     * @return array
    579581     */
    580     function get_event_details( $event_id ) {
    581 
     582    public function get_event_details( $event_id ) {
    582583        $fields = $this->get_default_fields( 'event' );
    583584
    584585        // Accepts, slug / id / slugId as the query-by fields.
    585         $query = '
     586        $query     = '
    586587        query ( $eventId: ID ) {
    587588            event( id: $eventId ) {
     
    589590            }
    590591        }';
    591         $variables = [
     592        $variables = array(
    592593            'eventId' => $event_id,
    593         ];
     594        );
    594595
    595596        $result = $this->send_paginated_request( $query, $variables );
     
    617618        /* $events = [ id => $meetupID, id2 => $meetupID2 ] */
    618619
    619         $return = [];
     620        $return = array();
    620621        $chunks = array_chunk( $event_ids, 250, true );
    621622
    622623        foreach ( $chunks as $chunked_events ) {
    623             $keys      = [];
    624             $query     = '';
     624            $keys  = array();
     625            $query = '';
    625626
    626627            foreach ( $chunked_events as $id => $event_id ) {
    627                 $key = 'e' . md5( $id );
     628                $key          = 'e' . md5( $id );
    628629                $keys[ $key ] = $id;
    629630
     
    659660     */
    660661    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(
    664665            'dateTime',
    665666            'going',
    666         ];
    667 
    668         if ( !empty( $args['fields'] ) && is_array( $args['fields'] ) ) {
     667        );
     668
     669        if ( ! empty( $args['fields'] ) && is_array( $args['fields'] ) ) {
    669670            $fields = array_merge( $fields, $args['fields'] );
    670671        }
    671         if ( !empty( $args['events_fields'] ) && is_array( $args['events_fields'] ) ) {
     672        if ( ! empty( $args['events_fields'] ) && is_array( $args['events_fields'] ) ) {
    672673            $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'] ) {
    674675            $events_fields = array_merge( $events_fields, $this->get_default_fields( 'events' ) );
    675676        }
     
    678679        // Instead, we fetch the details for every past event instead.
    679680
    680         $query = '
     681        $query     = '
    681682        query ( $urlname: String!, $perPage: Int!, $cursor: String ) {
    682683            groupByUrlname( urlname: $urlname ) {
    683684                ' . implode( ' ', $fields ) . '
    684685                pastEvents ( input: { first: $perPage, after: $cursor } ) {
    685                     ' . $this->pageInfo . '
     686                    ' . $this->pagination . '
    686687                    edges {
    687688                        node {
     
    692693            }
    693694        }';
    694         $variables = [
     695        $variables = array(
    695696            'urlname' => $group_slug,
    696697            'perPage' => 200,
    697698            'cursor'  => null,
    698         ];
     699        );
    699700
    700701        $result = $this->send_paginated_request( $query, $variables );
     
    704705        }
    705706
    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;
    712711    }
    713712
     
    730729        }
    731730
    732         // Filters
    733         $filters = [];
     731        // Filters.
     732        $filters = array();
    734733        if ( isset( $args['role'] ) && 'leads' === $args['role'] ) {
    735734            // See https://www.meetup.com/api/schema/#MembershipStatus for valid statuses.
     
    744743
    745744        // 'memberships' => 'GroupUserConnection' not documented.
    746         $query = '
     745        $query     = '
    747746        query ( $urlname: String!, $perPage: Int!, $cursor: String ) {
    748747            groupByUrlname( urlname: $urlname ) {
    749748                memberships ( input: { first: $perPage, after: $cursor }, filter: { ' . implode( ', ', $filters ) . ' } ) {
    750                     ' . $this->pageInfo . '
     749                    ' . $this->pagination . '
    751750                    edges {
    752751                        node {
     
    757756            }
    758757        }';
    759         $variables = [
     758        $variables = array(
    760759            'urlname' => $group_slug,
    761760            'perPage' => 200,
    762761            'cursor'  => null,
    763         ];
     762        );
    764763
    765764        $results = $this->send_paginated_request( $query, $variables );
     
    768767        }
    769768
    770         // Select memberships.edges[*].node
     769        // Select memberships.edges[*].node.
    771770        $results = array_column(
    772771            $results['groupByUrlname']['memberships']['edges'],
     
    781780     */
    782781    public function get_network_events( array $args = array() ) {
    783         $defaults = [
    784             'filters'        => [],
     782        $defaults = array(
     783            'filters'        => array(),
    785784            'max_event_date' => time() + YEAR_IN_SECONDS,
    786785            'min_event_date' => false,
    787             'online_events'  => null, // true: only online events, false: only IRL events
    788             'status'         => 'upcoming', //  UPCOMING, PAST, CANCELLED
     786            'online_events'  => null, // true: only online events, false: only IRL events.
     787            'status'         => 'upcoming', // UPCOMING, PAST, CANCELLED.
    789788            'sort'           => '',
    790         ];
    791         $args = wp_parse_args( $args, $defaults );
     789        );
     790        $args     = wp_parse_args( $args, $defaults );
    792791
    793792        $fields = $this->get_default_fields( 'event' );
    794793
    795         // See https://www.meetup.com/api/schema/#ProNetworkEventsFilter
    796         $filters = [];
     794        // See https://www.meetup.com/api/schema/#ProNetworkEventsFilter.
     795        $filters = array();
    797796
    798797        if ( $args['min_event_date'] ) {
     
    807806        }
    808807
    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' ) ) ) {
    811810            $filters['status'] = 'status: ' . strtoupper( $args['status'] );
    812811        }
    813812
    814813        if ( $args['filters'] ) {
    815             foreach( $args['filters'] as $key => $filter ) {
     814            foreach ( $args['filters'] as $key => $filter ) {
    816815                $filters[ $key ] = "{$key}: {$filter}";
    817816            }
    818817        }
    819818
    820         $query = '
     819        $query     = '
    821820        query ( $urlname: String!, $perPage: Int!, $cursor: String ) {
    822821            proNetworkByUrlname( urlname: $urlname ) {
    823822                eventsSearch ( input: { first: $perPage, after: $cursor }, filter: { ' . implode( ', ', $filters )  . ' } ) {
    824                     ' . $this->pageInfo . '
     823                    ' . $this->pagination . '
    825824                    edges {
    826825                        node {
     
    831830            }
    832831        }';
    833         $variables = [
     832        $variables = array(
    834833            'urlname' => 'wordpress',
    835             'perPage' => 1000, // More per-page to avoid hitting request limits
     834            'perPage' => 1000, // More per-page to avoid hitting request limits.
    836835            'cursor'  => null,
    837         ];
    838 
     836        );
    839837
    840838        $results = $this->send_paginated_request( $query, $variables );
     
    845843
    846844        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(
    852850            $results['proNetworkByUrlname']['eventsSearch']['edges'],
    853851            'node'
    854852        );
    855853
    856         $results = $this->apply_backcompat_fields( 'events', $results );
    857 
    858         return $results;
     854        $events = $this->apply_backcompat_fields( 'events', $events );
     855
     856        return $events;
    859857
    860858    }
     
    869867     */
    870868    public function get_group_events( $group_slug, array $args = array() ) {
    871         $defaults = [
     869        $defaults = array(
    872870            'status'          => 'upcoming',
    873871            'no_earlier_than' => '',
    874872            'no_later_than'   => '',
    875             'fields'          => [],
    876         ];
    877         $args = wp_parse_args( $args, $defaults );
     873            'fields'          => array(),
     874        );
     875        $args     = wp_parse_args( $args, $defaults );
    878876
    879877        /*
     
    892890         */
    893891        if ( false !== strpos( $args['status'], ',' ) ) {
    894             $events = [];
     892            $events = array();
    895893            foreach ( explode( ',', $args['status'] ) as $status ) {
    896894                $args['status'] = $status;
     
    906904
    907905            // 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            );
    915916
    916917            return $events;
     
    918919
    919920        $fields = $this->get_default_fields( 'event' );
    920 
    921         // TODO: Check the above list against Official_WordPress_Events::parse_meetup_events()
    922921
    923922        if ( ! empty( $args['fields'] ) && is_array( $args['fields'] ) ) {
     
    937936            default:
    938937                // We got nothing.
    939                 return [];
     938                return array();
    940939        }
    941940
    942941        // No filters defined, as we have to do it ourselves. See above.
    943942
    944         $query = '
     943        $query     = '
    945944        query ( $urlname: String!, $perPage: Int!, $cursor: String ) {
    946945            groupByUrlname( urlname: $urlname ) {
    947946                ' . $event_field . ' ( input: { first: $perPage, after: $cursor } ) {
    948                     ' . $this->pageInfo . '
     947                    ' . $this->pagination . '
    949948                    edges {
    950949                        node {
     
    955954            }
    956955        }';
    957         $variables = [
     956        $variables = array(
    958957            'urlname' => $group_slug,
    959958            'perPage' => 200,
    960959            'cursor'  => null,
    961         ];
     960        );
    962961
    963962        $results = $this->send_paginated_request( $query, $variables );
     
    966965        }
    967966
    968         // Select {$event_field}.edges[*].node
    969         $results = array_column(
     967        // Select {$event_field}.edges[*].node.
     968        $events = array_column(
    970969            $results['groupByUrlname'][ $event_field ]['edges'],
    971970            'node'
    972971        );
    973972
    974         $results = $this->apply_backcompat_fields( 'events', $results );
     973        $events = $this->apply_backcompat_fields( 'events', $events );
    975974
    976975        // Apply filters.
     
    979978            $args['no_later_than']   = $this->datetime_to_time( $args['no_later_than'] ) ?: PHP_INT_MAX;
    980979
    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 (
    985984                        $event['time'] >= $args['no_earlier_than'] &&
    986                         $event['time'] < $args['no_later_than'];
     985                        $event['time'] < $args['no_later_than']
     986                    );
    987987                }
    988988            );
    989989        }
    990990
    991         return $results;
     991        return $events;
    992992    }
    993993
     
    10021002    public function get_result_count( $route, array $args = array() ) {
    10031003        $result  = false;
    1004         $filters = [];
     1004        $filters = array();
    10051005
    10061006        // Number of groups in the Pro Network.
     
    10091009        }
    10101010
    1011         // https://www.meetup.com/api/schema/#GroupAnalyticsFilter
     1011        // https://www.meetup.com/api/schema/#GroupAnalyticsFilter.
    10121012        if ( ! empty( $args['pro_join_date_max'] ) ) {
    10131013            $filters['proJoinDateMax'] = 'proJoinDateMax: ' . $this->datetime_to_time( $args['pro_join_date_max'] ) * 1000;
     
    10251025        $query = '
    10261026        query {
    1027             proNetworkByUrlname( urlname: "wordpress" ) {
     1027            proNetworkByUrlname( urlname: "WordPress" ) {
    10281028                groupsSearch( filter: { ' .  implode( ', ', $filters ) . ' } ) {
    10291029                    count
     
    10491049        if ( 'event' === $type ) {
    10501050            // See https://www.meetup.com/api/schema/#Event for valid fields.
    1051             return [
     1051            return array(
    10521052                'id',
    10531053                'title',
     
    10671067                }',
    10681068                '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            );
    10781072        } elseif ( 'memberships' === $type ) {
    10791073            // See https://www.meetup.com/api/schema/#User for valid fields.
    1080             return [
     1074            return array(
    10811075                'id',
    10821076                'name',
    10831077                'email',
    1084             ];
     1078            );
    10851079        } elseif ( 'group' === $type ) {
    1086             return [
     1080            return array(
    10871081                'id',
    10881082                'name',
     
    11011095                'latitude',
    11021096                '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            );
    11041108        }
    11051109    }
     
    11121116     * @param string $type   The type of result object.
    11131117     * @param array  $result The result to back-compat.
     1118     *
    11141119     * @return The $result with back-compat.
    11151120     */
     
    11251130
    11261131            // Parse an ISO DateInterval into seconds.
    1127             $now = time();
     1132            $now                = time();
    11281133            $result['duration'] = ( DateTimeImmutable::createFromFormat( 'U', $now ) )->add( new DateInterval( $result['duration'] ) )->getTimestamp() - $now;
    11291134
     
    11641169
    11651170            $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.
    11681173            }
    11691174
     
    11921197
    11931198            if ( ! empty( $result['pastEvents']['edges'] ) ) {
    1194                 $result['last_event']       = [
     1199                $result['last_event']       = array(
    11951200                    'time'           => $this->datetime_to_time( end( $result['pastEvents']['edges'] )['node']['dateTime'] ),
    11961201                    'yes_rsvp_count' => end( $result['pastEvents']['edges'] )['node']['going'],
    1197                 ];
     1202                );
    11981203                $result['past_event_count'] = count( $result['pastEvents']['edges'] );
    11991204            } elseif ( ! empty( $result['groupAnalytics']['lastEventDate'] ) ) {
     
    12181223     * Generate a localised location name.
    12191224     *
    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'.
    12231228     */
    12241229    protected function localise_location( $args = array() ) {
    1225         // Hard-code the Online event location
     1230        // Hard-code the Online event location.
    12261231        if ( ! empty( $args['id'] ) && self::ONLINE_VENUE_ID == $args['id'] ) {
    12271232            return 'online';
     
    12431248        $country = $this->localised_country_name( $country );
    12441249
    1245         return implode( ', ',  array_filter( [ $city, $state, $country ] ) ) ?: false;
     1250        return implode( ', ',  array_filter( array( $city, $state, $country ) ) ) ?: false;
    12461251    }
    12471252
     
    12571262
    12581263        // Shortcut, CLDR isn't always what we expect here.
    1259         $shortcut = [
     1264        $shortcut = array(
    12601265            'US' => 'USA',
    12611266            'HK' => 'Hong Kong',
    12621267            'SG' => 'Singapore',
    1263         ];
     1268        );
    12641269        if ( ! empty( $shortcut[ $country ] ) ) {
    12651270            return $shortcut[ $country ];
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/meetup/class-meetup-oauth2-client.php

    r11498 r11850  
    128128    /**
    129129     * Request one of various types of tokens from the Meetup OAuth API.
    130      * 
     130     *
    131131     * Setting $type to 'access_token' is for step 2 of the oAuth flow. This takes a code that has been previously set
    132132     * through a user-initiated oAuth authentication.
    133      * 
     133     *
    134134     * Setting $type to 'refresh_token' will request a new access_token generated through the above access_token method.
    135135     *
     
    150150        $request_body    = array();
    151151
    152         switch( $type ) {
     152        switch ( $type ) {
    153153            case 'access_token': // Request a new access token.
    154154                $args = wp_parse_args( $args, array(
     
    156156                ) );
    157157
    158                 $request_url  = self::URL_ACCESS_TOKEN;
    159                 $request_body = array(
     158                $request_url                     = self::URL_ACCESS_TOKEN;
     159                $request_body                    = array(
    160160                    'client_id'     => self::CONSUMER_KEY,
    161161                    'client_secret' => self::CONSUMER_SECRET,
     
    238238                if ( ! $_GET['code'] ) {
    239239                    $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" .
    241241                        "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' '...'`",
    242242                        self::EMAIL,
     
    265265                delete_site_option( self::SITE_OPTION_KEY_AUTHORIZATION, false );
    266266            }
    267 
    268267        } elseif ( $this->is_expired_token( $token ) ) {
    269268            $token = $this->request_token( 'refresh_token', $token );
Note: See TracChangeset for help on using the changeset viewer.