forked from bigfa/wp-douban
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathembed.php
23 lines (20 loc) · 912 Bytes
/
embed.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
wp_embed_register_handler( 'doubanlist', '#https?:\/\/(\w+)\.douban\.com\/subject\/(\d+)#i', 'wp_embed_handler_doubanlist' );
wp_embed_register_handler( 'doubanalbum', '#https?:\/\/www\.douban\.com\/photos\/album\/(\d+)#i', 'wp_embed_handler_doubanablum' );
function wp_embed_handler_doubanablum( $matches, $attr, $url, $rawattr ){
if(! is_singular() ) return $url;
$type = $matches[1];
$html = display_album_detail($type);
return apply_filters( 'embed_forbes', $html, $matches, $attr, $url, $rawattr );
}
function wp_embed_handler_doubanlist( $matches, $attr, $url, $rawattr ){
if(! is_singular() ) return $url;
$type = $matches[1];
$id = $matches[2];
if ( $type == 'movie' ) {
$html = display_movie_detail($id);
} else {
return $url;
}
return apply_filters( 'embed_forbes', $html, $matches, $attr, $url, $rawattr );
}