Pass post format as a class to TinyMCE's body, props adamsilverstein, fixes #23198

git-svn-id: http://core.svn.wordpress.org/trunk@23730 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2013-03-16 05:57:54 +00:00
parent 53d12e91bc
commit 2c5ad0030f
3 changed files with 30 additions and 8 deletions

View File

@ -4,14 +4,28 @@ window.wp = window.wp || {};
var imageFrame;
// Post formats selection
$('.post-format-select a').on( 'click', function(e){
e.preventDefault();
var $this = $(this),
format = $this.data('wpFormat');
$('.post-format-select a').on( 'click.post-format', function(e) {
var $this = $(this), editor, body,
format = $this.data('wp-format'), container = $('#post-body-content');
$('.post-format-select a.nav-tab-active').removeClass('nav-tab-active');
$this.addClass('nav-tab-active').blur();
$('#post_format').val(format);
$('#post-body-content').attr('class', 'wp-format-' + format );
container.get(0).className = container.get(0).className.replace( /\bwp-format-[^ ]+/, '' );
container.addClass('wp-format-' + format);
if ( typeof tinymce != 'undefined' ) {
editor = tinymce.get('content');
if ( editor ) {
body = editor.getBody();
body.className = body.className.replace( /\bpost-format-[^ ]+/, '' );
editor.dom.addClass( body, 'post-format-' + format );
}
}
e.preventDefault();
});
// Image selection

View File

@ -396,8 +396,16 @@ final class _WP_Editors {
$body_class = $editor_id;
if ( $post = get_post() )
$body_class .= ' post-type-' . $post->post_type;
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 ) )
$body_class .= ' post-format-' . sanitize_html_class( $post_format );
else
$body_class .= ' post-format-standard';
}
}
if ( !empty($set['tinymce']['body_class']) ) {
$body_class .= ' ' . $set['tinymce']['body_class'];

View File

@ -1315,7 +1315,7 @@ function wp_post_revision_title( $revision, $link = true ) {
$date = date_i18n( $datef, strtotime( $revision->post_modified ) );
if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )
$date = "<a href='$link'>$date</a>";
$revision_date_author = sprintf(
'%s %s, %s %s (%s)',
$gravatar,