#38639 closed defect (bug) (invalid)
Improve the user and developer experience for new custom header functions
Reported by: | bradyvercher | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.7 |
Component: | Themes | Keywords: | has-patch |
Focuses: | Cc: |
Description
The subject is a bit open-ended, but the custom header functionality currently feels a bit glitchy. As I've dug into the code over the past week, I've uncovered a few bugs that were present before video headers were introduced and have opened tickets for those. They make it difficult to really test the experience in the Customizer.
I'm going to try to lay out a few concrete things that can be done to improve the new custom header functions that should hopefully create a much smoother experience for users in the Customizer as well as make it easer for theme authors to implement support in themes, especially as the pre-existing bugs are addressed.
Selective Refresh
A Customizer partial is registered by default and uses the_custom_header_markup()
for the render callback, which allows both header images and videos to automatically support selective refresh. If a header image or video hasn't been set, we don't want to output empty markup on the front end, however, the container div needs to exist in the Customizer for selective refresh to work. Otherwise, setting an image or video will result in a full refresh.
the_custom_logo()
, along with other features in core, output placeholders in the Customizer preview for the optimal experience, so making sure the container is always available in the preview isn't really breaking new ground. Themes can always use .wp-custom-header:empty { display: none;}
to hide it if it causes styling issues in the preview.
Header Image Settings
It may also be worth changing the transport for the header_image
and header_image_data
settings to postMessage
automatically when the the theme registers support for videos. Otherwise, it's kind of a weird experience when videos use selective refresh and images don't.
Front Page Restriction
I've been looking to incorporate this functionality in the Marquee theme and it feels broken if video only loads on the front page. This seems like a restriction that should be left up to the theme and is particularly difficult to workaround if a theme wants video on more than one page.
Browsers should be caching local videos, which should minimize the bandwidth impact a bit. I think we should make the API broadly useful and document best practices instead of trying to enforce onerous restrictions.
Attachments (2)
Change History (15)
This ticket was mentioned in Slack in #core-themes by bradyvercher. View the logs.
8 years ago
#3
@
8 years ago
- Milestone changed from Awaiting Review to 4.7
+1 to automatically turning on selective refresh for images when video support is added. Since themes have to explicitly add video support, we can ask them to also ensure that they're either using the_custom_header_markup()
, adjusting the custom header partial to reflect their custom output, or turning the transport back to refresh on those settings.
This ticket was mentioned in Slack in #core-themes by bradyvercher. View the logs.
8 years ago
#5
@
8 years ago
- Keywords has-patch added
In 38639.1.diff:
- Set the transport for
header_image
andheader_image_data
topostMessage
when support for video headers is registered - Remove unnecessary tests for #38557
#6
@
8 years ago
I think this is best split into two tickets: 1) selective refresh; 2) removing the front page limitation.
The architectural and design decisions around one ought not block the other.
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
#10
@
8 years ago
Thanks @peterwilsoncc I agree that these are separate tickets. @bradyvercher, could you split the appropriate parts of 38639.1.diff to their related new tickets? If the unit tests don't go cleanly with either, feel free to add another ticket for adding unit tests.
#11
@
8 years ago
I'd like to see these changes through and help make sure video headers provide a good experience, but the various pieces here are intertwined and splitting them up at this point is going to take a good chunk of time. Getting to the bottom of numerous issues with custom headers and juggling the various tickets has already taken much more time than I anticipated.
There's been little discussion on this ticket and no opinions offered on the new ones. I realize everyone is busy, but I'd like to see some decisions made before moving forward with these changes.
In 38639.diff:
is_front_page()
conditional inhas_header_video()
show_video
argument tothe_custom_header_markup()
that defaults to only displaying video on the front page.get_customer_header_markup()
to always output the container div in the Customizer for selective refresh support.I've also added a bunch of "unit" tests.
_remove_theme_support()
were required, otherwise all sorts of notices would be thrown, causing the tests to fail.add_theme_support( 'custom-header' )
in the tests should be avoided since it sets a number of constants, which would poison subsequent tests. The_add_theme_support()
method isn't ideal, but it's the only way I could think of to get around the constants.