wp_apply_generated_classname_support()WP 5.6.0

Adds the generated classnames to the output.

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

No Hooks.

Return

Array. Block CSS classes and inline styles.

Usage

wp_apply_generated_classname_support( $block_type );
$block_type(WP_Block_Type) (required)
Block Type.

Changelog

Since 5.6.0 Introduced.

wp_apply_generated_classname_support() code WP 6.4.3

function wp_apply_generated_classname_support( $block_type ) {
	$attributes                      = array();
	$has_generated_classname_support = block_has_support( $block_type, 'className', true );
	if ( $has_generated_classname_support ) {
		$block_classname = wp_get_block_default_classname( $block_type->name );

		if ( $block_classname ) {
			$attributes['class'] = $block_classname;
		}
	}

	return $attributes;
}