WordPress.org

Make WordPress Core

Opened 15 months ago

Closed 12 months ago

Last modified 10 months ago

#37599 closed enhancement (fixed)

Editor (WP_Editor or TinyMCE) page template body class

Reported by: webmandesign Owned by: azaozz
Milestone: 4.7 Priority: normal
Severity: normal Version:
Component: TinyMCE Keywords: has-patch
Focuses: Cc:

Description

Hi,

Currently the post editor (TinyMCE) applies several classes on the editor's HTML body#tinymce:

  • Post type class
  • Post status class
  • If supported, post format class

However, it would be good idea to support a page template classes here too.

Usecase:

Theme author may target different content widths within editor stylesheet depending on the page template set. Such as for fullwidth page template or page with sidebar template.

Thanks for consideration!

Regards,

Oliver

Attachments (1)

37599.patch (2.2 KB) - added by webmandesign 14 months ago.
Adding a page template CSS class on TinyMCE body

Download all attachments as: .zip

Change History (8)

#1 follow-up: @azaozz
14 months ago

  • Focuses ui template removed
  • Milestone changed from Awaiting Review to Future Release
  • Version 4.5.3 deleted

Assuming that class will have to change "dynamically" when selecting another template from the drop-down, the same way post type classes work. This is fairly easy to do from a plugin or theme, but maybe it should happen by default.

Last edited 14 months ago by azaozz (previous) (diff)

#2 in reply to: ↑ 1 @webmandesign
14 months ago

Replying to azaozz:

Assuming that class will have to change "dynamically" when selecting another template from the drop-down, the same way post type classes work. This is fairly easy to do from a plugin or theme, but maybe it should happen by default.

Hi. Yes, I am doing this in the theme already (just not applying all the page template related classes as there is too many of them ;)) but I really think this should be part of the core.

@webmandesign
14 months ago

Adding a page template CSS class on TinyMCE body

#3 @webmandesign
14 months ago

  • Keywords has-patch added

I've made a patch for this. And judging by how the WordPress creates additional page template classes when applying them on HTML body on front-end, I think using simple page-template-{filename} class would be enough. Let me know if this is OK with you, guys.

#4 @azaozz
12 months ago

  • Milestone changed from Future Release to 4.7

#5 @azaozz
12 months ago

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

In 38803:

TinyMCE:

  • When editing pages, add body class with the page template, or page-template-default.
  • Change the page template class when the users select another template, similarly to changing the post type class for posts.

Props webmandesign.
Fixes #37599.

#6 @webmandesign
12 months ago

Thanks for including this in WP4.7!

#7 @ocean90
10 months ago

Follow-up: #39368 (.page-template-default body class in editor doesn't appear in initial post/page load)

Note: See TracTickets for help on using tickets.