From 56b5a2ff831eeb6e2a9bb9190ea6912c6bda2eb9 Mon Sep 17 00:00:00 2001 From: Matias Benedetto Date: Wed, 28 Feb 2024 10:10:45 -0300 Subject: [PATCH 1/3] wp_get_font_dir(): Bail if the 'font_dir' filter is already running. This avoids an infinite loop that can occur if wp_upload_dir() is called inside a 'font_dir' callback. Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com> --- src/wp-includes/fonts.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/fonts.php b/src/wp-includes/fonts.php index 953898136300e..5222329dfefd3 100644 --- a/src/wp-includes/fonts.php +++ b/src/wp-includes/fonts.php @@ -118,6 +118,16 @@ function wp_unregister_font_collection( string $slug ) { * } */ function wp_get_font_dir( $defaults = array() ) { + /* + * Bail if the 'font_dir' filter is already running. + * + * This avoids an infinite loop that can occur + * if wp_upload_dir() is called inside a 'font_dir' callback. + */ + if ( doing_filter( 'font_dir' ) ) { + return $defaults; + } + $site_path = ''; if ( is_multisite() && ! ( is_main_network() && is_main_site() ) ) { $site_path = '/sites/' . get_current_blog_id(); @@ -140,7 +150,7 @@ function wp_get_font_dir( $defaults = array() ) { * * @param array $defaults The original fonts directory data. */ - return apply_filters( 'font_dir', $defaults ); + return doing_filter( 'font_dir' ) ? $defaults : apply_filters( 'font_dir', $defaults ); } /** From eee4f2d7a5172741d7cb5639e3c8808ef1ff3732 Mon Sep 17 00:00:00 2001 From: Matias Benedetto Date: Wed, 28 Feb 2024 10:30:30 -0300 Subject: [PATCH 2/3] format php --- src/wp-includes/fonts.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/fonts.php b/src/wp-includes/fonts.php index 5222329dfefd3..f06d2cc62a4dc 100644 --- a/src/wp-includes/fonts.php +++ b/src/wp-includes/fonts.php @@ -127,7 +127,7 @@ function wp_get_font_dir( $defaults = array() ) { if ( doing_filter( 'font_dir' ) ) { return $defaults; } - + $site_path = ''; if ( is_multisite() && ! ( is_main_network() && is_main_site() ) ) { $site_path = '/sites/' . get_current_blog_id(); From 96c7060a67c2ec1060b72a080b4bc1f3b3590d1f Mon Sep 17 00:00:00 2001 From: Matias Benedetto Date: Wed, 28 Feb 2024 13:32:08 -0300 Subject: [PATCH 3/3] fix comment formatting Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com> --- src/wp-includes/fonts.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/fonts.php b/src/wp-includes/fonts.php index f06d2cc62a4dc..9c928c9b81cee 100644 --- a/src/wp-includes/fonts.php +++ b/src/wp-includes/fonts.php @@ -119,11 +119,11 @@ function wp_unregister_font_collection( string $slug ) { */ function wp_get_font_dir( $defaults = array() ) { /* - * Bail if the 'font_dir' filter is already running. - * - * This avoids an infinite loop that can occur - * if wp_upload_dir() is called inside a 'font_dir' callback. - */ + * Bail if the 'font_dir' filter is already running. + * + * This avoids an infinite loop that can occur + * if wp_upload_dir() is called inside a 'font_dir' callback. + */ if ( doing_filter( 'font_dir' ) ) { return $defaults; }