Make WordPress Core

Ticket #40702: 40702-geoip.diff

File 40702-geoip.diff, 1.4 KB (added by iandunn, 8 years ago)

Always pass the IP address, so the API can improve search results

  • src/wp-admin/includes/class-wp-community-events.php

    diff --git src/wp-admin/includes/class-wp-community-events.php src/wp-admin/includes/class-wp-community-events.php
    index d3c6f08699..2f1ac86c42 100644
    class WP_Community_Events { 
    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                        // Get more than three in case some get trimmed out.
     148                        'number' => 5,
     149
     150                        // Anonymize the IP to protect user privacy.
     151                        'ip' => $this->maybe_anonymize_ip_address( $this->get_unsafe_client_ip() ),
     152                );
    147153
    148154                /*
    149155                 * Send the minimal set of necessary arguments, in order to increase the
    class WP_Community_Events { 
    161167
    162168                        if ( $search ) {
    163169                                $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() );
    174170                        }
    175171                }
    176172