Skip to content

Alternative fallback for the default /fonts path#6292

Closed
azaozz wants to merge 36 commits intoWordPress:trunkfrom
azaozz:Alt-default-font-path
Closed

Alternative fallback for the default /fonts path#6292
azaozz wants to merge 36 commits intoWordPress:trunkfrom
azaozz:Alt-default-font-path

Conversation

@azaozz
Copy link
Contributor

@azaozz azaozz commented Mar 20, 2024

An alternative to #6259. Reuses some of the code from there.

Trac ticket: https://core.trac.wordpress.org/ticket/60751


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

matiasbenedetto and others added 30 commits March 11, 2024 17:14
Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
…p_upload_dir

Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
…rror message is added in the 'error' key of the returned array following the `wp_font_dir` pattern: https://github.com/matiasbenedetto/wordpress-develop/blob/trunk/src/wp-includes/functions.php#L2393-L2406

Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com>
To trigger the fallback logic, need to create a fake where `wp_mkdir_p()` bails out early and returns `false`.

Looking at wp_mkdir_p(), notice this code:

```
if ( file_exists( $target ) ) {
	return @is_dir( $target );
}
```

When the `$target` exists but is a file (not a directory), then `false` gets returned. Aha! Props to @costdev.

This commit:

* Adds a fake file, reworks the test, and then removes the file in the tear_down().
* Refactors the removing of the fonts directory by putting it into a separate method.

These new methods can be put into a trait or base abstraction that all of the Font Library test classes use to ensure the filesystem is restored between tests (that's out-of-scope for this PR).
Co-authored-by: Brian Alexander <824344+ironprogrammer@users.noreply.github.com>
Co-authored-by: Brian Alexander <824344+ironprogrammer@users.noreply.github.com>
…'t fall back to the /wp-content/uploads/fonts folder.
matiasbenedetto and others added 5 commits March 18, 2024 18:05
Depend only on `wp_is_writable( WP_CONTENT_DIR )` to change the location to /uploads/fonts.
add test-only filter, add 'create' param to function calls, etc.
@github-actions
Copy link

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props mmaattiiaass, swissspidy, hellofromtonya, azaozz.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

Test using WordPress Playground

The 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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@peterwilsoncc
Copy link
Contributor

Closing this PR off per https://make.wordpress.org/core/2024/03/21/font-library-update-storage-of-font-files/. Thanks everyone for your work on this, I appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants