Template Switcher: Add current theme#21578
Conversation
|
Size Change: +1.17 kB (0%) Total Size: 841 kB
ℹ️ View Unchanged
|
3704d06 to
4950572
Compare
|
I wonder, does the code in #222 need to go into the Gutenberg plugin for the time being? Otherwise, wouldn't the feature be broken until the next WordPress core update? |
I think so, yeah. Probably by tapping into |
Yep, that worked: c74cf62 🎉 |
youknowriad
left a comment
There was a problem hiding this comment.
Probable some failures on php linting. Otherwise, it looks good to me.
Thanks Riad! Ah, looks like it's actually a PHP unit test, I'll look into it. Edit: Nope, PHP lint run inside Travis' unit test job 😅 |
In #21578, I added a few fields to Core's `/themes` endpoint, for use by the Site Editor's Template Switcher (see both #21578 and #21768). I then submitted those changes as a [PR](WordPress/wordpress-develop#222) against Core. That PR underwent a number of modifications and was eventually merged; the new fields will be part of the `/themes` endpoint exposed by Core starting from the next WP release. This PR updates the fields added by Gutenberg to follow the same semantics, as well as the callsites that use that endpoint.
Description
Display the current theme name in the template selector of
edit-site.Since the
/themesendpoint currently only exposes thetheme_supportsfield for each theme, this PR adds a number of additional fields to it, using therest_prepare_themehook. (I also filed a WordPress/wordpress-develop#222 against Core to extend the, err, upstream endpoint accordingly so that we can eventually drop the filter.)In addition, this PR adds a new
getCurrentThemeselector and related reducer/resolver/action tocore-data(including athemesreducer for better normalization).Finally, that selector is used to render the theme name in
edit-site's template selector.The fields I've chosen to add should be sufficient to implement the on-hover previews seen at #20469 (comment):
However, this PR doesn't implement those previews yet, since we need to implement the underlying fly-out menu component first (see #20470).
Fixes part of #20469.
How has this been tested?
Screenshots
Types of changes
New feature
Checklist: