remove_block_asset_path_prefix

函式
remove_block_asset_path_prefix ( $asset_handle_or_path )
引數
  • (string) $asset_handle_or_path Asset handle or prefixed path.
    Required:
返回值
  • (string) Path without the prefix or the original value.
定義位置
相關方法
resolve_block_templategenerate_block_asset_handle_resolve_home_block_templaterender_block_core_pattern_get_block_template_file
引入
5.5.0
棄用
-

remove_block_asset_path_prefix: 這個函式是用來移除區塊指令碼和樣式的資產路徑字首的: 當你想載入你自己的自定義指令碼和樣式而不使用資產路徑字首時,這個函式很有用。

如果提供的話,刪除資產區塊的路徑字首。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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;
}

常見問題

FAQs
檢視更多 >