Make WordPress Core

Ticket #26642: 26642.4.diff

File 26642.4.diff, 2.4 KB (added by jond3r, 11 years ago)

Introduce a new theme support 'no-inline-style-captions'

  • 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_no_inline_style_captions' => current_theme_supports( 'no-inline-style-captions' ),
    336337                                        'plugins' => implode( ',', $plugins ),
    337338                                );
    338339
  • src/wp-includes/media.php

     
    785785        $caption_width = apply_filters( 'img_caption_shortcode_width', $caption_width, $atts, $content );
    786786
    787787        $style = '';
    788         if ( $caption_width )
     788        if ( $caption_width && ! current_theme_supports( 'no-inline-style-captions' ) )
    789789                $style = 'style="width: ' . (int) $caption_width . 'px" ';
    790790
    791791        $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] );
  • 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_no_inline_style_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        }