wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes



remove_block_asset_path_prefix › WordPress Function

Depuis5.5.0
Dépréciéen/a
remove_block_asset_path_prefix ( $asset_handle_or_path )
Paramètres:
  • (string) $asset_handle_or_path Asset handle or prefixed path.
    Requis: Oui
Retourne:
  • (string) Path without the prefix or the original value.
Défini(e) dans:
Codex:

Removes the block asset's path prefix if provided.



Source

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