#34456 closed defect (bug) (invalid)
Add add_theme_support('title-tag') to all default WordPress themes as wp_title() is deprecated since WordPress 4.4
Reported by: | Nikschavan | Owned by: | obenland |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.4 |
Component: | Bundled Theme | Keywords: | has-patch has-screenshots |
Focuses: | Cc: |
Description
Now that the wp_title()
is deprecated since WordPress 4.4, all the default themes before should have add_theme_support('title-tag');
https://make.wordpress.org/core/2015/10/20/document-title-in-4-4/
The screenshot is from twentythirteen theme with WP_Debug enabled.
Attachments (7)
Change History (36)
#2
@
9 years ago
- Keywords dev-feedback has-screenshots needs-testing added; reporter-feedback removed
This ticket was mentioned in Slack in #core-themes by nik. View the logs.
9 years ago
#5
@
9 years ago
- Milestone changed from Awaiting Review to 4.4
@obenland, could you please have a look at this? I just ran into the same problem in Twenty Eleven.
#7
@
9 years ago
- Keywords dev-feedback removed
Hi @Nikschavan, thanks for the ticket and the patch!
Some feedback:
The compat function would need an actual prefix and should be defined outside of twentythirteen_setup()
. We should also do a positive check (if ( function_exists() )
rather than if ( ! function_exists() )
.
#8
@
9 years ago
Thank you @obenland for your feedback, I have refreshed the patch accordingly, I will probably need help in the doc for the new function that is added, though.
Also, As this needs to be updated in all the default themes from 2010-2014, should I create a new ticket for all the themes separately, combine all into one patch?
@
9 years ago
I noticed this was adding title two tiles on WordPress 4.3.1, because add_filter( 'wp_title', 'twentythirteen_wp_title', 10, 2 );
was also being fired along with add_theme_support( 'title-tag' );
add_filter( 'wp_title', 'twentythirteen_wp_title', 10, 2 );
to compat check, will only be fired if _wp_render_title_tag
does not exists.
This ticket was mentioned in Slack in #core-themes by obenland. View the logs.
9 years ago
#11
follow-up:
↓ 15
@
9 years ago
I don't think we should patch Twenty Ten or Eleven because it'd be difficult to avoid breaking all the sites running those themes. I think it's OK to focus on newer themes.
#12
@
9 years ago
@Nikschavan 34456.4.diff looks good. Do you want to update it for 2012 and 2014 as well?
#14
@
9 years ago
34456.5.diff Adds the changes made in 34456.4.diff to themes 2012 and 2014 as well.
#15
in reply to:
↑ 11
@
9 years ago
Replying to lancewillett:
I don't think we should patch Twenty Ten or Eleven because it'd be difficult to avoid breaking all the sites running those themes. I think it's OK to focus on newer themes.
We're essentially breaking back compat for all other themes too though, the 'wp_title'
filter won't be run anymore.
#16
@
9 years ago
- Keywords needs-testing removed
After giving it a bit more thought, I don't think we should update default themes at all. The reason being that we would break back compat for every site that has a filter hooked into wp_title
, which is obviously not a good experience.
I added a patch that would make the notice less obtrusive and also stop hijacking the title on sites that have WP_DEBUG
enabled in production, which I think could be a good compromise. If the deprecated_function_trigger_error
filter had the function as a second argument we could even disable displaying the notice at all in these themes, which in this case might make sense because we know they will never get updated.
Thoughts?
#17
follow-up:
↓ 19
@
9 years ago
I'm think it's okay to not update old default themes, but 34456.diff is meh. The function declaration should be outside of wp_title()
otherwise it will lead to a "cannot redeclare" fatal error if wp_title()
gets called twice.
Wasn't there a suggestion to make wp_title()
a wrapper for wp_get_document_title()
somewhere?
If the
deprecated_function_trigger_error
filter had the function as a second argument we could even disable displaying the notice at all in these themes
Related: #34183
#18
follow-up:
↓ 20
@
9 years ago
I agree with @obenland on not updating the default themes concerning the backwards compatibility, Although I am not too sure if I like the deprecated notice being displayed on the front end to all the visitors of the site.
Maybe only show the notice to logged in/ admin users? or add the notice in error_log()
?
Either way, as we are planning to not to patch the themes, user who has this theme installed will have only two options to get rid of this warning either to change the theme or downgrade WordPress both the options are not good.
#19
in reply to:
↑ 17
@
9 years ago
Replying to ocean90:
The function declaration should be outside of
wp_title()
otherwise it will lead to a "cannot redeclare" fatal error ifwp_title()
gets called twice.
Good point, I shall update the patch.
Wasn't there a suggestion to make
wp_title()
a wrapper forwp_get_document_title()
somewhere?
Maybe on the make/core post? I'm not sure it would help with maintaining back compat for the filters in there. We could maintain it for wp_title
but probably not for wp_title_parts
unless I'm missing something.
#20
in reply to:
↑ 18
@
9 years ago
Replying to Nikschavan:
I am not too sure if I like the deprecated notice being displayed on the front end to all the visitors of the site.
user who has this theme installed will have only two options to get rid of this warning either to change the theme or downgrade WordPress both the options are not good.
The notice is only shown on sites that have WP_DEBUG
enabled in production.
#21
follow-up:
↓ 22
@
9 years ago
First thoughts:
- For some reason I was thinking nested functions would be treated as closures in 5.2, which doesn't actually seem to be true. But @ocean90 raises a good point about reuse of
wp_title()
. - I think because of the deprecated notice and because we're talking about default themes, we need to update the defaults back at least a year, so Twenty Fourteen and Fifteen
#22
in reply to:
↑ 21
;
follow-ups:
↓ 23
↓ 25
@
9 years ago
Replying to DrewAPicture:
- I think because of the deprecated notice and because we're talking about default themes, we need to update the defaults back at least a year, so Twenty Fourteen and Fifteen
Twenty Fifteen already uses the new way. Again, if we updated Twenty Fourteen we would break backwards compatibility with everything that is hooked into wp_title_parts
and wp_title
on sites that use the theme.
#23
in reply to:
↑ 22
@
9 years ago
Replying to obenland:
everything that is hooked into
wp_title_parts
andwp_title
on sites that use the theme.
We could check via has_filter()
if something is hooked into one of the filters. If not, use the new title.
#25
in reply to:
↑ 22
;
follow-up:
↓ 26
@
9 years ago
Replying to obenland:
Twenty Fifteen already uses the new way.
Actually that's a back compat issue, because the new way was previoulsy _wp_render_title_tag()
->wp_title()
and thus the wp_title
and wp_title_parts
filters were available.
#26
in reply to:
↑ 25
@
9 years ago
Replying to ocean90:
Actually that's a back compat issue, because the new way was previoulsy
_wp_render_title_tag()
->wp_title()
and thus thewp_title
andwp_title_parts
filters were available.
The impact on backwards compatibility here should be limited. Chances that wp_title
is being filtered for anything other than what wp_get_document_title()
already accounts for are even more limited, especially for newer themes that would support title-tags. I also assume that the vast majority of themes has implemented theme support the way it was recommended on make/core, which would make this pretty much a non-concern.
In retrospect we probably should have kept theme support for title-tags visible in current_theme_supports()
, it would have allowed plugins to account for themes that declare it, even though they still might temporarily call wp_title()
. While it's not as ideal as I'd like it to be, I don't think it's going to pose a problem.
The patch fixes only for twentythirteen theme, Once this is reviewed, I will create refresh the patch for all the themes as well.