vimeo-embed.php
1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/*
Plugin Name: Embedded Vimeo videos
Description: Parse embedded videos from Vimeo
Version: 1.0
Author: Janis Elsts
ModuleCategory: parser
ModuleClassName: blcVimeoEmbed
ModuleContext: on-demand
ModuleLazyInit: true
*/
if ( ! class_exists( 'blcEmbedParserBase' ) ) {
require 'embed-parser-base.php';
}
class blcVimeoEmbed extends blcEmbedParserBase {
var $supported_formats = array( 'html' );
function init() {
parent::init();
$this->url_search_string = 'vimeo.com/moogaloop.swf?';
$this->short_title = __( 'Vimeo Video', 'broken-link-checker' );
$this->long_title = __( 'Embedded Vimeo video', 'broken-link-checker' );
}
function link_url_from_src( $src ) {
//Extract video ID from the SRC
$components = @parse_url( $src );
if ( empty( $components['query'] ) ) {
return '';
}
parse_str( $components['query'], $query );
if ( empty( $query['clip_id'] ) ) {
return '';
} else {
$video_id = $query['clip_id'];
}
//Reconstruct the video permalink based on the ID
$url = 'http://vimeo.com/' . $video_id;
return $url;
}
}