Ticket #40702: 40702.10.diff
File 40702.10.diff, 27.5 KB (added by , 7 years ago) |
---|
-
src/wp-admin/admin-ajax.php
diff --git src/wp-admin/admin-ajax.php src/wp-admin/admin-ajax.php index 3213d55028..e0f4464d94 100644
$core_actions_post = array( 64 64 'parse-media-shortcode', 'destroy-sessions', 'install-plugin', 'update-plugin', 'press-this-save-post', 65 65 'press-this-add-category', 'crop-image', 'generate-password', 'save-wporg-username', 'delete-plugin', 66 66 'search-plugins', 'search-install-plugins', 'activate-plugin', 'update-theme', 'delete-theme', 67 'install-theme', 'get-post-thumbnail-html', 'get-community-events',67 'install-theme', 'get-post-thumbnail-html', 68 68 ); 69 69 70 70 // Deprecated -
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..3342cad375 100644
function wp_ajax_autocomplete_user() { 297 297 } 298 298 299 299 /** 300 * Handles AJAX requests for community events301 *302 * @since 4.8.0303 */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 }331 }332 333 /**334 300 * Ajax handler for dashboard widgets. 335 301 * 336 302 * @since 3.4.0 -
src/wp-admin/includes/dashboard.php
diff --git src/wp-admin/includes/dashboard.php src/wp-admin/includes/dashboard.php index b25426e753..2e49ce54c5 100644
function wp_get_community_events_script_data() { 144 144 $events_client = new WP_Community_Events( $user_id, $user_location ); 145 145 146 146 $script_data = array( 147 'nonce' => wp_create_nonce( 'community_events' ),148 147 'cache' => $events_client->get_cached_events(), 149 148 150 149 'l10n' => array( … … function wp_print_community_events_templates() { 1243 1242 <?php printf( 1244 1243 /* translators: %s is a placeholder for the name of a city. */ 1245 1244 __( 'Attend an upcoming event near %s.' ), 1246 '<strong>{{ data.location }}</strong>'1245 '<strong>{{ data.location.description }}</strong>' 1247 1246 ); ?> 1248 1247 </script> 1249 1248 … … function wp_print_community_events_templates() { 1265 1264 </div> 1266 1265 </div> 1267 1266 1268 <div class="event-date-time"> 1269 <span class="event-date">{{ event.formatted_date }}</span> 1270 <# if ( 'meetup' === event.type ) { #> 1271 <span class="event-time">{{ event.formatted_time }}</span> 1272 <# } #> 1273 </div> 1267 <# if ( event.date && event.date.formatted ) { #> 1268 <div class="event-date-time"> 1269 <span class="event-date">{{ event.date.formatted.date }}</span> 1270 <# if ( 'meetup' === event.type ) { #> 1271 <span class="event-time">{{ event.date.formatted.time }}</span> 1272 <# } #> 1273 </div> 1274 <# } #> 1274 1275 </li> 1275 1276 <# } ) #> 1276 1277 </script> … … function wp_print_community_events_templates() { 1280 1281 <?php printf( 1281 1282 /* translators: 1: the city the user searched for, 2: meetup organization documentation URL */ 1282 1283 __( 'There aren’t any events scheduled near %1$s at the moment. Would you like to <a href="%2$s">organize one</a>?' ), 1283 '{{data.location }}',1284 '{{data.location.description}}', 1284 1285 __( 'https://make.wordpress.org/community/handbook/meetup-organizer/welcome/' ) 1285 1286 ); ?> 1286 1287 </li> -
src/wp-admin/js/dashboard.js
diff --git src/wp-admin/js/dashboard.js src/wp-admin/js/dashboard.js index 6a9b5033d4..570eecadac 100644
jQuery(document).ready( function($) { 191 191 192 192 jQuery( function( $ ) { 193 193 'use strict'; 194 194 195 195 var communityEventsData = window.communityEventsData || {}; 196 196 197 197 var app = window.wp.communityEvents = { … … jQuery( function( $ ) { 288 288 getEvents: function( requestParams ) { 289 289 var initiatedBy, 290 290 app = this, 291 $spinner = $( '.community-events-form' ).children( '.spinner' ); 291 $spinner = $( '.community-events-form' ).children( '.spinner' ), 292 dashboardLoadPromise = wp.api.init( { 'versionString': 'wp/dashboard/v1/' } ); 292 293 293 294 requestParams = requestParams || {}; 294 requestParams._wpnonce = communityEventsData.nonce;295 295 requestParams.timezone = window.Intl ? window.Intl.DateTimeFormat().resolvedOptions().timeZone : ''; 296 requestParams._embed = 1; 296 297 297 298 initiatedBy = requestParams.location ? 'user' : 'app'; 298 299 299 300 $spinner.addClass( 'is-active' ); 300 301 301 wp.ajax.post( 'get-community-events', requestParams ) 302 .always( function() { 303 $spinner.removeClass( 'is-active' ); 304 }) 305 306 .done( function( response ) { 307 if ( 'no_location_available' === response.error ) { 308 if ( requestParams.location ) { 309 response.unknownCity = requestParams.location; 310 } else { 311 /* 312 * No location was passed, which means that this was an automatic query 313 * based on IP, locale, and timezone. Since the user didn't initiate it, 314 * it should fail silently. Otherwise, the error could confuse and/or 315 * annoy them. 316 */ 317 318 delete response.error; 302 dashboardLoadPromise.done( function( endpoint ) { 303 if ( ! app.model ) { 304 app.model = new wp.api.collections.CommunityEventsMine(); 305 } 306 requestParams = requestParams || {}; 307 requestParams.timezone = window.Intl ? window.Intl.DateTimeFormat().resolvedOptions().timeZone : ''; 308 requestParams._embed = 1; 309 initiatedBy = requestParams.location ? 'user' : 'app'; 310 311 $spinner.addClass( 'is-active' ); 312 313 314 var meModel = app.model.fetch( { 315 'data': requestParams, 316 'success': function( model, response ) { 317 window.console.log( 'success', response ); 318 var events = response._embedded && response._embedded.events ? response._embedded.events[0] : []; 319 var location = response; 320 321 delete response._embedded; 322 delete response._links; 323 324 app.renderEventsTemplate({ 325 location: location, 326 events: events 327 }, initiatedBy ); 328 329 }, 330 'error': function( model, response ) { 331 332 if ( 'rest_cannot_retrieve_user_location' === response.code && requestParams.location ) { 333 app.renderEventsTemplate({ 334 unknownCity: requestParams.location, 335 location: false, 336 events: [] 337 }, initiatedBy ); 338 339 return; 319 340 } 341 342 app.renderEventsTemplate( { 343 'location' : false, 344 'error' : true 345 }, initiatedBy ); 320 346 } 321 app.renderEventsTemplate( response, initiatedBy ); 322 }) 323 324 .fail( function() { 325 app.renderEventsTemplate( { 326 'location' : false, 327 'error' : true 328 }, initiatedBy ); 329 }); 347 } ); 348 349 meModel 350 .always( function() { 351 $spinner.removeClass( 'is-active' ); 352 }); 353 }); 354 330 355 }, 331 356 332 357 /** -
src/wp-includes/js/wp-api.js
diff --git src/wp-includes/js/wp-api.js src/wp-includes/js/wp-api.js index 3f950a47f5..040a9af834 100644
1270 1270 // Extract the name and any parent from the route. 1271 1271 var collectionClassName, modelClassName, 1272 1272 routeName = collectionRoute.index.slice( collectionRoute.index.lastIndexOf( '/' ) + 1 ), 1273 parentName = wp.api.utils.extractRoutePart( collectionRoute.index, 1, routeModel.get( 'versionString' ), false ); 1273 parentName = wp.api.utils.extractRoutePart( collectionRoute.index, 1, routeModel.get( 'versionString' ), false ), 1274 remainder = collectionRoute.index 1275 .replace( routeModel.get( 'versionString' ), '' ) 1276 .replace( routeName, '' ) 1277 .slice( 1 ); 1274 1278 1275 1279 // If the collection has a parent in its route, add that to its class name. 1276 1280 if ( '' !== parentName && parentName !== routeName && routeModel.get( 'versionString' ) !== parentName ) { … … 1282 1286 1283 1287 // Function that returns a constructed url passed on the parent. 1284 1288 url: function() { 1285 return routeModel.get( 'apiRoot' ) + routeModel.get( 'versionString' ) + 1286 parentName + '/' + this.parent + '/' + 1287 routeName; 1289 var hasParent = ! _.isEmpty( this.parent ); 1290 1291 return routeModel.get( 'apiRoot' ) + 1292 routeModel.get( 'versionString' ) + 1293 ( hasParent ? ( parentName + '/' ) : remainder ) + 1294 ( hasParent ? ( this.parent + '/' ) : '' ) + 1295 routeName; 1288 1296 }, 1289 1297 1290 1298 // Specify the model that this collection contains. 1291 1299 model: function( attrs, options ) { 1292 return new loadingObjects.models[ modelClassName ]( attrs, options ); 1300 if ( loadingObjects.models[ modelClassName ] ) { 1301 return new loadingObjects.models[ modelClassName ]( attrs, options ); 1302 } else { 1303 return new Backbone.Model(); 1304 } 1293 1305 }, 1294 1306 1295 1307 // Include a reference to the original class name. -
src/wp-includes/rest-api.php
diff --git src/wp-includes/rest-api.php src/wp-includes/rest-api.php index ec7c50d27b..891be7ceb6 100644
function create_initial_rest_routes() { 237 237 // Settings. 238 238 $controller = new WP_REST_Settings_Controller; 239 239 $controller->register_routes(); 240 241 // Community events. 242 $controller = new WP_REST_Community_Events_Events_Controller; 243 $controller->register_routes(); 244 245 // Community events location. 246 $controller = new WP_REST_Community_Events_Location_Controller; 247 $controller->register_routes(); 240 248 } 241 249 242 250 /** -
new file src/wp-includes/rest-api/endpoints/dashboard/class-wp-rest-community-events-events-controller.php
diff --git src/wp-includes/rest-api/endpoints/dashboard/class-wp-rest-community-events-events-controller.php src/wp-includes/rest-api/endpoints/dashboard/class-wp-rest-community-events-events-controller.php new file mode 100644 index 0000000000..570abd2adc
- + 1 <?php 2 /** 3 * REST API: WP_REST_Community_Events_Events_Controller class 4 * 5 * @package WordPress 6 * @subpackage REST_API 7 * @since 4.8.0 8 */ 9 10 /** 11 * Core class to access community events via the REST API. 12 * 13 * @since 4.8.0 14 * 15 * @see WP_REST_Controller 16 */ 17 class WP_REST_Community_Events_Events_Controller extends WP_REST_Controller { 18 19 /** 20 * Constructor. 21 * 22 * @since 4.8.0 23 * @access public 24 */ 25 public function __construct() { 26 $this->namespace = 'wp/dashboard/v1'; 27 $this->rest_base = 'community-events/events'; 28 } 29 30 /** 31 * Registers the routes for the objects of the controller. 32 * 33 * @since 4.8.0 34 * @access public 35 * 36 * @see register_rest_route() 37 */ 38 public function register_routes() { 39 40 register_rest_route( $this->namespace, '/' . $this->rest_base . '/me', array( 41 array( 42 'methods' => WP_REST_Server::READABLE, 43 'callback' => array( $this, 'get_current_items' ), 44 'permission_callback' => array( $this, 'get_current_items_permissions_check' ), 45 'args' => $this->get_collection_params(), 46 ), 47 'schema' => array( $this, 'get_public_item_schema' ), 48 ) ); 49 } 50 51 /** 52 * Checks whether a given request has permission to read community events. 53 * 54 * @since 4.8.0 55 * @access public 56 * 57 * @param WP_REST_Request $request Full details about the request. 58 * @return WP_Error|true True if the request has read access, WP_Error object otherwise. 59 */ 60 public function get_current_items_permissions_check( $request ) { 61 if ( ! is_user_logged_in() ) { 62 return new WP_Error( 'rest_not_logged_in', __( 'You are not currently logged in.' ), array( 'status' => 401 ) ); 63 } 64 65 return true; 66 } 67 68 /** 69 * Retrieves community events. 70 * 71 * @since 4.8.0 72 * @access public 73 * 74 * @param WP_REST_Request $request Full details about the request. 75 * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure. 76 */ 77 public function get_current_items( $request ) { 78 require_once( ABSPATH . 'wp-admin/includes/class-wp-community-events.php' ); 79 80 $user_id = get_current_user_id(); 81 82 $location = $request->get_param( 'location' ); 83 $timezone = $request->get_param( 'timezone' ); 84 85 $saved_location = get_user_option( 'community-events-location', $user_id ); 86 $events_client = new WP_Community_Events( $user_id, $saved_location ); 87 $events = $events_client->get_events( $location, $timezone ); 88 89 $data = array(); 90 91 // Store the location network-wide, so the user doesn't have to set it on each site. 92 if ( ! is_wp_error( $events ) ) { 93 if ( isset( $events['location'] ) ) { 94 update_user_option( $user_id, 'community-events-location', $events['location'], true ); 95 } 96 97 if ( isset( $events['events'] ) ) { 98 foreach ( $events['events'] as $event ) { 99 $data[] = $this->prepare_item_for_response( $event, $request ); 100 } 101 } 102 } 103 104 return rest_ensure_response( $data ); 105 } 106 107 /** 108 * Prepares a single event output for response. 109 * 110 * @since 4.8.0 111 * @access public 112 * 113 * @param array $event Event data array from the API. 114 * @param WP_REST_Request $request Request object. 115 * @return array Item prepared for response. 116 */ 117 public function prepare_item_for_response( $event, $request ) { 118 $data = array(); 119 120 $keys_to_copy = array( 'type', 'title', 'url', 'meetup', 'meetup_url' ); 121 foreach ( $keys_to_copy as $key ) { 122 if ( isset( $event[ $key ] ) ) { 123 $data[ $key ] = $event[ $key ]; 124 } else { 125 $data[ $key ] = null; 126 } 127 } 128 129 $data['date'] = array( 130 'raw' => isset( $event['date'] ) ? $event['date'] : null, 131 'formatted' => array( 132 'date' => isset( $event['formatted_date'] ) ? $event['formatted_date'] : null, 133 'time' => isset( $event['formatted_time'] ) ? $event['formatted_time'] : null, 134 ), 135 ); 136 137 $data['location'] = isset( $event['location'] ) ? $event['location'] : null; 138 139 return $data; 140 } 141 142 /** 143 * Retrieves a community event's schema, conforming to JSON Schema. 144 * 145 * @since 4.8.0 146 * @access public 147 * 148 * @return array Item schema data. 149 */ 150 public function get_item_schema() { 151 return array( 152 '$schema' => 'http://json-schema.org/schema#', 153 'title' => 'community_event', 154 'type' => 'object', 155 'properties' => array( 156 'type' => array( 157 'description' => __( 'Type for the event.' ), 158 'type' => 'string', 159 'enum' => array( 'meetup', 'wordcamp' ), 160 'context' => array( 'view', 'edit', 'embed' ), 161 'readonly' => true, 162 ), 163 'title' => array( 164 'description' => __( 'Title for the event.' ), 165 'type' => 'string', 166 'context' => array( 'view', 'edit', 'embed' ), 167 'readonly' => true, 168 ), 169 'url' => array( 170 'description' => __( 'Website URL for the event.' ), 171 'type' => 'string', 172 'context' => array( 'view', 'edit', 'embed' ), 173 'readonly' => true, 174 ), 175 'meetup' => array( 176 'description' => __( 'Name of the meetup, if the event is a meetup.' ), 177 'type' => 'string', 178 'context' => array( 'view', 'edit', 'embed' ), 179 'readonly' => true, 180 ), 181 'meetup_url' => array( 182 'description' => __( 'URL for the meetup on meetup.com, if the event is a meetup.' ), 183 'type' => 'string', 184 'context' => array( 'view', 'edit', 'embed' ), 185 'readonly' => true, 186 ), 187 'date' => array( 188 'description' => __( 'Date and time information for the event.' ), 189 'type' => 'object', 190 'context' => array( 'view', 'edit', 'embed' ), 191 'readonly' => true, 192 'properties' => array( 193 'raw' => array( 194 'description' => __( 'Unformatted date and time string.' ), 195 'type' => 'string', 196 'format' => 'date-time', 197 'context' => array( 'view', 'edit', 'embed' ), 198 'readonly' => true, 199 ), 200 'formatted' => array( 201 'description' => __( 'Formatted date and time information for the event.' ), 202 'type' => 'object', 203 'context' => array( 'view', 'edit', 'embed' ), 204 'readonly' => true, 205 'properties' => array( 206 'date' => array( 207 'description' => __( 'Formatted event date.' ), 208 'type' => 'string', 209 'context' => array( 'view', 'edit', 'embed' ), 210 'readonly' => true, 211 ), 212 'time' => array( 213 'description' => __( 'Formatted event time.' ), 214 'type' => 'string', 215 'context' => array( 'view', 'edit', 'embed' ), 216 'readonly' => true, 217 ), 218 ), 219 ), 220 ), 221 ), 222 'location' => array( 223 'description' => __( 'Location information for the event.' ), 224 'type' => 'object', 225 'context' => array( 'view', 'edit', 'embed' ), 226 'readonly' => true, 227 'properties' => array( 228 'location' => array( 229 'description' => __( 'Location name for the event.' ), 230 'type' => 'string', 231 'context' => array( 'view', 'edit', 'embed' ), 232 'readonly' => true, 233 ), 234 'country' => array( 235 'description' => __( 'Two-letter country code for the event.' ), 236 'type' => 'string', 237 'context' => array( 'view', 'edit', 'embed' ), 238 'readonly' => true, 239 ), 240 'latitude' => array( 241 'description' => __( 'Latitude for the event.' ), 242 'type' => 'number', 243 'context' => array( 'view', 'edit', 'embed' ), 244 'readonly' => true, 245 ), 246 'longitude' => array( 247 'description' => __( 'Longitude for the event.' ), 248 'type' => 'number', 249 'context' => array( 'view', 'edit', 'embed' ), 250 'readonly' => true, 251 ), 252 ), 253 ), 254 ), 255 ); 256 } 257 258 /** 259 * Retrieves the query params for collections. 260 * 261 * @since 4.8.0 262 * @access public 263 * 264 * @return array Collection parameters. 265 */ 266 public function get_collection_params() { 267 return array( 268 'context' => $this->get_context_param( array( 'default' => 'view' ) ), 269 'location' => array( 270 'description' => __( 'Optional city name to help determine the location for the events.' ), 271 'type' => 'string', 272 'default' => '', 273 ), 274 'timezone' => array( 275 'description' => __( 'Optional timezone to help determine the location for the events.' ), 276 'type' => 'string', 277 'default' => '', 278 ), 279 ); 280 } 281 } -
new file src/wp-includes/rest-api/endpoints/dashboard/class-wp-rest-community-events-location-controller.php
diff --git src/wp-includes/rest-api/endpoints/dashboard/class-wp-rest-community-events-location-controller.php src/wp-includes/rest-api/endpoints/dashboard/class-wp-rest-community-events-location-controller.php new file mode 100644 index 0000000000..7b5f360d9e
- + 1 <?php 2 /** 3 * REST API: WP_REST_Community_Events_Location_Controller class 4 * 5 * @package WordPress 6 * @subpackage REST_API 7 * @since 4.8.0 8 */ 9 10 /** 11 * Core class to access community events user locations via the REST API. 12 * 13 * @since 4.8.0 14 * 15 * @see WP_REST_Controller 16 */ 17 class WP_REST_Community_Events_Location_Controller extends WP_REST_Controller { 18 19 /** 20 * Constructor. 21 * 22 * @since 4.8.0 23 * @access public 24 */ 25 public function __construct() { 26 $this->namespace = 'wp/dashboard/v1'; 27 $this->rest_base = 'community-events/location'; 28 } 29 30 /** 31 * Registers the routes for the objects of the controller. 32 * 33 * @since 4.8.0 34 * @access public 35 * 36 * @see register_rest_route() 37 */ 38 public function register_routes() { 39 40 register_rest_route( $this->namespace, '/' . $this->rest_base . '/mine', array( 41 array( 42 'methods' => WP_REST_Server::READABLE, 43 'callback' => array( $this, 'get_current_item' ), 44 'permission_callback' => array( $this, 'get_current_item_permissions_check' ), 45 'args' => $this->get_item_params(), 46 ), 47 'schema' => array( $this, 'get_public_item_schema' ), 48 ) ); 49 } 50 51 /** 52 * Checks whether a given request has permission to read the current user's community events location. 53 * 54 * @since 4.8.0 55 * @access public 56 * 57 * @param WP_REST_Request $request Full details about the request. 58 * @return WP_Error|true True if the request has read access, WP_Error object otherwise. 59 */ 60 public function get_current_item_permissions_check( $request ) { 61 if ( ! is_user_logged_in() ) { 62 return new WP_Error( 'rest_not_logged_in', __( 'You are not currently logged in.' ), array( 'status' => 401 ) ); 63 } 64 65 return true; 66 } 67 68 /** 69 * Retrieves the community events location for the current user. 70 * 71 * @since 4.8.0 72 * @access public 73 * 74 * @param WP_REST_Request $request Full details about the request. 75 * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure. 76 */ 77 public function get_current_item( $request ) { 78 require_once( ABSPATH . 'wp-admin/includes/class-wp-community-events.php' ); 79 80 $user_id = get_current_user_id(); 81 82 $location = $request->get_param( 'location' ); 83 $timezone = $request->get_param( 'timezone' ); 84 85 $saved_location = get_user_option( 'community-events-location', $user_id ); 86 $events_client = new WP_Community_Events( $user_id, $saved_location ); 87 $events = $events_client->get_events( $location, $timezone ); 88 89 // Store the location network-wide, so the user doesn't have to set it on each site. 90 if ( ! is_wp_error( $events ) ) { 91 if ( isset( $events['error'] ) && 'no_location_available' === $events['error'] ) { 92 return new WP_Error( 'rest_cannot_retrieve_user_location', __( 'The user location could not be retrieved.' ), array( 'status' => 503 ) ); 93 } 94 95 if ( isset( $events['location'] ) ) { 96 update_user_option( $user_id, 'community-events-location', $events['location'], true ); 97 98 $data = $this->prepare_item_for_response( $events['location'], $request ); 99 100 return rest_ensure_response( $data ); 101 } 102 } 103 104 return new WP_Error( 'rest_cannot_retrieve_user_location', __( 'The user location could not be retrieved.' ), array( 'status' => 503 ) ); 105 } 106 107 /** 108 * Prepares a single location output for response. 109 * 110 * @since 4.8.0 111 * @access public 112 * 113 * @param array $location Location data array from the API. 114 * @param WP_REST_Request $request Request object. 115 * @return WP_REST_Response Response object. 116 */ 117 public function prepare_item_for_response( $location, $request ) { 118 $data = array( 119 'description' => isset( $location['description'] ) ? $location['description'] : null, 120 'country' => isset( $location['country'] ) ? $location['country'] : null, 121 'latitude' => isset( $location['latitude'] ) ? (float) $location['latitude'] : null, 122 'longitude' => isset( $location['longitude'] ) ? (float) $location['longitude'] : null, 123 ); 124 125 $response = rest_ensure_response( $data ); 126 127 $url = rest_url( 'wp/dashboard/v1/community-events/events/me' ); 128 129 $url_args = array(); 130 131 if ( ! empty( $request['location'] ) ) { 132 $url_args['location'] = $request['location']; 133 } 134 if ( ! empty( $request['timezone'] ) ) { 135 $url_args['timezone'] = $request['timezone']; 136 } 137 138 if ( ! empty( $url_args ) ) { 139 $url = add_query_arg( $url_args, $url ); 140 } 141 142 $response->add_links( array( 143 'events' => array( 144 'href' => $url, 145 'embeddable' => true, 146 ), 147 ) ); 148 149 return $response; 150 } 151 152 /** 153 * Retrieves a community events location schema, conforming to JSON Schema. 154 * 155 * @since 4.8.0 156 * @access public 157 * 158 * @return array Item schema data. 159 */ 160 public function get_item_schema() { 161 return array( 162 '$schema' => 'http://json-schema.org/schema#', 163 'title' => 'community_events_location', 164 'type' => 'object', 165 'properties' => array( 166 'description' => array( 167 'description' => __( 'Location description.' ), 168 'type' => 'string', 169 'context' => array( 'view', 'edit', 'embed' ), 170 'readonly' => true, 171 ), 172 'country' => array( 173 'description' => __( 'Two-letter country code.' ), 174 'type' => 'string', 175 'context' => array( 'view', 'edit', 'embed' ), 176 'readonly' => true, 177 ), 178 'latitude' => array( 179 'description' => __( 'Latitude.' ), 180 'type' => 'number', 181 'context' => array( 'view', 'edit', 'embed' ), 182 'readonly' => true, 183 ), 184 'longitude' => array( 185 'description' => __( 'Longitude.' ), 186 'type' => 'number', 187 'context' => array( 'view', 'edit', 'embed' ), 188 'readonly' => true, 189 ), 190 ), 191 ); 192 } 193 194 /** 195 * Retrieves the params for a single item. 196 * 197 * @since 4.8.0 198 * @access public 199 * 200 * @return array Item parameters. 201 */ 202 public function get_item_params() { 203 return array( 204 'context' => $this->get_context_param( array( 'default' => 'view' ) ), 205 'location' => array( 206 'description' => __( 'Optional city name to help determine the location.' ), 207 'type' => 'string', 208 'default' => '', 209 ), 210 'timezone' => array( 211 'description' => __( 'Optional timezone to help determine the location.' ), 212 'type' => 'string', 213 'default' => '', 214 ), 215 ); 216 } 217 } -
src/wp-includes/script-loader.php
diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php index f1eda9ee38..c02fe73588 100644
function wp_default_scripts( &$scripts ) { 732 732 'current' => __( 'Current Color' ), 733 733 ) ); 734 734 735 $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox', 'wp-util', 'wp-a11y' ), false, 1 );735 $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox', 'wp-util', 'wp-a11y', 'wp-api' ), false, 1 ); 736 736 737 737 $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" ); 738 738 -
src/wp-settings.php
diff --git src/wp-settings.php src/wp-settings.php index d1505c502d..060ab4c782 100644
require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-terms-controller.p 234 234 require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-users-controller.php' ); 235 235 require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-comments-controller.php' ); 236 236 require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-settings-controller.php' ); 237 require( ABSPATH . WPINC . '/rest-api/endpoints/dashboard/class-wp-rest-community-events-events-controller.php' ); 238 require( ABSPATH . WPINC . '/rest-api/endpoints/dashboard/class-wp-rest-community-events-location-controller.php' ); 237 239 require( ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-meta-fields.php' ); 238 240 require( ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-comment-meta-fields.php' ); 239 241 require( ABSPATH . WPINC . '/rest-api/fields/class-wp-rest-post-meta-fields.php' );