Patterns: Remove the ref from pattern content #550
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #545 — This removes the Navigation's
ref
property from patterns on output, so that it's never added in the copyable pattern code. Theref
is an ID for the nav menu, which only exists on the local site. When added to a user's site, it errors. There should be no ref so that the default behavior takes over when it's added.Patterns should never have a ref, but in some rare cases they do— patterns created by users with more permissions on the w.org/patterns site, not using the pattern creator, or patterns copied in from external sites.
I decided to fix this by filtering out the ref on the output, rather than just updating the pattern content - this way if someone updates these patterns again or adds new patterns, they'll never have a
ref
value.The following is a complete list of published patterns with a
ref
.Screenshots
The pattern now correctly displays the fallback (mocked) nav menu:
and when you copy the code, there is no
ref
.How to test the changes in this Pull Request:
This is easiest to test on a wporg sandbox, since it already has the
ref
'd patterns. Otherwise create some patterns in wp-admin with Navigation blocks so that they have localref
.wp:navigation
code, it should not include theref
https://api.wordpress.org/patterns/1.0/?slug=centered-header-with-logo
pattern_content
value — this is what the core editor uses to display patternswp:navigation
code should not have a ref