Make WordPress Core

Ticket #44971: WP_Community_Events.patch

File WP_Community_Events.patch, 1.3 KB (added by andfinally, 5 years ago)

Change to enable WP_Community_Events to find cached events when no location is passed to the constructor

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

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    3333         */
    3434        protected $user_location = false;
    3535
     36        /**
     37         * Partially anonymized IP address of the user's network.
     38         *
     39         * @since 5.0.0
     40         *
     41         * @var bool|string
     42         */
     43        protected $unsafe_client_ip = false;
     44
    3645        /**
    3746         * Constructor for WP_Community_Events.
    3847         *
     
    8695         *                        success.
    8796         */
    8897        public function get_events( $location_search = '', $timezone = '' ) {
     98
     99                $this->unsafe_client_ip = self::get_unsafe_client_ip();
     100
     101                if ( ! $this->user_location && $this->unsafe_client_ip ) {
     102                        $this->user_location = [ 'ip' => $this->unsafe_client_ip ];
     103                }
     104
    89105                $cached_events = $this->get_cached_events();
    90106
    91107                if ( ! $location_search && $cached_events ) {
     
    179195        protected function get_request_args( $search = '', $timezone = '' ) {
    180196                $args = array(
    181197                        'number' => 5, // Get more than three in case some get trimmed out.
    182                         'ip'     => self::get_unsafe_client_ip(),
     198                        'ip'     => $this->unsafe_client_ip,
    183199                );
    184200
    185201                /*