codysnider /
tt-rss
| 1 | <?php |
||
| 2 | class Af_Youtube_Embed extends Plugin { |
||
| 3 | private $host; |
||
| 4 | |||
| 5 | public function about() { |
||
| 6 | return array(1.0, |
||
| 7 | "Embed videos in Youtube RSS feeds (and whitelist Youtube iframes)", |
||
| 8 | "fox"); |
||
| 9 | } |
||
| 10 | |||
| 11 | public function init($host) { |
||
| 12 | $this->host = $host; |
||
| 13 | |||
| 14 | $host->add_hook($host::HOOK_RENDER_ENCLOSURE, $this); |
||
| 15 | $host->add_hook($host::HOOK_IFRAME_WHITELISTED, $this); |
||
| 16 | } |
||
| 17 | |||
| 18 | public function hook_iframe_whitelisted($src) { |
||
| 19 | return in_array($src, ["www.youtube.com", "youtube.com", "youtu.be"]); |
||
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
||
| 24 | */ |
||
| 25 | public function hook_render_enclosure($entry, $hide_images) { |
||
|
0 ignored issues
–
show
|
|||
| 26 | |||
| 27 | $matches = array(); |
||
| 28 | |||
| 29 | if (preg_match("/\/\/www\.youtube\.com\/v\/([\w-]+)/", $entry["url"], $matches) || |
||
| 30 | preg_match("/\/\/www\.youtube\.com\/watch?v=([\w-]+)/", $entry["url"], $matches) || |
||
| 31 | preg_match("/\/\/youtu.be\/([\w-]+)/", $entry["url"], $matches)) { |
||
| 32 | |||
| 33 | $vid_id = $matches[1]; |
||
| 34 | |||
| 35 | return "<iframe class=\"youtube-player\" |
||
| 36 | type=\"text/html\" width=\"640\" height=\"385\" |
||
| 37 | src=\"https://www.youtube.com/embed/$vid_id\" |
||
| 38 | allowfullscreen frameborder=\"0\"></iframe>"; |
||
| 39 | |||
| 40 | } |
||
| 41 | } |
||
| 42 | |||
| 43 | public function api_version() { |
||
| 44 | return 2; |
||
| 45 | } |
||
| 46 | |||
| 47 | } |
||
| 48 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.