Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



generate_block_asset_handle ›

Seit5.5.0
Veraltetn/v
generate_block_asset_handle ( $block_name, $field_name )
Parameter: (2)
  • (string) $block_name Name of the block.
    Erforderlich: Ja
  • (string) $field_name Name of the metadata field.
    Erforderlich: Ja
Gibt zurück:
  • (string) Generated asset name for the block's field.
Definiert in:
Codex:

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



Quellcode

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 ];
}