- 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@38803 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz
2016-10-17 01:10:01 +00:00
parent d3dd6046d5
commit 79fdcbdb07
2 changed files with 23 additions and 0 deletions

View File

@@ -663,6 +663,7 @@ final class _WP_Editors {
if ( $post = get_post() ) {
$body_class .= ' post-type-' . sanitize_html_class( $post->post_type ) . ' post-status-' . sanitize_html_class( $post->post_status );
if ( post_type_supports( $post->post_type, 'post-formats' ) ) {
$post_format = get_post_format( $post );
if ( $post_format && ! is_wp_error( $post_format ) )
@@ -670,6 +671,11 @@ final class _WP_Editors {
else
$body_class .= ' post-format-standard';
}
if ( $page_template = get_page_template_slug( $post ) ) {
$page_template = str_replace( '.', '-', basename( $page_template, '.php' ) );
$body_class .= ' page-template-' . sanitize_html_class( $page_template );
}
}
$body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );