Make WordPress Core

Ticket #26642: 26642.2.diff

File 26642.2.diff, 2.7 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, style,
    66                                trim = tinymce.trim;
    77
    88                        id = b.match( /id=['"]([^'"]*)['"] ?/ );
     
    4747                                return c;
    4848                        }
    4949
    50                         width = parseInt( w, 10 ) + 10;
     50                        style = editor.getParam( 'wpeditimage_html5_captions', false ) ? '' : ' style="width: '+ ( parseInt( w, 10 ) + 10 ) +'px"';
    5151
    52                         return '<div class="mceTemp"><dl id="'+ id +'" class="wp-caption '+ cls +'" style="width: '+ width +'px">' +
     52                        return '<div class="mceTemp"><dl id="'+ id +'" class="wp-caption '+ cls +'"'+ style +'>' +
    5353                                '<dt class="wp-caption-dt">'+ img +'</dt><dd class="wp-caption-dd">'+ cap +'</dd></dl></div>';
    5454                });
    5555        }
  • src/wp-includes/media.php

     
    720720        if ( ! empty( $atts['id'] ) )
    721721                $atts['id'] = 'id="' . esc_attr( $atts['id'] ) . '" ';
    722722
     723        $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] );
     724
     725        if ( current_theme_supports( 'html5', 'caption' ) ) {
     726                return '<figure ' . $atts['id'] . 'class="' . esc_attr( $class ) . '">'
     727                . do_shortcode( $content ) . '<figcaption class="wp-caption-text">' . $atts['caption'] . '</figcaption></figure>';
     728        }
     729
    723730        $caption_width = 10 + $atts['width'];
    724731
    725732        /**
     
    743750        if ( $caption_width )
    744751                $style = 'style="width: ' . (int) $caption_width . 'px" ';
    745752
    746         $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] );
    747 
    748753        return '<div ' . $atts['id'] . $style . 'class="' . esc_attr( $class ) . '">'
    749754        . do_shortcode( $content ) . '<p class="wp-caption-text">' . $atts['caption'] . '</p></div>';
    750755}