-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Adds minimum WordPress version to theme metadata #715
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I think this is a good idea to help prevent missing minimum versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this field could be a good candidate for a 'select' type component instead of a plain 'input' one. The select could feature the version '5.9', '6.0', '6.1'.
As a probably not-needed addition, each option could have some comment/documentation like "Minimum version for block themes" or something like that.
Is there a case where the minimum version would be the version the theme was exported with? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem to be updating the data in the theme as expected. In this screencast I tried updating theme description (working as expected) and WordPress minimum version (not updating).
2024-09-05.11-31-36.mp4
That's not always true. A theme could be a very basic template that doesn't require the latest version of Wordpress which is commonly what a theme creator would use. |
Thanks for the reviews and feedback.
I updated the control to be a Select control instead of a text input. An issue with this is that if the theme sets a version not provided by the predetermined options, it won't be reflected in the metadata editor.
It's possible, but do we think that's a better default if no required version is supplied?
Whoops, I wasn't properly sanitizing the field in the REST API request. Fixed in b1d1558 |
Problem is, you don't really know. Picking a version is basically guessing. :) |
const WP_MINIMUM_VERSIONS = [ | ||
'5.9', | ||
'6.0', | ||
'6.1', | ||
'6.2', | ||
'6.3', | ||
'6.4', | ||
'6.5', | ||
'6.6', | ||
'6.7', | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems tedious to maintain. How about adding global $wp_version
from PHP into a JS global and using that to generate a range of versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@creativecoder do you mean something like this? f3d352a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's in line with what I was thinking!
Co-authored-by: Grant Kinney <creativecoder@users.noreply.github.com>
I think it would make sense because it would reflect the features available to the theme builder at the time of export. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you update the minimum version the style.css
file is updated but the readme.txt
file not.
The minimum version of the blank themes created is hardcoded. Probably we should set something dynamic.
Thanks @matiasbenedetto for the review.
Fixed here: 416b149
Done here: 8e25b5b |
The default version is empty now when creating a blank theme. 2024-09-18.10-50-12.mp4 |
Sorry for not testing that before, I fixed it here: b3b3386. I assumed I could check for the existence of the parameter, but the sanitization function ensures that I also added the minimum version selector to the additional metadata panel when creating a new theme: 2f9225f Here's what I tested:
Am I missing any other flows? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is working well in my testing 🎉
I've tested creating themes from the Appearance page, which defaults to using the active WP version in each case:
- Blank theme ✅
- Clone ✅
- Child ✅
I also tested the options available from the Editor, where I was able to set a custom WP version or it would default to the active version:
- Editing active theme's metadata ✅
- Blank theme ✅
- Clone ✅
- Child ✅
I don't believe there are any other flows and I think this is ready to bring in, so I'm leaving a ✔️ , but it'd be great if @matiasbenedetto has a chance to review before landing too.
Description
This PR adds a field to the metadata to allow users to update the required minimum WordPress version in the theme's metadata.
Background
In reviewing some themes recently (Automattic/themes#8058) (Automattic/themes#8067), I've noticed the required minimum version is empty.
I think we should allow the user to be able to edit this via the Metadata editor.
Since this metadata is a requirement, the PR also supplies a minimum version (5.9, when block themes were introduced) if none exists. I'm not sure about this part.