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 |
jffng
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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: