wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



remove_block_asset_path_prefix › WordPress Function

Seit5.5.0
Veraltetn/v
remove_block_asset_path_prefix ( $asset_handle_or_path )
Parameter:
  • (string) $asset_handle_or_path Asset handle or prefixed path.
    Erforderlich: Ja
Gibt zurück:
  • (string) Path without the prefix or the original value.
Definiert in:
Codex:

Removes the block asset's path prefix if provided.



Quellcode

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;
}