mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
REST API: Include block_version on Post content object.
The `block_version` denotes which version of Blocks the `post_content` contains. Introduces new `block_version()` function for versioning Blocks. Merges [43770] from the 5.0 branch to trunk. Props danielbachhuber, birgire. Fixes #43887. git-svn-id: https://develop.svn.wordpress.org/trunk@44127 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1521,10 +1521,11 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
|
||||
if ( in_array( 'content', $fields, true ) ) {
|
||||
$data['content'] = array(
|
||||
'raw' => $post->post_content,
|
||||
'raw' => $post->post_content,
|
||||
/** This filter is documented in wp-includes/post-template.php */
|
||||
'rendered' => post_password_required( $post ) ? '' : apply_filters( 'the_content', $post->post_content ),
|
||||
'protected' => (bool) $post->post_password,
|
||||
'rendered' => post_password_required( $post ) ? '' : apply_filters( 'the_content', $post->post_content ),
|
||||
'protected' => (bool) $post->post_password,
|
||||
'block_version' => block_version( $post->post_content ),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2062,18 +2063,24 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database()
|
||||
),
|
||||
'properties' => array(
|
||||
'raw' => array(
|
||||
'raw' => array(
|
||||
'description' => __( 'Content for the object, as it exists in the database.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'edit' ),
|
||||
),
|
||||
'rendered' => array(
|
||||
'rendered' => array(
|
||||
'description' => __( 'HTML content for the object, transformed for display.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'protected' => array(
|
||||
'block_version' => array(
|
||||
'description' => __( 'Version of the content block format used by the object.' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'protected' => array(
|
||||
'description' => __( 'Whether the content is protected with a password.' ),
|
||||
'type' => 'boolean',
|
||||
'context' => array( 'view', 'edit', 'embed' ),
|
||||
|
||||
Reference in New Issue
Block a user