-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
wp_get_font_dir(): Bail if the 'font_dir' filter is already running. #6198
Conversation
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>
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
The one thing I don't like about Things would be much easier if it would behave more like e.g.
|
@swissspidy I' don't see how function wp_privacy_exports_dir() {
$upload_dir = wp_upload_dir();
$exports_dir = trailingslashit( $upload_dir['basedir'] ) . 'wp-personal-data-exports/';
return apply_filters( 'wp_privacy_exports_dir', $exports_dir );
} function wp_get_font_dir( $defaults = array() ) {
$site_path = '';
if ( is_multisite() && ! ( is_main_network() && is_main_site() ) ) {
$site_path = '/sites/' . get_current_blog_id();
}
// Sets the defaults.
$defaults['path'] = path_join( WP_CONTENT_DIR, 'fonts' ) . $site_path;
$defaults['url'] = untrailingslashit( content_url( 'fonts' ) ) . $site_path;
$defaults['subdir'] = '';
$defaults['basedir'] = path_join( WP_CONTENT_DIR, 'fonts' ) . $site_path;
$defaults['baseurl'] = untrailingslashit( content_url( 'fonts' ) ) . $site_path;
$defaults['error'] = false;
return apply_filters( 'font_dir', $defaults );
} I think wordpress-develop/src/wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.php Line 859 in a69052a
@swissspidy @costdev What do you think about this alternative WordPress/gutenberg#58839 to avoid the infinite loop this PR is trying to fix? |
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
This is exactly what I suggested in my comment :)
That's exactly what I said is confusing :) |
Yeah, the alternative looks better to me, nice! |
@swissspidy @costdev, if the alternative approach is looking better, could you please add a review in that PR? |
Closing this PR in favor of: #6200 |
What?
wp_get_font_dir()
: Bail if thefont_dir
filter is already running.Props to @costdev for proposing this solution.
Why?
This avoids an infinite loop that can occur if wp_upload_dir() is called inside a 'font_dir' callback.
Testing instructions
wp_get_upload_dir()
inside a function used to filterupload_dir
as in the following example:(
wp-content/uploads/fonts
in the example provided).Trac ticket: https://core.trac.wordpress.org/ticket/60652