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. Built from https://develop.svn.wordpress.org/trunk@38803 git-svn-id: http://core.svn.wordpress.org/trunk@38746 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
374a079746
commit
4996d05355
|
@ -1167,6 +1167,23 @@ jQuery(document).ready( function($) {
|
|||
$( document ).trigger( 'editor-classchange' );
|
||||
}
|
||||
});
|
||||
|
||||
// When changing page template, change the editor body class
|
||||
$( '#page_template' ).on( 'change.set-editor-class', function() {
|
||||
var editor, body, pageTemplate = $( this ).val() || '';
|
||||
|
||||
pageTemplate = pageTemplate.substr( pageTemplate.lastIndexOf( '/' ) + 1, pageTemplate.length )
|
||||
.replace( /\.php$/, '' )
|
||||
.replace( /\./g, '-' );
|
||||
|
||||
if ( pageTemplate && ( editor = tinymce.get( 'content' ) ) ) {
|
||||
body = editor.getBody();
|
||||
body.className = body.className.replace( /\bpage-template-[^ ]+/, '' );
|
||||
editor.dom.addClass( body, 'page-template-' + pageTemplate );
|
||||
$( document ).trigger( 'editor-classchange' );
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// Save on pressing [ctrl]/[command] + [s] in the Text editor.
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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() ) ) );
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.7-alpha-38802';
|
||||
$wp_version = '4.7-alpha-38803';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue