Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // support for
- // - Default Wordpress behavior without any wordpress plugin,
- // - Smart Youtube PRO
- // - YouTube
- // - Advanced YouTube Embed by Embed Plus
- foreach ($iframes as $iframe) {
- $url = $iframe->getAttribute('src');
- $videoId = $this->get_youtube_id_from_url($url);
- $containerElement = $dom->createElement('div');
- $containerClassAttribute = $this->createAttribute($dom, 'class', $containerCssClass);
- $containerElement->appendChild($containerClassAttribute);
- $linkElement = $dom->createElement('a', $linkText);
- $linkClassAttribute = $this->createAttribute($dom, 'class', $linkCssClass);
- $linkElement->appendChild($linkClassAttribute);
- $linkNoFollowAttribute = $this->createAttribute($dom, 'rel', 'nofollow');
- $linkElement->appendChild($linkNoFollowAttribute);
- $linkTargetAttribute = $this->createAttribute($dom, 'target', '_blank');
- $linkElement->appendChild($linkTargetAttribute);
- $Youtube2mp3Url = "http://www.yt-mp3.com/?url=http://www.youtube.com/watch?v=".$videoId;
- $linkHrefAttribute = $this->createAttribute($dom, 'href', $Youtube2mp3Url);
- $linkElement->appendChild($linkHrefAttribute);
- $containerElement->appendChild($linkElement);
- if($iframe->parentNode->nodeName != 'object'){
- $iframe->parentNode->appendChild($containerElement);
- }else{
- $iframe->parentNode->parentNode->appendChild($containerElement);
- }
- }
- // support for
- // - viper plugin
- $iframes = $xpath->query("//span[contains(@class,'vvqbox')]/span/a ");
- foreach ($iframes as $iframe) {
- $url = $iframe->getAttribute('href');
- $videoId = $this->get_youtube_id_from_url($url);
- $containerElement = $dom->createElement('div');
- $containerClassAttribute = $this->createAttribute($dom, 'class', $containerCssClass);
- $containerStyleAttribute = $this->createAttribute($dom, 'style', 'margin-top: -7px;');
- $containerElement->appendChild($containerStyleAttribute);
- $containerElement->appendChild($containerClassAttribute);
- $linkElement = $dom->createElement('a', $linkText);
- $linkClassAttribute = $this->createAttribute($dom, 'class', $linkCssClass);
- $linkElement->appendChild($linkClassAttribute);
- $linkNoFollowAttribute = $this->createAttribute($dom, 'rel', 'nofollow');
- $linkElement->appendChild($linkNoFollowAttribute);
- $linkTargetAttribute = $this->createAttribute($dom, 'target', '_blank');
- $linkElement->appendChild($linkTargetAttribute);
- $Youtube2mp3Url = "http://www.youtube-mp3.org/get?video_id=".$videoId;
- $linkHrefAttribute = $this->createAttribute($dom, 'href', $Youtube2mp3Url);
- $linkElement->appendChild($linkHrefAttribute);
- $containerElement->appendChild($linkElement);
- $iframe->parentNode->parentNode->appendChild($containerElement);
- }
- return utf8_decode($dom->saveHTML());
- }
- function createAttribute($dom, $name, $value){
- $attribute = $dom->createAttribute($name);
- $attribute->value = $value;
- return $attribute;
- }
- function get_youtube_id_from_url($url)
- {
- if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match)) {
- return $match[1];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement