[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/ -> blocks.php (summary)

Functions related to registering and parsing blocks.

File Size: 386 lines (11 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 14 functions

  register_block_type()
  unregister_block_type()
  has_blocks()
  has_block()
  get_dynamic_block_names()
  excerpt_remove_blocks()
  _excerpt_render_inner_columns_blocks()
  render_block()
  parse_blocks()
  do_blocks()
  _restore_wpautop_hook()
  block_version()
  register_block_style()
  unregister_block_style()

Functions
Functions that are not part of a class:

register_block_type( $name, $args = array()   X-Ref
Registers a block type.

param: string|WP_Block_Type $name Block type name including namespace, or alternatively a
param: array                $args {
return: WP_Block_Type|false The registered block type on success, or false on failure.
since: 5.0.0

unregister_block_type( $name )   X-Ref
Unregisters a block type.

param: string|WP_Block_Type $name Block type name including namespace, or alternatively a
return: WP_Block_Type|false The unregistered block type on success, or false on failure.
since: 5.0.0

has_blocks( $post = null )   X-Ref
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.

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.
since: 5.0.0

has_block( $block_type, $post = null )   X-Ref
Determine whether a $post or a string contains a specific block type.

This test optimizes for performance rather than strict accuracy, detecting
the block type exists but not validating its structure. For strict accuracy,
you should use the block parser on post content.

param: string                  $block_type 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.
return: bool Whether the post content contains the specified block.
since: 5.0.0

get_dynamic_block_names()   X-Ref
Returns an array of the names of all registered dynamic block types.

return: string[] Array of dynamic block names.
since: 5.0.0

excerpt_remove_blocks( $content )   X-Ref
Parses blocks out of a content string, and renders those appropriate for the excerpt.

As the excerpt should be a small string of text relevant to the full post content,
this function renders the blocks that are most likely to contain such text.

param: string $content The content to parse.
return: string The parsed and filtered content.
since: 5.0.0

_excerpt_render_inner_columns_blocks( $columns, $allowed_blocks )   X-Ref
Render inner blocks from the `core/columns` block for generating an excerpt.

param: array $columns        The parsed columns block.
param: array $allowed_blocks The list of allowed inner blocks.
return: string The rendered inner blocks.
since: 5.2.0

render_block( $block )   X-Ref
Renders a single block into a HTML string.

param: array $block A single parsed block object.
return: string String of rendered HTML.
since: 5.0.0

parse_blocks( $content )   X-Ref
Parses blocks out of a content string.

param: string $content Post content.
return: array[] Array of parsed block objects.
since: 5.0.0

do_blocks( $content )   X-Ref
Parses dynamic blocks out of `post_content` and re-renders them.

param: string $content Post content.
return: string Updated post content.
since: 5.0.0

_restore_wpautop_hook( $content )   X-Ref
If do_blocks() needs to remove wpautop() from the `the_content` filter, this re-adds it afterwards,
for subsequent `the_content` usage.

param: string $content The post content running through this filter.
return: string The unmodified content.
since: 5.0.0

block_version( $content )   X-Ref
Returns the current version of the block format that the content string is using.

If the string doesn't contain blocks, it returns 0.

param: string $content Content to test.
return: int The block format version is 1 if the content contains one or more blocks, 0 otherwise.
since: 5.0.0

register_block_style( $block_name, $style_properties )   X-Ref
Registers a new block style.

param: string $block_name       Block type name including namespace.
param: array  $style_properties Array containing the properties of the style name, label, style (name of the stylesheet to be enqueued), inline_style (string containing the CSS to be added).
return: boolean True if the block style was registered with success and false otherwise.
since: 5.3.0

unregister_block_style( $block_name, $block_style_name )   X-Ref
Unregisters a block style.

param: string $block_name       Block type name including namespace.
param: array  $block_style_name Block style name.
return: boolean True if the block style was unregistered with success and false otherwise.
since: 5.3.0



Generated: Sun Nov 17 01:00:03 2019 Cross-referenced by PHPXref 0.7.1