mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@38803 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user