Changeset 36240
- Timestamp:
- 01/09/2016 02:17:02 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r36121 r36240 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. … … 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 ) { … … 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 … … 2408 2412 'width' => 640, 2409 2413 'height' => 360, 2414 'class' => 'wp-video-shortcode', 2410 2415 ); 2411 2416 … … 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'] ), -
trunk/tests/phpunit/tests/media.php
r36121 r36240 416 416 $matches2 = get_media_embedded_in_content( $reversed, array( 'audio', 'video' ) ); 417 417 $this->assertEquals( array( $video, $audio ), $matches2 ); 418 } 419 420 /** 421 * @ticket 35367 422 */ 423 function test_wp_audio_shortcode_with_empty_params() { 424 $this->assertNull( wp_audio_shortcode( array() ) ); 425 } 426 427 /** 428 * @ticket 35367 429 */ 430 function test_wp_audio_shortcode_with_bad_attr() { 431 $this->assertSame( 432 '<a class="wp-embedded-audio" href="https://example.com/foo.php">https://example.com/foo.php</a>', 433 wp_audio_shortcode( array( 434 'src' => 'https://example.com/foo.php', 435 ) ) 436 ); 437 } 438 439 /** 440 * @ticket 35367 441 */ 442 function test_wp_audio_shortcode_attributes() { 443 $actual = wp_audio_shortcode( array( 444 'src' => 'https://example.com/foo.mp3', 445 ) ); 446 447 $this->assertContains( 'src="https://example.com/foo.mp3', $actual ); 448 $this->assertNotContains( 'loop', $actual ); 449 $this->assertNotContains( 'autoplay', $actual ); 450 $this->assertContains( 'preload="none"', $actual ); 451 $this->assertContains( 'class="wp-audio-shortcode"', $actual ); 452 $this->assertContains( 'style="width: 100%; visibility: hidden;"', $actual ); 453 454 $actual = wp_audio_shortcode( array( 455 'src' => 'https://example.com/foo.mp3', 456 'loop' => true, 457 'autoplay' => true, 458 'preload' => true, 459 'class' => 'foobar', 460 'style' => 'padding:0;', 461 ) ); 462 463 $this->assertContains( 'src="https://example.com/foo.mp3', $actual ); 464 $this->assertContains( 'loop="1"', $actual ); 465 $this->assertContains( 'autoplay="1"', $actual ); 466 $this->assertContains( 'preload="1"', $actual ); 467 $this->assertContains( 'class="foobar"', $actual ); 468 $this->assertContains( 'style="padding:0;"', $actual ); 469 } 470 471 /** 472 * @ticket 35367 473 * @depends test_video_shortcode_body 474 */ 475 function test_wp_video_shortcode_with_empty_params() { 476 $this->assertNull( wp_video_shortcode( array() ) ); 477 } 478 479 /** 480 * @ticket 35367 481 * @depends test_video_shortcode_body 482 */ 483 function test_wp_video_shortcode_with_bad_attr() { 484 $this->assertSame( 485 '<a class="wp-embedded-video" href="https://example.com/foo.php">https://example.com/foo.php</a>', 486 wp_video_shortcode( array( 487 'src' => 'https://example.com/foo.php', 488 ) ) 489 ); 490 } 491 492 /** 493 * @ticket 35367 494 * @depends test_video_shortcode_body 495 */ 496 function test_wp_video_shortcode_attributes() { 497 $actual = wp_video_shortcode( array( 498 'src' => 'https://example.com/foo.mp4', 499 ) ); 500 501 $this->assertContains( 'src="https://example.com/foo.mp4', $actual ); 502 $this->assertNotContains( 'loop', $actual ); 503 $this->assertNotContains( 'autoplay', $actual ); 504 $this->assertContains( 'preload="metadata"', $actual ); 505 $this->assertContains( 'width="640"', $actual ); 506 $this->assertContains( 'height="360"', $actual ); 507 $this->assertContains( 'class="wp-video-shortcode"', $actual ); 508 509 $actual = wp_video_shortcode( array( 510 'src' => 'https://example.com/foo.mp4', 511 'poster' => 'https://example.com/foo.png', 512 'loop' => true, 513 'autoplay' => true, 514 'preload' => true, 515 'width' => 123, 516 'height' => 456, 517 'class' => 'foobar', 518 ) ); 519 520 $this->assertContains( 'src="https://example.com/foo.mp4', $actual ); 521 $this->assertContains( 'poster="https://example.com/foo.png', $actual ); 522 $this->assertContains( 'loop="1"', $actual ); 523 $this->assertContains( 'autoplay="1"', $actual ); 524 $this->assertContains( 'preload="1"', $actual ); 525 $this->assertContains( 'width="123"', $actual ); 526 $this->assertContains( 'height="456"', $actual ); 527 $this->assertContains( 'class="foobar"', $actual ); 418 528 } 419 529
Note: See TracChangeset
for help on using the changeset viewer.