function test_multiple_different_iframes() { $content = ' <iframe src="https://player.vimeo.com/video/12345" width="500" height="281"></iframe> <iframe src="https://player.vimeo.com/video/67890" width="280" height="501"></iframe> <iframe src="https://player.vimeo.com/video/11111" width="700" height="601"></iframe> '; $expected = ' <amp-iframe src="https://player.vimeo.com/video/12345" width="500" height="281"></amp-iframe> <amp-iframe src="https://player.vimeo.com/video/67890" width="280" height="501"></amp-iframe> <amp-iframe src="https://player.vimeo.com/video/11111" width="700" height="601"></amp-iframe> '; $converter = new AMP_Iframe_Converter($content); $converted = $converter->convert(); $this->assertEquals($expected, $converted); }
public function transform() { $content = $this->original_content; $content = apply_filters('the_content', $content); // We run kses before AMP conversion due to a kses bug which doesn't allow hyphens (#34105-core). // Our custom kses handler strips out all not-allowed stuff and leaves in stuff that will be converted (like iframe, img, audio, video). // Technically, conversion should catch the tags so we shouldn't need to run it after anyway. $content = AMP_KSES::strip($content); // Convert HTML to AMP // see https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#html-tags) $scripts = array(); $converter = new AMP_Img_Converter($content); $content = $converter->convert(array('layout' => 'responsive')); $this->add_scripts($converter->get_scripts()); $converter = new AMP_Iframe_Converter($content); $content = $converter->convert(array('layout' => 'responsive')); $this->add_scripts($converter->get_scripts()); return $content; }