Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#39368 closed defect (bug) (fixed)

.page-template-default body class in editor doesn't appear in initial post/page load.

Reported by: timph Owned by: azaozz
Priority: normal Milestone: 4.7.1
Component: Editor Version: 4.7
Severity: normal Keywords: has-patch
Cc: Focuses:

Description

The class .page-template-default isn't in tinymce editor body classes on initial load if default template is used. It was causing some odd behaviors when I was testing some themes out. This was because the themes were adding specific styles for .page-template-default. This class seems to only get added when you select a template from Page Attributes > Default, and there were some major visual differences from initial page load to what would be seen when selecting that template from page attributes. I think for consistency it should be present if that's the template in use.

  1. Add a page template to the theme. Mine was page-home.php
  2. Add a new page. This should use the default template.
  3. Inspect the body classes of the editor, there's no class added to designate this is the page-template-default at this point.
  4. Under Page Attributes, select Home. Inspect the body classes, you'll see page-template-page-home is applied.
  5. Select the Default template, you'll see page-template-default is applied and page-template-page-home is removed.
  6. Select the home page template again.
  7. Publish the page. Inspect the body class you'll see it's still there. Refresh the page. It's still there.
  8. Select the default template, then update the page and refresh. You'll see that the class is no longer present.

Attachments (1)

39368.patch (761 bytes ) - added by azaozz 10 years ago.

Download all attachments as: .zip

Change History (7)

#1 @ocean90
10 years ago

  • Keywords needs-patch added
  • Milestone Awaiting ReviewFuture Release

Confirmed, tested with Twenty Twelve. The additional classes were introduced in #37599.

@azaozz
10 years ago

#2 @azaozz
10 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone Future Release4.7.1

39368.patch should fix this. Moving to 4.7 for consideration.

I'm not sure what the best behavior is here. Adding page-template-default when the template is determined by the template hierarchy (i.e. we don't know the exact template that is used) doesn't seem that good. Not adding anything seems better?

However in the editor we should match what happens on the front-end. Related #18375 and [38951].

Last edited 10 years ago by azaozz (previous) (diff)

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


10 years ago

#4 @azaozz
10 years ago

  • Owner set to azaozz
  • Resolutionfixed
  • Status newclosed

In 39678:

Always add page-template-default class to the editor body when the template is not specified. This matches the behavior on the front-end.

Props timph (for the detailed bug report), azaozz.
Fixes #39368 for trunk.

#5 @azaozz
10 years ago

Reopen for 4.7.

#6 @azaozz
10 years ago

In 39679:

Always add page-template-default class to the editor body when the template is not specified. This matches the behavior on the front-end.

Props timph (for the detailed bug report), azaozz.
Merges [39678] to the 4.7 branch.
Fixes #39368.

Note: See TracTickets for help on using tickets.