WordPress.org

Make WordPress Core

Changeset 23730


Ignore:
Timestamp:
03/16/2013 05:57:54 AM (8 years ago)
Author:
azaozz
Message:

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

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/post-formats.js

    r23449 r23730  
    55
    66    // Post formats selection
    7     $('.post-format-select a').on( 'click', function(e){
    8         e.preventDefault();
    9         var $this = $(this),
    10             format = $this.data('wpFormat');
     7    $('.post-format-select a').on( 'click.post-format', function(e) {
     8        var $this = $(this), editor, body,
     9            format = $this.data('wp-format'), container = $('#post-body-content');
     10
    1111        $('.post-format-select a.nav-tab-active').removeClass('nav-tab-active');
    1212        $this.addClass('nav-tab-active').blur();
    1313        $('#post_format').val(format);
    14         $('#post-body-content').attr('class', 'wp-format-' + format );
     14
     15        container.get(0).className = container.get(0).className.replace( /\bwp-format-[^ ]+/, '' );
     16        container.addClass('wp-format-' + format);
     17
     18        if ( typeof tinymce != 'undefined' ) {
     19            editor = tinymce.get('content');
     20
     21            if ( editor ) {
     22                body = editor.getBody();
     23                body.className = body.className.replace( /\bpost-format-[^ ]+/, '' );
     24                editor.dom.addClass( body, 'post-format-' + format );
     25            }
     26        }
     27
     28        e.preventDefault();
    1529    });
    1630
  • trunk/wp-includes/class-wp-editor.php

    r23123 r23730  
    397397            $body_class = $editor_id;
    398398
    399             if ( $post = get_post() )
    400                 $body_class .= ' post-type-' . $post->post_type;
     399            if ( $post = get_post() ) {
     400                $body_class .= ' post-type-' . sanitize_html_class( $post->post_type ) . ' post-status-' . sanitize_html_class( $post->post_status );
     401                if ( post_type_supports( $post->post_type, 'post-formats' ) ) {
     402                    $post_format = get_post_format( $post );
     403                    if ( $post_format && ! is_wp_error( $post_format ) )
     404                        $body_class .= ' post-format-' . sanitize_html_class( $post_format );
     405                    else
     406                        $body_class .= ' post-format-standard';
     407                }
     408            }
    401409
    402410            if ( !empty($set['tinymce']['body_class']) ) {
  • trunk/wp-includes/post-template.php

    r23653 r23730  
    13161316    if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )
    13171317        $date = "<a href='$link'>$date</a>";
    1318    
     1318
    13191319    $revision_date_author = sprintf(
    13201320        '%s %s, %s %s (%s)',
Note: See TracChangeset for help on using the changeset viewer.