Make WordPress Core


Ignore:
Timestamp:
12/14/2018 02:34:28 AM (8 years ago)
Author:
jeremyfelt
Message:

REST API: Add endpoints for blocks.

WP_REST_Block_Renderer_Controller allows rendering of server-side rendered blocks, whilst WP_REST_Blocks_Controller allows retrieving of reusable blocks.

Merges [43805] and [43806] from the 5.0 branch to trunk.

Props desrosj, danielbachhuber, pento, Presskopp, swissspidy.
See #45065, #45098.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-includes/post.php

    r44146 r44150  
    256256                'wp_block',
    257257                array(
    258                         'labels'          => array(
     258                        'labels'                => array(
    259259                                'name'          => __( 'Blocks' ),
    260260                                'singular_name' => __( 'Block' ),
    261261                                'search_items'  => __( 'Search Blocks' ),
    262262                        ),
    263                         'public'          => false,
    264                         '_builtin'        => true, /* internal use only. don't use this when registering your own post type. */
    265                         'show_ui'         => true,
    266                         'show_in_menu'    => false,
    267                         'rewrite'         => false,
    268                         'capability_type' => 'block',
    269                         'capabilities'    => array(
     263                        'public'                => false,
     264                        '_builtin'              => true, /* internal use only. don't use this when registering your own post type. */
     265                        'show_ui'               => true,
     266                        'show_in_menu'          => false,
     267                        'rewrite'               => false,
     268                        'show_in_rest'          => true,
     269                        'rest_base'             => 'blocks',
     270                        'rest_controller_class' => 'WP_REST_Blocks_Controller',
     271                        'capability_type'       => 'block',
     272                        'capabilities'          => array(
    270273                                // You need to be able to edit posts, in order to read blocks in their raw form.
    271274                                'read'                   => 'edit_posts',
    … …  
    277280                                'delete_others_posts'    => 'delete_others_posts',
    278281                        ),
    279                         'map_meta_cap'    => true,
    280                         'supports'        => array(
     282                        'map_meta_cap'          => true,
     283                        'supports'              => array(
    281284                                'title',
    282285                                'editor',
Note: See TracChangeset for help on using the changeset viewer.