-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Font Library: add wp_get_font_dir() function. #57730
Conversation
This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress. If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged. If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack. Thank you! ❤️ View changed files❔ lib/experimental/fonts/font-library/class-wp-font-family.php ❔ lib/experimental/fonts/font-library/class-wp-font-library.php ❔ lib/experimental/fonts/font-library/class-wp-rest-font-families-controller.php ❔ lib/experimental/fonts/font-library/font-library.php ❔ phpunit/tests/fonts/font-library/wpFontFamily/base.php ❔ phpunit/tests/fonts/font-library/wpRestFontFamiliesController/base.php ❔ phpunit/tests/fonts/font-library/fontsDir.php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still works as expected and tests pass, I left a couple minor comments.
* | ||
* @type string $path Base directory and subdirectory or full path to the fonts upload directory. | ||
* @type string $url Base URL and subdirectory or absolute URL to the fonts upload directory. | ||
* @type string $subdir Subdirectory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I should have asked in the previous PR, but are we including $subdir just to match the wp_upload_dir function? What is the use for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think we should include the subdir
property to match wp_get_upload_dir()
because we are using the output of this function to update upload_dir
filter before uploading fonts. Currently, we are not using it in the font library related code. It is used just in core's _wp_upload_dir
to set the /year/month
sub directory:
} | ||
|
||
// Sets the defaults. | ||
$defaults['path'] = path_join( WP_CONTENT_DIR, 'fonts' ) . $site_path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function and filter are named singularly (font_dir
), but the default path is plural (fonts
). Does it make sense that these are different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so because we are following the pattern from core, the filter name is upload_dir
and the folder is uploads
.
What?
Adds
wp_get_font_dir()
function.Why?
Emulates wp_get_upload_dir() but for the fonts directory.
How?
Implementing wp_get_font_dir() function.
Testing Instructions
Ways to test:
Use the font library to install fonts.
Run PHP unit tests.
Use the function in extension code (theme/plugin) as here:
should print:
should print: