Example #1
0
 function test_strip_attribute_recursive()
 {
     $source = '<div style="border: 1px solid red;"><img src="/path/to/file.jpg" onclick="alert(e);" />Hello World</div>';
     $expected = '<div><img src="/path/to/file.jpg"/>Hello World</div>';
     $content = AMP_Sanitizer::strip($source);
     $this->assertEquals($expected, $content);
 }
Example #2
0
 public function transform()
 {
     $content = $this->original_content;
     $twitter_embed = new AMP_Twitter_Embed_Handler();
     $youtube_embed = new AMP_YouTube_Embed_Handler();
     $content = apply_filters('the_content', $content);
     $this->add_scripts($twitter_embed->get_scripts());
     $this->add_scripts($youtube_embed->get_scripts());
     $content = AMP_Sanitizer::strip($content);
     // Convert HTML to AMP
     // see https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#html-tags)
     $content = $this->convert(new AMP_Img_Converter($content), array('layout' => 'responsive'));
     $content = $this->convert(new AMP_Video_Converter($content), array('layout' => 'responsive'));
     $content = $this->convert(new AMP_Audio_Converter($content), array('layout' => 'responsive'));
     $content = $this->convert(new AMP_Iframe_Converter($content), array('layout' => 'responsive'));
     return $content;
 }