PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 3.1.5
Jetpack – WP Security, Backup, Speed, & Growth v3.1.5
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / modules / shortcodes / blip.php

blip.php in Jetpack – WP Security, Backup, Speed, & Growth 3.1.5, at modules/shortcodes/blip.php

56 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Blip.tv embed code:
5 * <embed src="http://blip.tv/play/g8sVgpfaCgI%2Em4v" type="application/x-shockwave-flash" width="480" height="255" allowscriptaccess="always" allowfullscreen="true"></embed>
6 * Blip.tv shortcode is: [blip.tv url-or-something-else]
7 * */
8
9 function blip_embed_to_shortcode( $content ) {
10 if ( false === stripos( $content, '/blip.tv/play/' ) )
11 return $content;
12
13 $regexp = '!<embed((?:\s+\w+="[^"]*")*)\s+src="http(?:\:|&#0*58;)//(blip\.tv/play/[^"]*)"((?:\s+\w+="[^"]*")*)\s*(?:/>|>\s*</embed>)!';
14 $regexp_ent = str_replace( '&amp;#0*58;', '&amp;#0*58;|&#0*58;', htmlspecialchars( $regexp, ENT_NOQUOTES ) );
15
16 foreach ( array( 'regexp', 'regexp_ent' ) as $reg ) {
17 if ( !preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) )
18 continue;
19
20 foreach ( $matches as $match ) {
21 $src = 'http://' . html_entity_decode( $match[2] );
22 $params = $match[1] . $match[3];
23 if ( 'regexp_ent' == $reg ) {
24 $src = html_entity_decode( $src );
25 $params = html_entity_decode( $params );
26 }
27 $params = wp_kses_hair( $params, array( 'http' ) );
28 if ( ! isset( $params['type'] ) || 'application/x-shockwave-flash' != $params['type']['value'] )
29 continue;
30
31 $content = str_replace( $match[0], "[blip.tv $src]", $content );
32 }
33 }
34 return $content;
35 }
36 add_filter( 'pre_kses', 'blip_embed_to_shortcode' );
37
38 // [blip.tv ?posts_id=4060324&dest=-1]
39 // [blip.tv http://blip.tv/play/hpZTgffqCAI%2Em4v] // WLS
40
41 function blip_shortcode( $atts ) {
42 if ( ! isset( $atts[0] ) )
43 return '';
44 $src = $atts[0];
45
46 if ( preg_match( '/^\?posts_id=(\d+)&[^d]*dest=(-?\d+)$/', $src, $matches ) )
47 return "<script type='text/javascript' src='http://blip.tv/syndication/write_player?skin=js&posts_id={$matches[1]}&cross_post_destination={$matches[2]}&view=full_js'></script>";
48 elseif ( preg_match( '|^http://blip.tv/play/[.\w]+$|', urldecode( $src ) ) ) // WLS
49 return "<embed src='$src' type='application/x-shockwave-flash' width='480' height='300' allowscriptaccess='never' allowfullscreen='true'></embed>";
50
51
52 return "<!--blip.tv pattern not matched -->";
53 }
54
55 add_shortcode( 'blip.tv', 'blip_shortcode' );
56