[wp-trac] [WordPress Trac] #35574: Add REST API JSON schema information to WP_Widget

WordPress Trac noreply at wordpress.org
Mon Apr 10 22:43:11 UTC 2017


#35574: Add REST API JSON schema information to WP_Widget
------------------------------------------+-----------------------------
 Reporter:  westonruter                   |       Owner:
     Type:  enhancement                   |      Status:  new
 Priority:  normal                        |   Milestone:  Future Release
Component:  Widgets                       |     Version:  2.8
 Severity:  normal                        |  Resolution:
 Keywords:  needs-patch needs-unit-tests  |     Focuses:  rest-api
------------------------------------------+-----------------------------

Comment (by westonruter):

 Humm, maybe we should rename a `WP_Widget::get_instance_schema()` method
 to `WP_Media::get_item_schema()` for parity with
 `WP_REST_Controller::get_item_schema()`.

 The return value for this function is essentially the schema for the
 `properties`: https://github.com/xwp/wp-core-media-
 widgets/blob/994d40f25467591773e76d111bfcc806b351fd40/wp-includes/widgets
 /class-wp-widget-media.php#L91-L120

 In that case perhaps it should be `WP_Widget::get_properties_schema()`?

 Or then again, is this being short-sighted by not including the level
 above `properties`, namely:

 {{{#!php
 '$schema' => 'http://json-schema.org/schema#',
 'title' => $this->id_base . '-widget',
 'type' => 'object',
 'properties' => array( /* existing array returned by get_instance_schema
 */ )
 }}}

 I guess the idea here is that eventually when we have a full-on
 `WP_REST_Widgets_Controller`, that these root-level schema properties
 would be supplied there and the `WP_Widget::get_instance_schema()` would
 essentially be serving the same purpose as
 `\WP_REST_Controller::get_additional_fields()`.

 Thoughts from REST API team?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35574#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list