Ticket #35367: 35367.diff
File 35367.diff, 6.8 KB (added by , 10 years ago) |
---|
-
src/wp-includes/media.php
diff --git src/wp-includes/media.php src/wp-includes/media.php index 7a41653..65842d0 100644
function wp_get_attachment_id3_keys( $attachment, $context = 'display' ) { 2163 2163 * @type string $src URL to the source of the audio file. Default empty. 2164 2164 * @type string $loop The 'loop' attribute for the `<audio>` element. Default empty. 2165 2165 * @type string $autoplay The 'autoplay' attribute for the `<audio>` element. Default empty. 2166 * @type string $preload The 'preload' attribute for the `<audio>` element. Default empty.2166 * @type string $preload The 'preload' attribute for the `<audio>` element. Default 'none'. 2167 2167 * @type string $class The 'class' attribute for the `<audio>` element. Default 'wp-audio-shortcode'. 2168 * @type string $style The 'style' attribute for the `<audio>` element. Default 'width: 100% '.2168 * @type string $style The 'style' attribute for the `<audio>` element. Default 'width: 100%; visibility: hidden;'. 2169 2169 * } 2170 2170 * @param string $content Shortcode content. 2171 2171 * @return string|void HTML content to display audio. … … function wp_audio_shortcode( $attr, $content = '' ) { 2200 2200 'src' => '', 2201 2201 'loop' => '', 2202 2202 'autoplay' => '', 2203 'preload' => 'none' 2203 'preload' => 'none', 2204 'class' => 'wp-audio-shortcode', 2205 'style' => 'width: 100%; visibility: hidden;' 2204 2206 ); 2205 2207 foreach ( $default_types as $type ) { 2206 2208 $defaults_atts[$type] = ''; … … function wp_audio_shortcode( $attr, $content = '' ) { 2262 2264 * 2263 2265 * @param string $class CSS class or list of space-separated classes. 2264 2266 */ 2267 $atts['class'] = apply_filters( 'wp_audio_shortcode_class', $atts['class'] ); 2268 2265 2269 $html_atts = array( 2266 'class' => apply_filters( 'wp_audio_shortcode_class', 'wp-audio-shortcode' ),2270 'class' => $atts['class'], 2267 2271 'id' => sprintf( 'audio-%d-%d', $post_id, $instance ), 2268 2272 'loop' => wp_validate_boolean( $atts['loop'] ), 2269 2273 'autoplay' => wp_validate_boolean( $atts['autoplay'] ), 2270 2274 'preload' => $atts['preload'], 2271 'style' => 'width: 100%; visibility: hidden;',2275 'style' => $atts['style'], 2272 2276 ); 2273 2277 2274 2278 // These ones should just be omitted altogether if they are blank … … function wp_video_shortcode( $attr, $content = '' ) { 2407 2411 'preload' => 'metadata', 2408 2412 'width' => 640, 2409 2413 'height' => 360, 2414 'class' => 'wp-video-shortcode', 2410 2415 ); 2411 2416 2412 2417 foreach ( $default_types as $type ) { … … function wp_video_shortcode( $attr, $content = '' ) { 2496 2501 * 2497 2502 * @param string $class CSS class or list of space-separated classes. 2498 2503 */ 2504 $atts['class'] = apply_filters( 'wp_video_shortcode_class', $atts['class'] ); 2505 2499 2506 $html_atts = array( 2500 'class' => apply_filters( 'wp_video_shortcode_class', 'wp-video-shortcode' ),2507 'class' => $atts['class'], 2501 2508 'id' => sprintf( 'video-%d-%d', $post_id, $instance ), 2502 2509 'width' => absint( $atts['width'] ), 2503 2510 'height' => absint( $atts['height'] ), -
tests/phpunit/tests/media.php
diff --git tests/phpunit/tests/media.php tests/phpunit/tests/media.php index 5fa4fab..0ff06da 100644
CAP; 118 118 $this->assertEquals( 1, preg_match_all( "~wp-caption-text.*{$content_preg}~", $result, $_r ) ); 119 119 } 120 120 121 /** 122 * @ticket 35367 123 */ 124 function test_wp_audio_shortcode_with_empty_params() { 125 $this->assertNull( wp_audio_shortcode( array() ) ); 126 } 127 128 /** 129 * @ticket 35367 130 */ 131 function test_wp_audio_shortcode_with_bad_attr() { 132 $this->assertSame( 133 '<a class="wp-embedded-audio" href="https://example.com/foo.php">https://example.com/foo.php</a>', 134 wp_audio_shortcode( array( 135 'src' => 'https://example.com/foo.php', 136 ) ) 137 ); 138 } 139 140 /** 141 * @ticket 35367 142 */ 143 function test_wp_audio_shortcode_attributes() { 144 $actual = wp_audio_shortcode( array( 145 'src' => 'https://example.com/foo.mp3', 146 ) ); 147 148 $this->assertContains( 'src="https://example.com/foo.mp3', $actual ); 149 $this->assertNotContains( 'loop', $actual ); 150 $this->assertNotContains( 'autoplay', $actual ); 151 $this->assertContains( 'preload="none"', $actual ); 152 $this->assertContains( 'class="wp-audio-shortcode"', $actual ); 153 $this->assertContains( 'style="width: 100%; visibility: hidden;"', $actual ); 154 155 $actual = wp_audio_shortcode( array( 156 'src' => 'https://example.com/foo.mp3', 157 'loop' => true, 158 'autoplay' => true, 159 'preload' => true, 160 'class' => 'foobar', 161 'style' => 'padding:0;', 162 ) ); 163 164 $this->assertContains( 'src="https://example.com/foo.mp3', $actual ); 165 $this->assertContains( 'loop="1"', $actual ); 166 $this->assertContains( 'autoplay="1"', $actual ); 167 $this->assertContains( 'preload="1"', $actual ); 168 $this->assertContains( 'class="foobar"', $actual ); 169 $this->assertContains( 'style="padding:0;"', $actual ); 170 } 171 172 /** 173 * @ticket 35367 174 */ 175 function test_wp_video_shortcode_with_empty_params() { 176 $this->assertNull( wp_video_shortcode( array() ) ); 177 } 178 179 /** 180 * @ticket 35367 181 */ 182 function test_wp_video_shortcode_with_bad_attr() { 183 $this->assertSame( 184 '<a class="wp-embedded-video" href="https://example.com/foo.php">https://example.com/foo.php</a>', 185 wp_video_shortcode( array( 186 'src' => 'https://example.com/foo.php', 187 ) ) 188 ); 189 } 190 191 /** 192 * @ticket 35367 193 */ 194 function test_wp_video_shortcode_attributes() { 195 $actual = wp_video_shortcode( array( 196 'src' => 'https://example.com/foo.mp4', 197 ) ); 198 199 $this->assertContains( 'src="https://example.com/foo.mp4', $actual ); 200 $this->assertNotContains( 'loop', $actual ); 201 $this->assertNotContains( 'autoplay', $actual ); 202 $this->assertContains( 'preload="metadata"', $actual ); 203 $this->assertContains( 'width="640"', $actual ); 204 $this->assertContains( 'height="360"', $actual ); 205 $this->assertContains( 'class="wp-video-shortcode"', $actual ); 206 207 $actual = wp_video_shortcode( array( 208 'src' => 'https://example.com/foo.mp4', 209 'poster' => 'https://example.com/foo.png', 210 'loop' => true, 211 'autoplay' => true, 212 'preload' => true, 213 'width' => 123, 214 'height' => 456, 215 'class' => 'foobar', 216 ) ); 217 218 $this->assertContains( 'src="https://example.com/foo.mp4', $actual ); 219 $this->assertContains( 'poster="https://example.com/foo.png', $actual ); 220 $this->assertContains( 'loop="1"', $actual ); 221 $this->assertContains( 'autoplay="1"', $actual ); 222 $this->assertContains( 'preload="1"', $actual ); 223 $this->assertContains( 'width="123"', $actual ); 224 $this->assertContains( 'height="456"', $actual ); 225 $this->assertContains( 'class="foobar"', $actual ); 226 } 227 121 228 function test_add_remove_oembed_provider() { 122 229 wp_oembed_add_provider( 'http://foo.bar/*', 'http://foo.bar/oembed' ); 123 230 $this->assertTrue( wp_oembed_remove_provider( 'http://foo.bar/*' ) );