WordPress.org

Make WordPress Core

Changeset 40774


Ignore:
Timestamp:
05/18/17 07:30:05 (7 months ago)
Author:
obenland
Message:

Dashboard: Always pass the IP when getting events

Allows the API to determine event locations more accurately.

Props iandunn.
See #40702.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-community-events.php

    r40669 r40774  
    138138     * @since 4.8.0 
    139139     * 
    140      * @param  string $search   City search string. Default empty string. 
    141      * @param  string $timezone Timezone string. Default empty string. 
     140     * @param  string $search   Optional. City search string. Default empty string. 
     141     * @param  string $timezone Optional. Timezone string. Default empty string. 
    142142     * @return string The request URL. 
    143143     */ 
    144144    protected function get_request_url( $search = '', $timezone = '' ) { 
    145145        $api_url = 'https://api.wordpress.org/events/1.0/'; 
    146         $args    = array( 'number' => 5 ); // Get more than three in case some get trimmed out. 
     146        $args    = array( 
     147            'number' => 5, // Get more than three in case some get trimmed out. 
     148            'ip'     => $this->maybe_anonymize_ip_address( $this->get_unsafe_client_ip() ), 
     149        ); 
    147150 
    148151        /* 
     
    162165            if ( $search ) { 
    163166                $args['location'] = $search; 
    164             } else { 
    165                 /* 
    166                  * Protect the user's privacy by anonymizing their IP before sending 
    167                  * it to w.org, and only send it when necessary. 
    168                  * 
    169                  * The w.org API endpoint only uses the IP address when a location 
    170                  * query is not provided, so we can safely avoid sending it when 
    171                  * there is a query. 
    172                  */ 
    173                 $args['ip'] = $this->maybe_anonymize_ip_address( $this->get_unsafe_client_ip() ); 
    174167            } 
    175168        } 
Note: See TracChangeset for help on using the changeset viewer.