[wp-trac] [WordPress Trac] #47620: REST API: Expose blocks registered on the server

WordPress Trac noreply at wordpress.org
Wed Nov 6 09:31:18 UTC 2019


#47620: REST API: Expose blocks registered on the server
-------------------------------------------------+-------------------------
 Reporter:  gziolo                               |       Owner:
                                                 |  spacedmonkey
     Type:  feature request                      |      Status:  assigned
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  REST API                             |     Version:  5.0
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests dev-        |     Focuses:  rest-api
  feedback                                       |
-------------------------------------------------+-------------------------

Comment (by gziolo):

 > - What fields should be exposed in the api?

 You can see the full Block API which should be exposed to the client in
 https://github.com/WordPress/gutenberg/blob/master/docs/rfc/block-
 registration.md#block-api.

 The gist of it is presented in the following example:


 {{{
 {
         "name": "my-plugin/notice",
         "title": "Notice",
         "category": "common",
         "parent": [ "core/group" ],
         "icon": "star",
         "description": "Shows warning, error or success notices  ...",
         "keywords": [ "alert", "message" ],
         "textDomain": "my-plugin",
         "attributes": {
                 "message": {
                         "type": "string",
                         "source": "html",
                         "selector": ".message"
                 }
         },
         "styleVariations": [
                 { "name": "default", "label": "Default", "isDefault": true
 },
                 { "name": "other", "label": "Other" }
         ],
         "editorScript": "build/editor.js",
         "script": "build/main.js",
         "editorStyle": "build/editor.css",
         "style": "build/style.css"
 }
 }}}

 I think some of the fields are missing in your initial diff.

 > What permissions should be required to access this fields?

 That's a great question. I don't know myself. I can share for reference
 the implementation of the endpoint for the Block Directory:
 https://github.com/WordPress/gutenberg/blob/b138818dd4860151eb345606b1396a198572aefa/lib
 /class-wp-rest-block-directory-controller.php#L76-L85

 It doesn't look like it checks the permission for accessing blocks. /cc
 @tellyworth

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


More information about the wp-trac mailing list