コード例 #1
0
 /**
  * @dataProvider get_scripts_data
  */
 public function test__get_scripts($source, $expected)
 {
     $embed = new AMP_YouTube_Embed_Handler();
     $embed->register_embed();
     apply_filters('the_content', $source);
     $scripts = $embed->get_scripts();
     $this->assertEquals($expected, $scripts);
 }
コード例 #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;
 }
コード例 #3
0
 public function transform()
 {
     $content = $this->original_content;
     $twitter_embed = new AMP_Twitter_Embed_Handler();
     $youtube_embed = new AMP_YouTube_Embed_Handler();
     $gallery_embed = new AMP_Gallery_Embed_Handler();
     $instagram_embed = new AMP_Instagram_Embed_Handler();
     $content = apply_filters('the_content', $content);
     $this->add_scripts($twitter_embed->get_scripts());
     $this->add_scripts($youtube_embed->get_scripts());
     $this->add_scripts($gallery_embed->get_scripts());
     $this->add_scripts($instagram_embed->get_scripts());
     $dom = AMP_DOM_Utils::get_dom_from_content($content);
     $this->sanitize(new AMP_Blacklist_Sanitizer($dom, $this->args));
     $this->sanitize(new AMP_Img_Sanitizer($dom, $this->args));
     $this->sanitize(new AMP_Video_Sanitizer($dom, $this->args));
     $this->sanitize(new AMP_Iframe_Sanitizer($dom, $this->args));
     $this->sanitize(new AMP_Audio_Sanitizer($dom, $this->args));
     $content = AMP_DOM_Utils::get_content_from_dom($dom);
     return $content;
 }