Blocks: Add the reusable block post type, `wp_block`.
Merges [43804] from the 5.0 branch to trunk. See #45098. Built from https://develop.svn.wordpress.org/trunk@44146 git-svn-id: http://core.svn.wordpress.org/trunk@43976 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9bbc000c65
commit
3af9743b81
|
@ -200,6 +200,11 @@ $wp_list_table->prepare_items();
|
||||||
wp_enqueue_script( 'inline-edit-post' );
|
wp_enqueue_script( 'inline-edit-post' );
|
||||||
wp_enqueue_script( 'heartbeat' );
|
wp_enqueue_script( 'heartbeat' );
|
||||||
|
|
||||||
|
if ( 'wp_block' === $post_type ) {
|
||||||
|
wp_enqueue_script( 'wp-list-reusable-blocks' );
|
||||||
|
wp_enqueue_style( 'wp-list-reusable-blocks' );
|
||||||
|
}
|
||||||
|
|
||||||
$title = $post_type_object->labels->name;
|
$title = $post_type_object->labels->name;
|
||||||
|
|
||||||
if ( 'post' == $post_type ) {
|
if ( 'post' == $post_type ) {
|
||||||
|
|
|
@ -574,6 +574,23 @@ function map_meta_cap( $cap, $user_id ) {
|
||||||
return call_user_func_array( 'map_meta_cap', $args );
|
return call_user_func_array( 'map_meta_cap', $args );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Block capabilities map to their post equivalent.
|
||||||
|
$block_caps = array(
|
||||||
|
'edit_blocks',
|
||||||
|
'edit_others_blocks',
|
||||||
|
'publish_blocks',
|
||||||
|
'read_private_blocks',
|
||||||
|
'delete_blocks',
|
||||||
|
'delete_private_blocks',
|
||||||
|
'delete_published_blocks',
|
||||||
|
'delete_others_blocks',
|
||||||
|
'edit_private_blocks',
|
||||||
|
'edit_published_blocks',
|
||||||
|
);
|
||||||
|
if ( in_array( $cap, $block_caps, true ) ) {
|
||||||
|
$cap = str_replace( '_blocks', '_posts', $cap );
|
||||||
|
}
|
||||||
|
|
||||||
// If no meta caps match, return the original cap.
|
// If no meta caps match, return the original cap.
|
||||||
$caps[] = $cap;
|
$caps[] = $cap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,6 +252,38 @@ function create_initial_post_types() {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
register_post_type(
|
||||||
|
'wp_block',
|
||||||
|
array(
|
||||||
|
'labels' => array(
|
||||||
|
'name' => __( 'Blocks' ),
|
||||||
|
'singular_name' => __( 'Block' ),
|
||||||
|
'search_items' => __( 'Search Blocks' ),
|
||||||
|
),
|
||||||
|
'public' => false,
|
||||||
|
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
|
||||||
|
'show_ui' => true,
|
||||||
|
'show_in_menu' => false,
|
||||||
|
'rewrite' => false,
|
||||||
|
'capability_type' => 'block',
|
||||||
|
'capabilities' => array(
|
||||||
|
// You need to be able to edit posts, in order to read blocks in their raw form.
|
||||||
|
'read' => 'edit_posts',
|
||||||
|
// You need to be able to publish posts, in order to create blocks.
|
||||||
|
'create_posts' => 'publish_posts',
|
||||||
|
'edit_published_posts' => 'edit_published_posts',
|
||||||
|
'delete_published_posts' => 'delete_published_posts',
|
||||||
|
'edit_others_posts' => 'edit_others_posts',
|
||||||
|
'delete_others_posts' => 'delete_others_posts',
|
||||||
|
),
|
||||||
|
'map_meta_cap' => true,
|
||||||
|
'supports' => array(
|
||||||
|
'title',
|
||||||
|
'editor',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
register_post_status(
|
register_post_status(
|
||||||
'publish',
|
'publish',
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.1-alpha-44145';
|
$wp_version = '5.1-alpha-44146';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue