WP_Block_Supports
- Since
- 5.6.0
- Source
wp-includes/class-wp-block-supports.php:17
Class encapsulating and implementing Block Supports.
Compatibility
- WordPress
- since 5.6.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).
Properties · 3
$block_supportsarrayprivate- Config.
$block_to_renderarraypublic static- Tracks the current block to be rendered.
$instanceWP_Block_Supports|nullprivate static- Container for the main instance of the class.
Methods · 5
- get_instance()Utility method to retrieve the main instance of the class.
- init()Initializes the block supports. It registers the block supports block attributes.
- register()Registers a block support.
- apply_block_supports()Generates an array of HTML attributes, such as classes, by applying to the given block all of the features that the block supports.
- register_attributes()Registers the block attributes required by the different block supports.
Source code
#[AllowDynamicProperties]class WP_Block_Supports { /** * Config. * * @since 5.6.0 * @var array */ private $block_supports = array(); /** * Tracks the current block to be rendered. * * @since 5.6.0 * @var array */ public static $block_to_render = null; /** * Container for the main instance of the class. * * @since 5.6.0 * @var WP_Block_Supports|null */ private static $instance = null; /** * Utility method to retrieve the main instance of the class. * * The instance will be created if it does not exist yet. * * @since 5.6.0 * * @return WP_Block_Supports The main instance. */ public static function get_instance() { if ( null === self::$instance ) { self::$instance = new self(); } return self::$instance; } /** * Initializes the block supports. It registers the block supports block attributes. * * @since 5.6.0 */ public static function init() { $instance = self::get_instance(); $instance->register_attributes(); } /** * Registers a block support. * * @since 5.6.0 * * @link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/ * * @param string $block_support_name Block support name. * @param array $block_support_config Array containing the properties of the block support. */ public function register( $block_support_name, $block_support_config ) { $this->block_supports[ $block_support_name ] = array_merge( $block_support_config, array( 'name' => $block_support_name ) ); } /** * Generates an array of HTML attributes, such as classes, by applying to * the given block all of the features that the block supports. * * @since 5.6.0 * * @return string[] Array of HTML attribute values keyed by their name. */ public function apply_block_supports() {Changelog
Introduced in 5.6.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/class-wp-block-supports.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.