Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp_get_font_dir(): Bail if the 'font_dir' filter is already running. #6198

Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/wp-includes/fonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) ) {
matiasbenedetto marked this conversation as resolved.
Show resolved Hide resolved
return $defaults;
}

$site_path = '';
if ( is_multisite() && ! ( is_main_network() && is_main_site() ) ) {
$site_path = '/sites/' . get_current_blog_id();
Expand All @@ -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 );
costdev marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
Loading