Returns relative path to an uploaded font file.
Description
The path is relative to the current fonts directory.
Parameters
$path
stringrequired- Full path to the file.
Source
protected function relative_fonts_path( $path ) {
$new_path = $path;
$fonts_dir = wp_get_font_dir();
if ( str_starts_with( $new_path, $fonts_dir['basedir'] ) ) {
$new_path = str_replace( $fonts_dir['basedir'], '', $new_path );
$new_path = ltrim( $new_path, '/' );
}
return $new_path;
}
Changelog
Version | Description |
---|---|
6.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.