blob: 012b9c7ba3dccdf1bb31b13bf1c8df1bf7367d65 (
plain)
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
|
<?php
/*
* Slideshare shortcode format:
* [slideshare id=5342235&doc=camprock-101002163655-phpapp01&w=300&h=200]
**/
function slideshare_shortcode( $atts ) {
global $content_width;
$params = shortcode_new_to_old_params( $atts );
parse_str( $params, $arguments );
if ( empty( $arguments ) )
return "<!-- SlideShare error: no arguments -->";
extract( $arguments );
$pattern = '/[^-_a-zA-Z0-9]/';
if ( empty( $id ) || preg_match( $pattern, $id ) )
return "<!-- SlideShare error: id is missing or has illegal characters -->";
if ( empty( $doc ) || preg_match( $pattern, $doc ) )
return "<!-- SlideShare error: doc is missing or has illegal characters -->";
if ( empty( $w ) && !empty( $content_width ) )
$w = intval( $content_width );
elseif ( ! ( $w = intval( $w ) ) || $w < 300 || $w > 1600 )
$w = 425;
else
$w = intval( $w );
$h = ceil( $w * 348 / 425 );
$player = "<object type='application/x-shockwave-flash' wmode='opaque' data='http://static.slideshare.net/swf/ssplayer2.swf?id=$id&doc=$doc' width='$w' height='$h'><param name='movie' value='http://static.slideshare.net/swf/ssplayer2.swf?id=$id&doc=$doc' /><param name='allowFullScreen' value='true' /></object>";
if ( !empty( $type ) && $type == 'd' )
$player = "<object style='margin: 0px;' width='$w' height='$h'><param name='movie' value='http://static.slidesharecdn.com/swf/ssplayerd.swf?doc=$doc' /><param name='allowFullScreen' value='true' /><param name='wmode' value='opaque' /><embed src='http://static.slidesharecdn.com/swf/ssplayerd.swf?doc=$doc' type='application/x-shockwave-flash' allowfullscreen='true' wmode='opaque' width='$w' height='$h'></embed></object>";
return $player;
}
add_shortcode( 'slideshare', 'slideshare_shortcode' );
|