wppaste
WordPress

WP_Block_Type

Since
5.0.0
Source
wp-includes/class-wp-block-type.php:17
Core class representing a block type.

Compatibility

WordPress
since 5.0.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 3

Every hook that fires from inside WP_Block_Type, in the order it appears in the class, grouped by the method that fires it.

Properties · 30

$api_versionintpublic
Block API version.
$namestringpublic
Block type key.
$titlestringpublic
Human-readable block type label.
$categorystring|nullpublic
Block type category classification, used in search interfaces to arrange block types by category.
$parentstring[]|nullpublic
Setting parent lets a block require that it is only available when nested within the specified blocks.
$ancestorstring[]|nullpublic
Setting ancestor makes a block available only inside the specified block types at any position of the ancestor's block subtree.
$allowed_blocksstring[]|nullpublic
Limits which block types can be inserted as children of this block type.
$iconstring|nullpublic
Block type icon.
$descriptionstringpublic
A detailed block type description.
$keywordsstring[]public
Additional keywords to produce block type as result in search interfaces.
$textdomainstring|nullpublic
The translation textdomain.
$stylesarraypublic
Alternative block styles.
$variationsarray[]|nullprivate
Block variations.
$variation_callbackcallable|nullpublic
Block variations callback.
$selectorsarraypublic
Custom CSS selectors for theme.json style generation.
$supportsarray|nullpublic
Supported features.
$examplearray|nullpublic
Structured data for the block preview.
$render_callbackcallablepublic
Block type render callback.
$attributesarray|nullpublic
Block type attributes property schemas.
$uses_contextstring[]private
Context values inherited by blocks of this type.
$provides_contextstring[]|nullpublic
Context provided by blocks of this type.
$block_hooksstring[]public
Block hooks for this block type.
$editor_script_handlesstring[]public
Block type editor only script handles.
$script_handlesstring[]public
Block type front end and editor script handles.
$view_script_handlesstring[]public
Block type front end only script handles.
$view_script_module_idsstring[]public
Block type front end only script module IDs.
$editor_style_handlesstring[]public
Block type editor only style handles.
$style_handlesstring[]public
Block type front end and editor style handles.
$view_style_handlesstring[]public
Block type front end only style handles.
$deprecated_propertiesstring[]private
Deprecated block type properties for script and style handles.

Methods · 11

  • __construct()Constructor.
  • __get()Proxies getting values for deprecated properties for script and style handles for backward compatibility.
  • __isset()Proxies checking for deprecated properties for script and style handles for backward compatibility.
  • __set()Proxies setting values for deprecated properties for script and style handles for backward compatibility.
  • render()Renders the block type output for given attributes.
  • is_dynamic()Returns true if the block type is dynamic, or false otherwise. A dynamic block is one which defers its rendering to occur on-demand at runtime.
  • prepare_attributes_for_render()Validates attributes against the current block schema, populating defaulted and missing values.
  • set_props()Sets block type properties.
  • get_attributes()Get all available block attributes including possible layout attribute from Columns block.
  • get_variations()Get block variations.
  • get_uses_context()Get block uses context.

Source code

#[AllowDynamicProperties]class WP_Block_Type { 	/**	 * Block API version.	 *	 * @since 5.6.0	 * @var int	 */	public $api_version = 1; 	/**	 * Block type key.	 *	 * @since 5.0.0	 * @var string	 */	public $name; 	/**	 * Human-readable block type label.	 *	 * @since 5.5.0	 * @var string	 */	public $title = ''; 	/**	 * Block type category classification, used in search interfaces	 * to arrange block types by category.	 *	 * @since 5.5.0	 * @var string|null	 */	public $category = null; 	/**	 * Setting parent lets a block require that it is only available	 * when nested within the specified blocks.	 *	 * @since 5.5.0	 * @var string[]|null	 */	public $parent = null; 	/**	 * Setting ancestor makes a block available only inside the specified	 * block types at any position of the ancestor's block subtree.	 *	 * @since 6.0.0	 * @var string[]|null	 */	public $ancestor = null; 	/**	 * Limits which block types can be inserted as children of this block type.	 *	 * @since 6.5.0	 * @var string[]|null	 */	public $allowed_blocks = null; 	/**	 * Block type icon.	 *	 * @since 5.5.0	 * @var string|null	 */	public $icon = null; 	/**	 * A detailed block type description.	 *	 * @since 5.5.0	 * @var string	 */	public $description = ''; 	/**	 * Additional keywords to produce block type as result

Changelog

Introduced in 5.0.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-includes/class-wp-block-type.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.