Ticket #27292: 27292.3.diff
| File 27292.3.diff, 2.9 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/media.php
765 765 if ( ! empty( $atts['id'] ) ) 766 766 $atts['id'] = 'id="' . esc_attr( $atts['id'] ) . '" '; 767 767 768 $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] ); 768 $caption_width = $atts['width']; 769 $html5 = current_theme_supports( 'html5', 'caption' ); 769 770 770 if ( current_theme_supports( 'html5', 'caption' ) ) { 771 return '<figure ' . $atts['id'] . 'style="width: ' . (int) $atts['width'] . 'px;" class="' . esc_attr( $class ) . '">' 772 . do_shortcode( $content ) . '<figcaption class="wp-caption-text">' . $atts['caption'] . '</figcaption></figure>'; 771 if ( ! $html5 ) { 772 $caption_width += 10; 773 773 } 774 774 775 $caption_width = 10 + $atts['width'];776 777 775 /** 778 776 * Filter the width of an image's caption. 779 777 * … … 795 793 if ( $caption_width ) 796 794 $style = 'style="width: ' . (int) $caption_width . 'px" '; 797 795 798 return '<div ' . $atts['id'] . $style . 'class="' . esc_attr( $class ) . '">' 799 . do_shortcode( $content ) . '<p class="wp-caption-text">' . $atts['caption'] . '</p></div>'; 796 $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] ); 797 798 $itemtag = $html5 ? 'figure' : 'div'; 799 $captiontag = $html5 ? 'figcaption' : 'p'; 800 801 return "<$itemtag " . $atts['id'] . $style . 'class="' . esc_attr( $class ) . '">' 802 . do_shortcode( $content ) . "<$captiontag " . 'class="wp-caption-text">' . $atts['caption'] . "</$captiontag></$itemtag>"; 800 803 } 801 804 802 805 add_shortcode('gallery', 'gallery_shortcode'); -
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 27292 113 */ 114 function test_new_img_caption_shortcode_new_format_html5() { 115 add_theme_support( 'html5', array( 'caption' ) ); 116 add_filter( 'img_caption_shortcode_width', array( $this, 'filter_img_caption_shortcode_width' ) ); 117 118 $result = img_caption_shortcode( 119 array( 'width' => 20 ), 120 $this->img_content . $this->html_content 121 ); 122 123 $expected = '<figure style="width: 30px" class="wp-caption alignnone">' . $this->img_content . 124 '<figcaption class="wp-caption-text">' . $this->html_content . '</figcaption></figure>'; 125 $this->assertEquals( $expected, $result ); 126 127 remove_filter( 'img_caption_shortcode_width', array( $this, 'filter_img_caption_shortcode_width' ) ); 128 remove_theme_support( 'html5' ); 129 } 130 131 function filter_img_caption_shortcode_width( $caption_width ) { 132 return 30; 133 } 134 111 135 function test_add_remove_oembed_provider() { 112 136 wp_oembed_add_provider( 'http://foo.bar/*', 'http://foo.bar/oembed' ); 113 137 $this->assertTrue( wp_oembed_remove_provider( 'http://foo.bar/*' ) );