Make WordPress Core

Ticket #26642: 26642.8.diff

File 26642.8.diff, 3.6 KB (added by obenland, 11 years ago)
  • src/wp-includes/class-wp-editor.php

     
    333333                                        'preview_styles' => 'font-family font-size font-weight font-style text-decoration text-transform',
    334334
    335335                                        'wpeditimage_disable_captions' => $no_captions,
     336                                        'wpeditimage_html5_captions' => current_theme_supports( 'html5', 'caption' ),
    336337                                        'plugins' => implode( ',', $plugins ),
    337338                                );
    338339
  • src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js

     
    22tinymce.PluginManager.add( 'wpeditimage', function( editor ) {
    33        function parseShortcode( content ) {
    44                return content.replace( /(?:<p>)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?/g, function( a, b, c ) {
    5                         var id, cls, w, cap, img, width,
     5                        var id, cls, w, cap, img, width, style,
    66                                trim = tinymce.trim;
    77
    88                        id = b.match( /id=['"]([^'"]*)['"] ?/ );
     
    4747                                return c;
    4848                        }
    4949
    50                         width = parseInt( w, 10 ) + 10;
     50                        if ( editor.getParam( 'wpeditimage_html5_captions' ) ) {
     51                                style = '';
     52                        } else {
     53                                width = parseInt( w, 10 ) + 10;
     54                                style = ' style="width: '+ width +'px"';
     55                        }
    5156
    52                         return '<div class="mceTemp"><dl id="'+ id +'" class="wp-caption '+ cls +'" style="width: '+ width +'px">' +
     57                        return '<div class="mceTemp"><dl id="'+ id +'" class="wp-caption '+ cls +'"'+ style +'>' +
    5358                                '<dt class="wp-caption-dt">'+ img +'</dt><dd class="wp-caption-dd">'+ cap +'</dd></dl></div>';
    5459                });
    5560        }
     
    618623
    619624                        // Remove toolbar to avoid an orphaned toolbar when dragging an image to a new location
    620625                        removeToolbar();
    621 
    622626                });
    623627
    624628                // Prevent IE11 from making dl.wp-caption resizable
  • src/wp-includes/js/tinymce/skins/wordpress/wp-content.css

     
    6666        margin: 0;
    6767}
    6868
     69/* HTML5 captions */
     70.wp-caption:not([style]) {
     71        padding: 4px;
     72}
     73.wp-caption.aligncenter:not([style]) {
     74        display: table;
     75}
     76.wp-caption.alignnone:not([style]) {
     77        display: inline-block;
     78}
     79
    6980pre {
    7081        font: 12px/18px Consolas, Monaco, monospace;
    7182}
  • src/wp-includes/media.php

     
    765765        if ( ! empty( $atts['id'] ) )
    766766                $atts['id'] = 'id="' . esc_attr( $atts['id'] ) . '" ';
    767767
     768        $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] );
     769
     770        if ( current_theme_supports( 'html5', 'caption' ) ) {
     771                return '<figure ' . $atts['id'] . 'class="' . esc_attr( $class ) . '">'
     772                . do_shortcode( $content ) . '<figcaption class="wp-caption-text">' . $atts['caption'] . '</figcaption></figure>';
     773        }
     774
    768775        $caption_width = 10 + $atts['width'];
    769776
    770777        /**
     
    788795        if ( $caption_width )
    789796                $style = 'style="width: ' . (int) $caption_width . 'px" ';
    790797
    791         $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] );
    792 
    793798        return '<div ' . $atts['id'] . $style . 'class="' . esc_attr( $class ) . '">'
    794799        . do_shortcode( $content ) . '<p class="wp-caption-text">' . $atts['caption'] . '</p></div>';
    795800}