Skip to content

Commit 27d4937

Browse files
committed
Editor (Font Library): Store font subdirectory in post meta.
Stores the font file sub-directory in the `wp_font_face` post meta. Similar to attachments, only the portion of the path relative to the base directory is stored. This ensures the files can be deleted alongside their post on sites using a plugin to store font files in sub-directories. Previously running such a plugin would result in the files remaining on the file system post delete. Props costdev, grantmkin, peterwilsoncc. Fixes #61297. Built from https://develop.svn.wordpress.org/trunk@58353 git-svn-id: https://core.svn.wordpress.org/trunk@57805 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent 92a8165 commit 27d4937

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

wp-includes/fonts.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ function _wp_before_delete_font_face( $post_id, $post ) {
230230
}
231231

232232
$font_files = get_post_meta( $post_id, '_wp_font_face_file', false );
233-
$font_dir = wp_get_font_dir()['path'];
233+
$font_dir = untrailingslashit( wp_get_font_dir()['basedir'] );
234234

235235
foreach ( $font_files as $font_file ) {
236236
wp_delete_file( $font_dir . '/' . $font_file );

wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,8 @@ protected function relative_fonts_path( $path ) {
916916
$new_path = $path;
917917

918918
$fonts_dir = wp_get_font_dir();
919-
if ( str_starts_with( $new_path, $fonts_dir['path'] ) ) {
920-
$new_path = str_replace( $fonts_dir, '', $new_path );
919+
if ( str_starts_with( $new_path, $fonts_dir['basedir'] ) ) {
920+
$new_path = str_replace( $fonts_dir['basedir'], '', $new_path );
921921
$new_path = ltrim( $new_path, '/' );
922922
}
923923

wp-includes/version.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '6.6-beta1-58352';
19+
$wp_version = '6.6-beta1-58353';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)