Docs: Document that `has_block()` does not check reusable blocks.
Since the function only checks the raw, non-parsed post content, reusable blocks are just a `core/block` type and nothing more at that point. In order to also check reusable blocks, the content needs to be parsed using `parse_blocks()` first. Props vyskoczilova, peterwilsoncc. Fixes #53140. Built from https://develop.svn.wordpress.org/trunk@51046 git-svn-id: http://core.svn.wordpress.org/trunk@50655 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
086edc3d12
commit
fedbeb2f3c
|
@ -374,7 +374,8 @@ function unregister_block_type( $name ) {
|
||||||
*
|
*
|
||||||
* @see parse_blocks()
|
* @see parse_blocks()
|
||||||
*
|
*
|
||||||
* @param int|string|WP_Post|null $post Optional. Post content, post ID, or post object. Defaults to global $post.
|
* @param int|string|WP_Post|null $post Optional. Post content, post ID, or post object.
|
||||||
|
* Defaults to global $post.
|
||||||
* @return bool Whether the post has blocks.
|
* @return bool Whether the post has blocks.
|
||||||
*/
|
*/
|
||||||
function has_blocks( $post = null ) {
|
function has_blocks( $post = null ) {
|
||||||
|
@ -392,15 +393,16 @@ function has_blocks( $post = null ) {
|
||||||
* Determine whether a $post or a string contains a specific block type.
|
* Determine whether a $post or a string contains a specific block type.
|
||||||
*
|
*
|
||||||
* This test optimizes for performance rather than strict accuracy, detecting
|
* This test optimizes for performance rather than strict accuracy, detecting
|
||||||
* the block type exists but not validating its structure. For strict accuracy,
|
* whether the block type exists but not validating its structure and not checking
|
||||||
* you should use the block parser on post content.
|
* reusable blocks. For strict accuracy, you should use the block parser on post content.
|
||||||
*
|
*
|
||||||
* @since 5.0.0
|
* @since 5.0.0
|
||||||
*
|
*
|
||||||
* @see parse_blocks()
|
* @see parse_blocks()
|
||||||
*
|
*
|
||||||
* @param string $block_name Full Block type to look for.
|
* @param string $block_name Full block type to look for.
|
||||||
* @param int|string|WP_Post|null $post Optional. Post content, post ID, or post object. Defaults to global $post.
|
* @param int|string|WP_Post|null $post Optional. Post content, post ID, or post object.
|
||||||
|
* Defaults to global $post.
|
||||||
* @return bool Whether the post content contains the specified block.
|
* @return bool Whether the post content contains the specified block.
|
||||||
*/
|
*/
|
||||||
function has_block( $block_name, $post = null ) {
|
function has_block( $block_name, $post = null ) {
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.8-alpha-51045';
|
$wp_version = '5.8-alpha-51046';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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