Allow upload of themes without index.php#2692
Allow upload of themes without index.php#2692peterwilsoncc wants to merge 12 commits intoWordPress:trunkfrom
Conversation
| __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ), | ||
| '<code>Template</code>', | ||
| '<code>style.css</code>' | ||
| ) |
There was a problem hiding this comment.
Existing string
wordpress-develop/src/wp-includes/class-wp-theme.php
Lines 347 to 355 in 3dcdd4b
| empty( $info['Template'] ) && | ||
| ! file_exists( $working_directory . 'index.php' ) && | ||
| ! file_exists( $working_directory . 'templates/index.html' ) | ||
| ) { |
There was a problem hiding this comment.
This has changed the behavior for classic themes. Before this PR, a classic theme without a index.php file could not be uploaded. After this PR, it can be if it has a templates/index.html file. Is this problematic?
There was a problem hiding this comment.
I'm not sure, I based it on the code for activating plugins in r52940.
My reading of the docs for block themes is that template/index.html is what defines a block theme. Is there something else the code could be checking for?
There was a problem hiding this comment.
Yes it is for block themes. But non-block themes could also have a template directory and an index.html file within it.
My concern (though not tested or validated) is: does this allow a non-block theme to be installed but then not work elsewhere in the admin area or frontend? Hmm, need to test this to find out.
There was a problem hiding this comment.
A classic theme cannot have a templates/index.html since WP_Theme::is_block_theme() was introduced in 5.9. As soon as it has that file, it's considered a block theme.
| __( 'The theme is missing the %s file.' ), | ||
| '<code>index.php</code>' | ||
| /* translators: 1: templates/index.html, 2: index.php, 3: Documentation URL, 4: Template, 5: style.css */ | ||
| __( 'Template is missing. Standalone themes need to have a %1$s or %2$s template file. <a href="%3$s">Child themes</a> need to have a %4$s header in the %5$s stylesheet.' ), |
There was a problem hiding this comment.
Thinking this error message is a bit "too much information"? Who is it intended for? :)
- If it's mostly for users it would be enough to say that the theme seems damaged, and to point them to possible next step (try again, etc.).
- If it's mostly for developers, perhaps it can be a bit more technical, something like "the zip file is either damaged or it doesn't contain a valid WordPress theme as it is missing %1$s or %2$s".
There was a problem hiding this comment.
Thinking this error message is a bit "too much information"? Who is it intended for? :)
Are you able to create a follow up ticket for 6.1 to reconsider this string for both uploading and activating themes?
This ticket is on the 6.0 milestone so needs to use an existing string as the branch is in a hard string freeze.
There was a problem hiding this comment.
Ah, right, added it here as this hasn't been committed yet, but it is too late for the string change. Will open a follow-up ticket.
Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com>
…wordpress-develop into 55682-upload-block-themes
|
In c408ff6 I've added support back support for the deprecated paths in each of the locations that check for block themes. I'll add in some tests to ensure deprecated block themes are not broken. |
|
I left some comments about this patch on WordPress Slack (link requires registration at https://make.wordpress.org/chat): https://wordpress.slack.com/archives/C037DD0CLHY/p1652748680139119 and re-sharing here for visibility. I can confirm that in other places we use both folder names for detecting whether we have a block theme: wordpress-develop/src/wp-includes/class-wp-theme.php Lines 1484 to 1496 in 3dcdd4b so it feels like we should be doing the same checks in all other places. @mcsf was so kind to also look at this problem and we both arrived at the same conclusions. |
|
Thanks for the help, folks, I think this has caught all the areas that were missing the check for the legacy folder structure. Riad mentioned in Slack the deprecated paths are handled by the function above too. Based on some quick testing that seems to be happening in the FSE interface already. I'm sure I could add more tests but if I can get some approvals, I think this is good to go in as is. |
https://core.trac.wordpress.org/ticket/55682