remove_block_asset_path_prefix()WP 5.5.0

Removes the block asset's path prefix if provided.

Хуков нет.

Возвращает

Строку. Path without the prefix or the original value.

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

remove_block_asset_path_prefix( $asset_handle_or_path );
$asset_handle_or_path(строка) (обязательный)
Asset handle or prefixed path.

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

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

Код remove_block_asset_path_prefix() WP 6.0.2

function remove_block_asset_path_prefix( $asset_handle_or_path ) {
	$path_prefix = 'file:';
	if ( 0 !== strpos( $asset_handle_or_path, $path_prefix ) ) {
		return $asset_handle_or_path;
	}
	$path = substr(
		$asset_handle_or_path,
		strlen( $path_prefix )
	);
	if ( strpos( $path, './' ) === 0 ) {
		$path = substr( $path, 2 );
	}
	return $path;
}