mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-03 04:04:35 +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:
@@ -262,3 +262,17 @@ function _recurse_do_blocks( $blocks, $all_blocks ) {
|
||||
|
||||
return $rendered_content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current version of the block format that the content string is using.
|
||||
*
|
||||
* If the string doesn't contain blocks, it returns 0.
|
||||
*
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param string $content Content to test.
|
||||
* @return int The block format version.
|
||||
*/
|
||||
function block_version( $content ) {
|
||||
return has_blocks( $content ) ? 1 : 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user