#38615 closed task (blessed) (fixed)
Round out and refine starter content
Reported by: | helen | Owned by: | helen |
---|---|---|---|
Milestone: | 4.7 | Priority: | high |
Severity: | normal | Version: | |
Component: | Themes | Keywords: | needs-testing has-patch |
Focuses: | Cc: |
Description
Starter content is in as of [38991] for #38114; however, the content could still use fleshing out and refining. Core-bundled starter content should provide what the default themes need to showcase themselves, as well as taking a look at some of the more popular themes to see if there's anything else that themes would generically benefit from.
Also needed: communication with the theme review team and a dev note.
Attachments (18)
Change History (64)
This ticket was mentioned in Slack in #themereview by djrmom. View the logs.
8 years ago
This ticket was mentioned in Slack in #core by helen. View the logs.
8 years ago
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
8 years ago
#6
follow-up:
↓ 7
@
8 years ago
I'm not sure what the "Site Credits" widget is about and it looks a little bit weird. Maybe the time format needs to be adjusted? I'm not sure in general how useful this is. While translating I was assuming this is for the "Proudly powered by WordPress" text.
#7
in reply to:
↑ 6
@
8 years ago
Replying to iseulde:
I'm not sure what the "Site Credits" widget is about and it looks a little bit weird. Maybe the time format needs to be adjusted? I'm not sure in general how useful this is. While translating I was assuming this is for the "Proudly powered by WordPress" text.
Yeah this one definitely needs changing :) Might be better off as an "about this site" kind of widget instead, not sure how much people really think of that separately from credits.
#8
@
8 years ago
If we look at the popular and latest themes there are several things that are common but that will have to remain theme_mods since there is no standard. Like the multiple "Feature" or "Service" boxes with a title, text and icon, and placing section headlines above specific areas.
I was also thinking that e-commerce themes are generally more difficult to setup and preview than other themes, it would be nice if we could come up with something that could help with that.
#9
@
8 years ago
Note that #38541 has been resolved, so multiple themes can have starter content and each will apply when switching themes on a fresh site. Starter content from theme B will override starter content from theme A as long as the starter content in A was not touched in the customizer session.
This ticket was mentioned in Slack in #themereview by djrmom. View the logs.
8 years ago
#15
@
8 years ago
Noting for future reference - 38615.diff is an exploration of adding support for featured images; Twenty Seventeen would particularly benefit from this behavior, but I imagine the same holds true for many themes. It includes untested support for page templates since it's similar in terms of storage. There's also a test change to Twenty Seventeen to show what the format would be like in this case - note that I've used an actual ID from my install, and that where exactly images should come from is TBD - from within theme directory or w.org are currently floated options.
Further, there's a filter for whitelisting more args/fields for pages, though it'd be kind of funky to use for anything that's not a top level wp_insert_post() $postarr
element because you'd have to also use the later filter. Just straight up allowing meta_input
to be defined is also an option but complicates the format for theme authors and requires knowledge of how internal meta keys are named.
#16
@
8 years ago
The attachments themselves could be defined in the same way as other posts
, with a named symbol like attachment_header_image
, and then this could be referenced as the value of a thumbnail
as {{attachment_header_image}}
. The attachment
posts could accept an additional file_url
param to point to the remote location which would then get downloaded when the starter content is imported.
#18
@
8 years ago
38615.4.diff allows for sideloading of attachments from the theme directory into the media library and for them to be used as featured images. Because media is involved in a front-end context, there are ugly file includes involved. One thing that appears not to be working is setting auto-draft
for the attachments. But otherwise it appears to work. Thanks to @westonruter for the help on how the $nav_menus_created_posts
bit works :)
What this means is that themes would grow in size somewhat if they include images for this purpose. I don't know that we want to artificially limit the number of images to load in core but it could take a while to process the uploads if too many are registered. For Twenty Seventeen, I took the images off http://2017.wordpress.net for testing, but at the 2000px wide size because that's all that was needed, not the original full size.
#19
@
8 years ago
Hmm, getting an array to string conversion notice in /srv/www/wordpress-develop/src/wp-includes/class-wp-customize-manager.php
L1079 when refreshing the customizer, which is $this->set_post_value( $setting_id, array_unique( array_values( $nav_menus_created_posts ) ) )
.
This ticket was mentioned in Slack in #core-media by helen. View the logs.
8 years ago
#21
@
8 years ago
38615.5.diff includes a minor fix in WP_Customize_Manager
where, when using a child theme that does not provide its own image replacement, the file is taken from the parent theme. Previously this would have caused an issue.
#22
@
8 years ago
As discussed in https://wordpress.slack.com/archives/core-media/p1479488594000409, it's currently not possible to set an attachment to the post status auto-draft
. This was causing previous patches to immediately have the starter content images show up in the media library. 38615.6.diff removes that limitation from the wp_insert_post()
function by including auto-draft
in the whitelist for attachment post statuses. The starter content media workflow worked correctly for me after applying this change.
@joemcgill Do you have any reservations regarding this? Why was this prevented in the first place?
#23
@
8 years ago
38615.7.diff is a minor tweak to make the if clause added in 38615.5.diff more readable: get_stylesheet_directory_uri()
is only called when there's a child theme and it contains the file, otherwise get_template_directory_uri()
is used.
This ticket was mentioned in Slack in #core-customize by helen. View the logs.
8 years ago
#26
@
8 years ago
38615.8.diff fixes the problem with array to string conversion notice. It was a trivial oversight (of mine).
Also fixed an issue an “undefined index: sizes” PHP notice. When a header image is not sourced from an attachment, then there is no sizes
item in the array passed to the get_header_image_tag
filter. Maybe the sizes
should be defined in the array defaults to prevent that from happening unexpectedly. (But that's been the case since 4.4.)
#27
follow-up:
↓ 37
@
8 years ago
- Keywords has-patch needs-testing added
38615.9.diff is ready for testing. To test, you will need:
- These images in
twentyseventeen/assets/images
: http://s.hyhs.me/iAFm - To set the
fresh_site
option to1
(if you are a wp-cli user,wp option set fresh_site 1
). - Load up the customizer to view Twenty Seventeen (both as the active theme and not) and see something that hopefully looks like this (except with the default header image): http://s.hyhs.me/iAfl
What this patch should get you is featured images set for each of those pages that are homepage sections. These attachments are sideloaded from within the theme directory and are set to auto-draft
so they don't appear in the media library until you save your changes; otherwise, they should stay hidden and later be garbage collected. It also happens to enable page templates to be set; to test that, you will want to make a page template inside the twentyseventeen
directory and add 'template' => 'sample-page-template.php'
(or whatever the filename is) to one of the non-blog page/post definitions in functions.php
.
I'm interested in:
- Does this help present Twenty Seventeen in a better way upon first live preview? Do you see this being useful for other themes that use image attachments in various contexts (the ID can be used for theme mods and more, not just the post thumbnail)?
- How does the load time feel? This is a concern because of the image sideloading. Themes should be encouraged not to add too many attachments this way, both for load reasons and not to bloat theme packages too much.
- Does everything save correctly? In particular, do those sideloaded images only appear in the media library after you've saved and published your customizer changes?
- Is enabling
auto-draft
for attachments a problem? Does the garbage collection work? - What do you think of the patch in general?
- Are there any bugs?
And finally, if this is the first time you're taking a look at starter content, are there any changes or additions you'd want to see in the other defined content?
This ticket was mentioned in Slack in #core by helen. View the logs.
8 years ago
#30
@
8 years ago
I compressed the images regarding to #38793. I used IrfanView for that, and maybe we could discuss (somewhere else) how we proceed in the future with that. See next screenshot for the settings used. I did not use progressive setting, for example.
#31
@
8 years ago
Both the images and the page templates are working very well, no issues found (4.7-beta4-39320 + 38615.9).
#32
@
8 years ago
- Keywords needs-patch added; has-patch removed
In 38615.10.diff & 38615.11.diff (see changes):
- Set auto-draft via 4th arg on
media_handle_sideload()
instead of an additional call towp_update_post()
. - Allow starter content to supply attachment args for title, description, and excerpt; supply translatable titles for the images in Twenty Seventeen.
- Sideload attachment from disk instead of downloading from URL when possible.
- Prevent clobbering gathered attachment IDs when amending to existing changeset.
Sideloading the 3 images by first fetching each via download_url()
causes the entire starter content import process to take about 2.05 seconds. When the files are already on the filesystem, as they have been in our examples, it is much faster to copy the file to the temporary location and then use temp file in the call to media_handle_sideload()
. This cuts the starter content import time down to 0.07 seconds (about 30× faster).
I am noticing a probably defect with the attachment importing whereby once images are imported and you reload the customizer, the images get re-uploaded into the media library again even though they are already there as auto-drafts. Likewise, the nav_menus_created_posts
setting keeps getting the new attachment IDs amended to it even though they aren't actually used because posts are skipped from being inserted (and thus the new thumbnail
assigned) if there is already an auto-draft
post with the expected post_name
in the DB among the nav_menus_created_posts
.
This ticket was mentioned in Slack in #core-customize by helen. View the logs.
8 years ago
This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.
8 years ago
#36
@
8 years ago
- Keywords needs-patch removed
In 38615.12.diff (see changes):
- Eliminate support for fetching starter content files by URL
- Allow any recognized file for starter content attachments
- Prevent attachments from being re-created and re-sideloaded when auto-drafts already exist in the customized state
#37
in reply to:
↑ 27
@
8 years ago
Replying to helen:
- Is enabling
auto-draft
for attachments a problem? Does the garbage collection work?
I can confirm that the attachment
posts with the auto-draft
status do indeed get deleted via wp_delete_auto_drafts()
, with one caveat. It turns out that the cron event that does wp_delete_auto_drafts()
is only scheduled when a user lands on post-new.php
:
<?php // Schedule auto-draft cleanup if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) wp_schedule_event( time(), 'daily', 'wp_scheduled_auto_draft_delete' );
This logic should be added to WP_Customize_Manager
as well so that these starter content auto-draft posts will get garbage collected (as well as the unpublished customize_changeset
posts themselves) will get garbage-collected in the rare case where a user never goes to post-new.php
on a given install. A user never visiting post-new.php
is entirely possible if the user does all of their site management in the customizer or via the REST API.
Update: I've opened #38899 to address this.
#38
@
8 years ago
- Keywords has-patch added; needs-unit-tests removed
In 38615.13.diff (see changes):
- Fix handling of theme starter content extending core content arrays.
- Enforce subset of post fields that can be used in starter content.
- Add unit tests for
get_theme_starter_content()
andWP_Customize_Manager::import_theme_starter_content()
.
#39
@
8 years ago
- Owner changed from westonruter to helen
- Status changed from accepted to assigned
Unit tests should be running soon: https://travis-ci.org/xwp/wordpress-develop/builds/177901400
I was seeing a unit test failure on Travis where an attachment file wasn't getting added successfully:
File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.
I tried it a second time and it seemed to not be a problem then. So I'm not sure.
This ticket was mentioned in Slack in #core by westonruter. View the logs.
8 years ago
#41
@
8 years ago
That was a pretty wild PHP bug chase :) 38615.15.diff fixes the issue caught in the tests - I think we're ready.
Generally, the idea here is to have content that showcases various WP and default theme features and gives users an idea of what sort of site X theme will help them create. Of note, I think we need to flesh out the page content that's been committed and add more that does some showcasing of formatting and media (doesn't need to be full-on theme unit testing by any means), as well as do a little more with widgets. We may also want to think about how to allow for page template setting, although not sure it's critical for 4.7.
I should also point out that images are missing entirely from this. While I think they are important, I'm okay with not considering them critical for launch either, and there are a ton of considerations around sizes and where they're loaded from and how.
First run commit content, for easy reference (options and theme mods can also be set):
Widgets
text_business_info
Address
123 Main Street
New York, NY 10001
Hours
Monday—Friday: 9:00AM–5:00PM
Saturday & Sunday: 11:00AM–3:00PM
search
text_credits
Nav menus
Each of the sample content pages is available via the following IDs:
page_home
page_about
page_blog
page_contact
Links (currently geared toward commonly used social nav menus):
link_yelp
link_facebook
link_twitter
link_instagram
link_email
Posts (of any type)
home
about-us
contact-us
blog
homepage-section