Skip to content

Sort uploaded font files into subdirectories for each font family#60402

Closed
creativecoder wants to merge 3 commits intotrunkfrom
try/font-files-in-subfolders
Closed

Sort uploaded font files into subdirectories for each font family#60402
creativecoder wants to merge 3 commits intotrunkfrom
try/font-files-in-subfolders

Conversation

@creativecoder
Copy link
Copy Markdown
Contributor

@creativecoder creativecoder commented Apr 3, 2024

What?

Sort font file uploads into subdirectories within the fonts folder, according to font family.

Related to #58411

Why?

  • Helps organize the fonts folder for sites that may have many fonts
  • Helps associate font files with non-descriptive names with their font families

How?

Adds additional filtering to the

Testing Instructions

  • Install a Google font to your site and see that the font file is stored in a subdirectory using the font family slug
  • Upload a font file to your site and see that the font file is stored in a subdirectory using the font family slug
  • Delete both font families and see that the files and the subdirectory are deleted

@creativecoder
Copy link
Copy Markdown
Contributor Author

This is still in draft because I'd like to add/update unit tests for the subdirectory uploads.

@creativecoder creativecoder force-pushed the try/font-files-in-subfolders branch from 54e9bec to 04396fb Compare June 3, 2024 19:06
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 3, 2024

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/compat/wordpress-6.6/fonts/class-gutenberg-rest-font-faces-controller.php
❔ lib/compat/wordpress-6.6/fonts/fonts.php
❔ lib/load.php

Copy link
Copy Markdown
Member

@mikachan mikachan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is working really well for me so far. I believe sorting the font files into subdirectories is a good improvement too, it's much easier to find files like this when the file names are non-descriptive, e.g. N0b52SlTPu5rIkWIZjVKKtYtfxYqZ4RJBFzFfYUjkSDdlqZgy7JYxnL31AHfAAy5.woff2.

Test report:

  • Install a Google font to your site and see that the font file is stored in a subdirectory using the font family slug ✅
  • Upload a font file to your site and see that the font file is stored in a subdirectory using the font family slug ✅
  • Delete both font families and see that the files and the subdirectory are deleted ✅

The fonts were successfully stored in a subdirectory using the font family slug:
image

I can see you're planning to add tests later, happy to come back and give this a more detailed review then. The code is looking good to me - it's well organised and the comments are helpful, especially for the merge with Core.

*
* @package WordPress
* @subpackage REST_API
* @since 6.5.0
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @since 6.5.0
* @since 6.6.0

I'm guessing this version number may need to be updated for 6.6?

mikachan

This comment was marked as duplicate.

@johnbillion johnbillion deleted the try/font-files-in-subfolders branch February 10, 2025 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants