Opened 23 months ago

Closed 23 months ago

Last modified 23 months ago

#18018 closed defect (bug) (fixed)

body_class page-template-default removed

Reported by: peterwilsoncc Owned by: nacin
Priority: normal Milestone: 3.2.1
Component: Template Version: 3.2
Severity: normal Keywords: has-patch
Cc:

Description

Changes to is_page_template() have inadvertently removed the body classes page-template and page-template-default from pages using the default template.

The class first appeared as a bug a few versions ago ( #17458 ) but has is now expected by theme authors.

Previous output

<body class="page page-id-2 page-template page-template-default [...]


3.2 output

<body class="page page-id-2 [...]

I have attached two .diff files:

  1. outputs .page-template-default only for default page templates
  2. outputs .page-template and .page-template-default for default page templates (previous behaviour)

I'm inclined to go with version (a) as (b) has .page-template doubling up for .page but it may affect existing themes.

Cheers,
Pete

Attachments (2)

18018-A.diff (750 bytes) - added by peterwilsoncc 23 months ago.
return page-template-default
18018-B.diff (919 bytes) - added by peterwilsoncc 23 months ago.
return page-template-default and page-template

Download all attachments as: .zip

Change History (10)

return page-template-default

return page-template-default and page-template

  • Milestone changed from Awaiting Review to 3.2.1

18018-B makes more sense, even if it isn't technically compatible.

Sorry, I meant A.

When did this behavior begin originally?

Based on Dion's comment in the support forum, I think it was around version 2.8. Unable to find a specific diff file or ticket # though, sorry.

Looks like it was when _wp_page_template was first set to default for pages without an actual template.

Looks like it was when _wp_page_template was first set to default for pages without an actual template.

Yes, That's when it would've been. I'm not sure where that change was made, it's 2.9~3.1 somewhere, I'll track that down later

Personally i'm of the opinion that the page-template-default class should have never been used (nor was it ever supposed to)

2.8.0 (body_class() introduced): <body class="page page-id-2 page-template- logged-in">

2.8.1: <body class="page page-id-2 logged-in">

2.9 (branch): <body class="page page-id-2 logged-in">

3.0 (branch): <body class="page page-id-2 page-template page-template-default logged-in">

3.1 (branch): <body class="page page-id-2 page-template page-template-default logged-in admin-bar">

3.2 (branch): <body class="page page-id-2 logged-in admin-bar singular two-column right-sidebar">

so it's 3.0 and 3.1 which "incorrectly" gained these classes.

Thanks Dion, much appreciated.

I tend to agree, it probably shouldn't have appeared in the first place but now that it's been there for two complete versions it's become a surprise feature & isn't particularly buggy. It's why I made up option A - .page-template doubling up with .page is a clear case bug.

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In [18412]:

Restore page-template-default body class. props peterwilsoncc, fixes #18018 for trunk.

In [18413]:

Restore page-template-default body class. props peterwilsoncc, fixes #18018 for 3.2.

Note: See TracTickets for help on using tickets.