wpseek.com
WordPress开发者和主题制作者的搜索引擎



remove_block_asset_path_prefix › WordPress Function

Since5.5.0
已弃用n/a
remove_block_asset_path_prefix ( $asset_handle_or_path )
参数:
  • (string) $asset_handle_or_path Asset handle or prefixed path.
    Required: Yes
返回:
  • (string) Path without the prefix or the original value.
定义在:
文档:

Removes the block asset's path prefix if provided.



源码

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