| 588 | /** |
| 589 | * @ticket 33016 |
| 590 | */ |
| 591 | function test_multiline_cdata() { |
| 592 | global $wp_embed; |
| 593 | |
| 594 | $content = <<<EOF |
| 595 | <script>// <![CDATA[ |
| 596 | _my_function('data'); |
| 597 | // ]]> |
| 598 | </script> |
| 599 | EOF; |
| 600 | |
| 601 | $result = $wp_embed->autoembed( $content ); |
| 602 | $this->assertEquals( $content, $result ); |
| 603 | } |
| 604 | |
| 605 | /** |
| 606 | * @ticket 33016 |
| 607 | */ |
| 608 | function test_multiline_comment() { |
| 609 | global $wp_embed; |
| 610 | |
| 611 | $content = <<<EOF |
| 612 | <script><!-- |
| 613 | my_function(); |
| 614 | // --> </script> |
| 615 | EOF; |
| 616 | |
| 617 | $result = $wp_embed->autoembed( $content ); |
| 618 | $this->assertEquals( $content, $result ); |
| 619 | } |
| 620 | |
| 621 | |
| 622 | /** |
| 623 | * @ticket 33016 |
| 624 | */ |
| 625 | function test_multiline_comment_with_embeds() { |
| 626 | $content = <<<EOF |
| 627 | Start. |
| 628 | [embed]http://www.youtube.com/embed/TEST01YRHA0[/embed] |
| 629 | <script><!-- |
| 630 | my_function(); |
| 631 | // --> </script> |
| 632 | http://www.youtube.com/embed/TEST02YRHA0 |
| 633 | [embed]http://www.example.com/embed/TEST03YRHA0[/embed] |
| 634 | http://www.example.com/embed/TEST04YRHA0 |
| 635 | Stop. |
| 636 | EOF; |
| 637 | |
| 638 | $expected = <<<EOF |
| 639 | <p>Start.<br /> |
| 640 | https://youtube.com/watch?v=TEST01YRHA0<br /> |
| 641 | <script><!-- |
| 642 | my_function(); |
| 643 | // --> </script><br /> |
| 644 | https://youtube.com/watch?v=TEST02YRHA0<br /> |
| 645 | <a href="http://www.example.com/embed/TEST03YRHA0">http://www.example.com/embed/TEST03YRHA0</a><br /> |
| 646 | http://www.example.com/embed/TEST04YRHA0<br /> |
| 647 | Stop.</p> |
| 648 | |
| 649 | EOF; |
| 650 | |
| 651 | $result = apply_filters('the_content', $content ); |
| 652 | $this->assertEquals( $expected, $result ); |
| 653 | } |
| 654 | |
| 655 | /** |
| 656 | * @ticket 33016 |
| 657 | */ |
| 658 | function filter_wp_embed_shortcode_custom( $custom, $attr, $url ) { |
| 659 | if ( $url === 'https://www.example.com/?video=1' ) { |
| 660 | $custom = "<iframe src='$url'></iframe>"; |
| 661 | } |
| 662 | return $custom; |
| 663 | } |
| 664 | |
| 665 | /** |
| 666 | * @ticket 33016 |
| 667 | */ |
| 668 | function test_oembed_explicit_media_link() { |
| 669 | global $wp_embed; |
| 670 | add_filter( 'wp_embed_shortcode_custom', array( $this, 'filter_wp_embed_shortcode_custom' ), 10, 3 ); |
| 671 | |
| 672 | $content = <<<EOF |
| 673 | https://www.example.com/?video=1 |
| 674 | EOF; |
| 675 | |
| 676 | $expected = <<<EOF |
| 677 | <iframe src='https://www.example.com/?video=1'></iframe> |
| 678 | EOF; |
| 679 | |
| 680 | $result = $wp_embed->autoembed( $content ); |
| 681 | $this->assertEquals( $expected, $result ); |
| 682 | |
| 683 | $content = <<<EOF |
| 684 | <a href="https://www.example.com/?video=1">https://www.example.com/?video=1</a> |
| 685 | EOF; |
| 686 | |
| 687 | $result = $wp_embed->autoembed( $content ); |
| 688 | $this->assertEquals( $content, $result ); |
| 689 | |
| 690 | remove_filter( 'wp_embed_shortcode_custom', array( $this, 'filter_wp_embed_shortcode_custom' ), 10 ); |
| 691 | } |