WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

register_block_script_handle() WP 5.5.0

Finds a script handle for the selected block metadata field. It detects when a path to file was provided and finds a corresponding asset file with details necessary to register the script under automatically generated handle name. It returns unprocessed script handle otherwise.

Хуков нет.

Возвращает

Строку/true/false. Script handle provided directly or created through script's registration, or false on failure.

Использование

register_block_script_handle( $metadata, $field_name );
$metadata(массив) (обязательный)
Block metadata.
$field_name(строка) (обязательный)
Field name to pick from metadata.

Список изменений

С версии 5.5.0 Введена.

Код register_block_script_handle() WP 5.5.3

<?php
function register_block_script_handle( $metadata, $field_name ) {
	if ( empty( $metadata[ $field_name ] ) ) {
		return false;
	}
	$script_handle = $metadata[ $field_name ];
	$script_path   = remove_block_asset_path_prefix( $metadata[ $field_name ] );
	if ( $script_handle === $script_path ) {
		return $script_handle;
	}

	$script_handle     = generate_block_asset_handle( $metadata['name'], $field_name );
	$script_asset_path = realpath(
		dirname( $metadata['file'] ) . '/' .
		substr_replace( $script_path, '.asset.php', - strlen( '.js' ) )
	);
	if ( ! file_exists( $script_asset_path ) ) {
		$message = sprintf(
			/* translators: %1: field name. %2: block name */
			__( 'The asset file for the "%1$s" defined in "%2$s" block definition is missing.', 'default' ),
			$field_name,
			$metadata['name']
		);
		_doing_it_wrong( __FUNCTION__, $message, '5.5.0' );
		return false;
	}
	$script_asset = require $script_asset_path;
	$result       = wp_register_script(
		$script_handle,
		plugins_url( $script_path, $metadata['file'] ),
		$script_asset['dependencies'],
		$script_asset['version']
	);
	return $result ? $script_handle : false;
}