Changeset 40607 for trunk/src/wp-admin/includes/ajax-actions.php
- Timestamp:
- 05/10/2017 08:03:01 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r40476 r40607 295 295 296 296 wp_die( wp_json_encode( $return ) ); 297 } 298 299 /** 300 * Handles AJAX requests for community events 301 * 302 * @since 4.8.0 303 */ 304 function wp_ajax_get_community_events() { 305 require_once( ABSPATH . 'wp-admin/includes/class-wp-community-events.php' ); 306 307 check_ajax_referer( 'community_events' ); 308 309 $search = isset( $_POST['location'] ) ? wp_unslash( $_POST['location'] ) : ''; 310 $timezone = isset( $_POST['timezone'] ) ? wp_unslash( $_POST['timezone'] ) : ''; 311 $user_id = get_current_user_id(); 312 $saved_location = get_user_option( 'community-events-location', $user_id ); 313 $events_client = new WP_Community_Events( $user_id, $saved_location ); 314 $events = $events_client->get_events( $search, $timezone ); 315 316 if ( is_wp_error( $events ) ) { 317 wp_send_json_error( array( 318 'error' => $events->get_error_message(), 319 ) ); 320 } else { 321 if ( isset( $events['location'] ) ) { 322 // Send only the data that the client will use. 323 $events['location'] = $events['location']['description']; 324 325 // Store the location network-wide, so the user doesn't have to set it on each site. 326 update_user_option( $user_id, 'community-events-location', $events['location'], true ); 327 } 328 329 wp_send_json_success( $events ); 330 } 297 331 } 298 332
Note: See TracChangeset
for help on using the changeset viewer.