A WordPress-centric search engine for devs and theme authors



wp_register_typography_support ›

Sincen/a
Deprecatedn/a
wp_register_typography_support ( $block_type )
Access:
  • private
Parameters:
  • (WP_Block_Type) $block_type Block Type.
    Required: Yes
Defined at:
Codex:

Registers the style and typography block attributes for block types that support it.



Source

function wp_register_typography_support( $block_type ) {
	$has_font_size_support = false;
	if ( property_exists( $block_type, 'supports' ) ) {
		$has_font_size_support = wp_array_get( $block_type->supports, array( '__experimentalFontSize' ), false );
	}

	$has_line_height_support = false;
	if ( property_exists( $block_type, 'supports' ) ) {
		$has_line_height_support = wp_array_get( $block_type->supports, array( '__experimentalLineHeight' ), false );
	}

	if ( ! $block_type->attributes ) {
		$block_type->attributes = array();
	}

	if ( ( $has_font_size_support || $has_line_height_support ) && ! array_key_exists( 'style', $block_type->attributes ) ) {
		$block_type->attributes['style'] = array(
			'type' => 'object',
		);
	}

	if ( $has_font_size_support && ! array_key_exists( 'fontSize', $block_type->attributes ) ) {
		$block_type->attributes['fontSize'] = array(
			'type' => 'string',
		);
	}
}