diff -r c7c34916027a -r 177826044cd9 wp/wp-includes/blocks.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wp/wp-includes/blocks.php Mon Oct 14 18:28:13 2019 +0200 @@ -0,0 +1,359 @@ +register( $name, $args ); +} + +/** + * Unregisters a block type. + * + * @since 5.0.0 + * + * @param string|WP_Block_Type $name Block type name including namespace, or alternatively a + * complete WP_Block_Type instance. + * @return WP_Block_Type|false The unregistered block type on success, or false on failure. + */ +function unregister_block_type( $name ) { + return WP_Block_Type_Registry::get_instance()->unregister( $name ); +} + +/** + * Determine whether a post or content string has blocks. + * + * This test optimizes for performance rather than strict accuracy, detecting + * the pattern of a block but not validating its structure. For strict accuracy, + * you should use the block parser on post content. + * + * @since 5.0.0 + * @see parse_blocks() + * + * @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. + */ +function has_blocks( $post = null ) { + if ( ! is_string( $post ) ) { + $wp_post = get_post( $post ); + if ( $wp_post instanceof WP_Post ) { + $post = $wp_post->post_content; + } + } + + return false !== strpos( (string) $post, '