From 2c5ad0030f565bd9c58c3302994786f864d2ef17 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sat, 16 Mar 2013 05:57:54 +0000 Subject: [PATCH] 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 --- wp-admin/js/post-formats.js | 24 +++++++++++++++++++----- wp-includes/class-wp-editor.php | 12 ++++++++++-- wp-includes/post-template.php | 2 +- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/wp-admin/js/post-formats.js b/wp-admin/js/post-formats.js index 27f638aa07..fd0f3c5357 100644 --- a/wp-admin/js/post-formats.js +++ b/wp-admin/js/post-formats.js @@ -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 diff --git a/wp-includes/class-wp-editor.php b/wp-includes/class-wp-editor.php index 38ab7c262f..da5ebb5049 100644 --- a/wp-includes/class-wp-editor.php +++ b/wp-includes/class-wp-editor.php @@ -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']; diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index 7117c33e33..aa37a9c5e6 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -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 = "$date"; - + $revision_date_author = sprintf( '%s %s, %s %s (%s)', $gravatar,