Make WordPress Core

Ticket #23198: 23198.2.diff

File 23198.2.diff, 2.6 KB (added by adamsilverstein, 11 years ago)

updated tinymce container class dynamically when changing post-format

  • wp-includes/post-template.php

     
    13091309        $date = date_i18n( $datef, strtotime( $revision->post_modified ) );
    13101310        if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )
    13111311                $date = "<a href='$link'>$date</a>";
    1312        
     1312
    13131313        $revision_date_author = sprintf(
    13141314                '%s %s, %s %s (%s)',
    13151315                $gravatar,
  • wp-includes/class-wp-editor.php

     
    395395                        }
    396396
    397397                        $body_class = $editor_id;
     398                        $post = get_post();
    398399
    399                         if ( $post = get_post() )
    400                                 $body_class .= ' post-type-' . $post->post_type;
     400                        if ( $post ) {
     401                                $body_class .= ' post-type-' . $post->post_type . ' post-status-' . $post->post_status;
     402                                if ( post_type_supports( $post->post_type, 'post-formats' ) ) {
     403                                        $post_format = get_post_format( $post );
     404                                        if ( $post_format && ! is_wp_error( $post_format ) )
     405                                                $body_class .= ' post-format-' . sanitize_html_class( $post_format );
     406                                        else
     407                                                $body_class .= ' post-format-standard';
     408                                }
     409                        }
    401410
    402411                        if ( !empty($set['tinymce']['body_class']) ) {
    403412                                $body_class .= ' ' . $set['tinymce']['body_class'];
  • wp-admin/js/post-formats.js

     
    1212                $this.addClass('nav-tab-active').blur();
    1313                $('#post_format').val(format);
    1414                $('#post-body-content').attr('class', 'wp-format-' + format );
     15
     16                var ed = tinymce.get( 'content' ), edBody, format;
     17                if ( ed && this.id ) {
     18                        edBody = ed.getBody();
     19                        format = 'post-format-' + this.id; // also need to handle 'post-format-0'
     20                        edBody.className = edBody.className.replace( /\bpost-format-[^ ]+/, '' );
     21                        ed.dom.addClass( edBody, format );
     22                }
    1523        });
    1624
    1725        // Image selection
  • wp-admin/edit-form-advanced.php

     
    343343                else
    344344                        $class = 'nav-tab';
    345345
    346                 echo '<a class="' . $class . '" href="?format=' . $slug . '" data-wp-format="' . $slug . '">' . $label . '</a>';
     346                echo '<a id="' . $slug . '" class="' . $class . '" href="?format=' . $slug . '" data-wp-format="' . $slug . '">' . $label . '</a>';
    347347        }
    348348
    349349        echo '</h2>';