函数原型
remove_block_asset_path_prefix( string $asset_handle_or_path ): string
函数描述
Removes the block asset’s path prefix if provided.
是否弃用
未弃用
函数参数
-
$asset_handle_or_path
string
Required - Asset handle or prefixed path.
函数返回值
string Path without the prefix or the original value.
函数位置
File: wp-includes/blocks.php.
函数源码
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;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 5.5.0 | Introduced. |

