Opened 8 years ago
Closed 8 years ago
#36839 closed defect (bug) (fixed)
Locale stylesheet loaded early for embeds
Reported by: | greenshady | Owned by: | peterwilsoncc |
---|---|---|---|
Milestone: | 4.6 | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | Embeds | Keywords: | needs-testing good-first-bug has-patch commit |
Focuses: | Cc: |
Description
Typically, locale stylesheets get loaded after other styles have been output when hooked to wp_head
. However, with embeds on the embed_head
hook, the locale stylesheet is output earlier. This can cause locale stylesheets to get overwritten with CSS applied later.
Here's a comparison of the priorities between the wp_head
and embed_head
hooks:
add_action( 'wp_head', 'wp_print_styles', 8 ); add_action( 'wp_head', 'locale_stylesheet' ); add_action( 'embed_head', 'wp_print_styles', 20 ); add_action( 'embed_head', 'locale_stylesheet' );
The locale_stylesheet
action should get a later priority on embed_head
for consistency.
This has been in core since 4.4, but it's probably been overlooked because most theme authors were not dealing with it. Now that themes can have custom embed templates, this could be a problem. I know it is for some of my themes that have locale-specific stylesheets.
Attachments (1)
Change History (9)
#1
@
8 years ago
- Keywords needs-patch needs-testing added
- Milestone changed from Awaiting Review to 4.6
#3
@
8 years ago
Would like to take a stab at this if someone would like to mentor a little.
Cheers,
#4
@
8 years ago
@sjmur That'd be great! You can ping me on Slack if you have any questions.
Basically, when you're running WordPress in another locale (e.g. de_DE) and a theme has a locale stylesheet (de_DE.css
) or an rtl.css
stylesheet, WordPress will enqueue this file.
As you can see from the add_action()
snippets above, the regular stylesheets get printed earlier (priority 8) than the locale stylesheet (default priority of 10). However, when embedding a post, regular stylesheets get printed after the locale CSS.
This of course is inconsistent and can lead to all sorts of bugs, like not being able to override some theme styles in the locale CSS.
We should change add_action( 'embed_head', 'locale_stylesheet' );
to something like add_action( 'embed_head', 'locale_stylesheet', 30 );
and test if it works correctly.
Hey Justin, thanks for opening this ticket.
Definitely looks a bit off. Will have a closer look at this tomorrow as there's a contributor day going on here.