Make WordPress Core

Changeset 51046


Ignore:
Timestamp:
05/29/2021 06:41:09 PM (3 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r50950 r51046  
    375375 * @see parse_blocks()
    376376 *
    377  * @param int|string|WP_Post|null $post Optional. Post content, post ID, or post object. Defaults to global $post.
     377 * @param int|string|WP_Post|null $post Optional. Post content, post ID, or post object.
     378 *                                      Defaults to global $post.
    378379 * @return bool Whether the post has blocks.
    379380 */
     
    393394 *
    394395 * This test optimizes for performance rather than strict accuracy, detecting
    395  * the block type exists but not validating its structure. For strict accuracy,
    396  * you should use the block parser on post content.
     396 * whether the block type exists but not validating its structure and not checking
     397 * reusable blocks. For strict accuracy, you should use the block parser on post content.
    397398 *
    398399 * @since 5.0.0
     
    400401 * @see parse_blocks()
    401402 *
    402  * @param string                  $block_name Full Block type to look for.
    403  * @param int|string|WP_Post|null $post Optional. Post content, post ID, or post object. Defaults to global $post.
     403 * @param string                  $block_name Full block type to look for.
     404 * @param int|string|WP_Post|null $post       Optional. Post content, post ID, or post object.
     405 *                                            Defaults to global $post.
    404406 * @return bool Whether the post content contains the specified block.
    405407 */
Note: See TracChangeset for help on using the changeset viewer.