Ticket #26642: 26642.6.diff
File 26642.6.diff, 4.9 KB (added by , 11 years ago) |
---|
-
src/wp-includes/class-wp-editor.php
333 333 'preview_styles' => 'font-family font-size font-weight font-style text-decoration text-transform', 334 334 335 335 'wpeditimage_disable_captions' => $no_captions, 336 'wpeditimage_no_inline_style_captions' => current_theme_supports( 'no-inline-style-captions' ), 336 337 'plugins' => implode( ',', $plugins ), 337 338 ); 338 339 -
src/wp-includes/media.php
785 785 $caption_width = apply_filters( 'img_caption_shortcode_width', $caption_width, $atts, $content ); 786 786 787 787 $style = ''; 788 if ( $caption_width )788 if ( $caption_width && ! current_theme_supports( 'no-inline-style-captions' ) ) 789 789 $style = 'style="width: ' . (int) $caption_width . 'px" '; 790 790 791 791 $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] ); -
src/wp-includes/js/tinymce/plugins/wpeditimage/plugin.js
2 2 tinymce.PluginManager.add( 'wpeditimage', function( editor ) { 3 3 function parseShortcode( content ) { 4 4 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, 6 6 trim = tinymce.trim; 7 7 8 8 id = b.match( /id=['"]([^'"]*)['"] ?/ ); … … 47 47 return c; 48 48 } 49 49 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 } 51 56 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 +'>' + 53 58 '<dt class="wp-caption-dt">'+ img +'</dt><dd class="wp-caption-dd">'+ cap +'</dd></dl></div>'; 54 59 }); 55 60 } … … 189 194 190 195 html = createImageAndLink( imageData, 'html' ); 191 196 192 width = imageData.width + 10;193 197 className = 'align' + imageData.align; 194 198 199 if ( editor.getParam( 'wpeditimage_no_inline_style_captions' ) ) { 200 style = ''; 201 } else { 202 width = imageData.width + 10; 203 style = ' style="width: '+ width +'px"'; 204 } 205 195 206 //TODO: shouldn't add the id attribute if it isn't an attachment 196 207 197 208 // should create a new function for generating the caption markup 198 html = '<dl id="'+ imageData.attachment_id +'" class="wp-caption '+ className +'" style="width: '+ width +'px">' +209 html = '<dl id="'+ imageData.attachment_id +'" class="wp-caption '+ className +'"'+ style +'>' + 199 210 '<dt class="wp-caption-dt">'+ html + '</dt><dd class="wp-caption-dd">'+ imageData.caption +'</dd></dl>'; 200 211 201 212 node = editor.dom.create( 'div', { 'class': 'mceTemp' }, html ); … … 475 486 if ( caption ) { 476 487 node = editor.selection.getNode(); 477 488 478 if ( data.width ) {489 if ( data.width && ! editor.getParam( 'wpeditimage_no_inline_style_captions' ) ) { 479 490 captionWidth = parseInt( data.width, 10 ) + 10; 480 491 captionWidth = ' style="width: '+ captionWidth +'px"'; 481 492 } … … 539 550 540 551 captionWidth = data.width || imgNode.clientWidth; 541 552 542 if ( captionWidth ) {553 if ( captionWidth && ! editor.getParam( 'wpeditimage_no_inline_style_captions' ) ) { 543 554 captionWidth = parseInt( captionWidth, 10 ) + 10; 544 555 captionWidth = ' style="width: '+ captionWidth +'px"'; 545 556 } -
tests/phpunit/tests/media.php
108 108 $this->assertEquals( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) ); 109 109 } 110 110 111 /** 112 * @ticket 26642 113 */ 114 function test_new_img_caption_shortcode_new_format_no_inline() { 115 add_theme_support( 'no-inline-style-captions' ); 116 $result = img_caption_shortcode( 117 array( 'width' => 20 ), 118 $this->img_content . $this->html_content 119 ); 120 $expected = '<div class="wp-caption alignnone">' . $this->img_content . '<p class="wp-caption-text">' . $this->html_content . '</p></div>'; 121 $this->assertEquals( $expected, $result ); 122 remove_theme_support( 'no-inline-style-captions' ); 123 } 124 111 125 function test_add_remove_oembed_provider() { 112 126 wp_oembed_add_provider( 'http://foo.bar/*', 'http://foo.bar/oembed' ); 113 127 $this->assertTrue( wp_oembed_remove_provider( 'http://foo.bar/*' ) );