generate_block_asset_handle

Advertisement

Summery Summery

Generates the name for an asset based on the name of the block and the field name provided.

Syntax Syntax

generate_block_asset_handle( string $block_name, string $field_name )

Parameters Parameters

$block_name

(string) (Required) Name of the block.

$field_name

(string) (Required) Name of the metadata field.

Return Return

(string) Generated asset name for the block's field.

Source Source

File: wp-includes/blocks.php

function generate_block_asset_handle( $block_name, $field_name ) {
	$field_mappings = array(
		'editorScript' => 'editor-script',
		'script'       => 'script',
		'editorStyle'  => 'editor-style',
		'style'        => 'style',
	);
	return str_replace( '/', '-', $block_name ) .
		'-' . $field_mappings[ $field_name ];
}

Advertisement

Changelog Changelog

Changelog
Version Description
5.5.0 Introduced.

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.