Make WordPress Core

Ticket #40702: 40702.ajax-fix.2.diff

File 40702.ajax-fix.2.diff, 1.7 KB (added by iandunn, 7 years ago)

A failed attempt at improving on 40702.ajax-fix.diff

  • src/wp-admin/includes/ajax-actions.php

    diff --git src/wp-admin/includes/ajax-actions.php src/wp-admin/includes/ajax-actions.php
    index 029e20e62b..634713b195 100644
    function wp_ajax_get_community_events() { 
    319319                ) );
    320320        } else {
    321321                if ( isset( $events['location'] ) ) {
    322                         // Send only the data that the client will use.
    323                         $events['location'] = $events['location']['description'];
    324 
    325322                        // Store the location network-wide, so the user doesn't have to set it on each site.
    326323                        update_user_option( $user_id, 'community-events-location', $events['location'], true );
     324
     325                        // Send only the data that the client will use.
     326                        $events['location'] = $events['location']['description'];
    327327                }
    328328
    329329                wp_send_json_success( $events );
  • src/wp-admin/includes/dashboard.php

    diff --git src/wp-admin/includes/dashboard.php src/wp-admin/includes/dashboard.php
    index b25426e753..f3de00e32b 100644
    function wp_get_community_events_script_data() { 
    142142        $user_id       = get_current_user_id();
    143143        $user_location = get_user_option( 'community-events-location', $user_id );
    144144        $events_client = new WP_Community_Events( $user_id, $user_location );
     145        $cached_data   = $events_client->get_cached_events();
     146
     147        // Send only the data that the client will use.
     148        $cached_data['location'] = $cached_data['location']['description'];
    145149
    146150        $script_data = array(
    147151                'nonce' => wp_create_nonce( 'community_events' ),
    148                 'cache' => $events_client->get_cached_events(),
     152                'cache' => $cached_data,
    149153
    150154                'l10n' => array(
    151155                        'enter_closest_city' => __( 'Enter your closest city to find nearby events.' ),