WP_REST_Font_Faces_Controller::relative_fonts_path( string $path ): string

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Returns relative path to an uploaded font file.

Description

The path is relative to the current fonts directory.

Parameters

$pathstringrequired
Full path to the file.

Return

string Relative path on success, unchanged path on failure.

Source

protected function relative_fonts_path( $path ) {
	$new_path = $path;

	$fonts_dir = wp_get_font_dir();
	if ( str_starts_with( $new_path, $fonts_dir['path'] ) ) {
		$new_path = str_replace( $fonts_dir, '', $new_path );
		$new_path = ltrim( $new_path, '/' );
	}

	return $new_path;
}

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.