PageRenderTime 25ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/broken-link-checker/modules/extras/youtube-embed.php

https://bitbucket.org/lgorence/quickpress
PHP | 40 lines | 18 code | 7 blank | 15 comment | 1 complexity | 6c13c8b447abbd787d7dba93489434cb MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, AGPL-1.0
  1. <?php
  2. /*
  3. Plugin Name: Embedded YouTube videos (old embed code)
  4. Description: Parse embedded videos from YouTube
  5. Version: 1.0
  6. Author: Janis Elsts
  7. ModuleCategory: parser
  8. ModuleClassName: blcYouTubeEmbed
  9. ModuleContext: on-demand
  10. ModuleLazyInit: true
  11. ModulePriority: 110
  12. */
  13. if ( !class_exists('blcEmbedParserBase') ){
  14. require 'embed-parser-base.php';
  15. }
  16. class blcYouTubeEmbed extends blcEmbedParserBase {
  17. function init(){
  18. parent::init();
  19. $this->short_title = __('YouTube Video', 'broken-link-checker');
  20. $this->long_title = __('Embedded YouTube video', 'broken-link-checker');
  21. $this->url_search_string = 'youtube.com/v/';
  22. }
  23. function link_url_from_src($src){
  24. //Extract video ID from the SRC. The ID is always 11 characters.
  25. $video_id = substr( end(explode('/', $src)), 0, 11 );
  26. //Reconstruct the video permalink based on the ID
  27. $url = 'http://www.youtube.com/watch?v='.$video_id;
  28. return $url;
  29. }
  30. }
  31. ?>