| Conditions | 7 |
| Paths | 4 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | function googlevideo_shortcode( $atts ) { |
||
| 9 | if ( ! isset( $atts[0] ) ) { |
||
| 10 | return ''; |
||
| 11 | } |
||
| 12 | |||
| 13 | $src = ltrim( $atts[0], '=' ); |
||
| 14 | |||
| 15 | if ( 0 !== strpos( $src, 'http://video.google.com/googleplayer.swf' ) ) { |
||
| 16 | if ( ! preg_match( '|^http://(video\.google\.[a-z]{2,3}(?:.[a-z]{2})?)/|', $src ) || ! preg_match( '|.*docid=([0-9-]+).*|i', $src, $match ) || ! is_numeric( $match[1] ) ) { |
||
| 17 | return '<!--Google Video Error: bad URL entered-->'; |
||
| 18 | } |
||
| 19 | |||
| 20 | $src = 'http://video.google.com/googleplayer.swf?docId=' . $match[1]; |
||
| 21 | } |
||
| 22 | |||
| 23 | // default width should be 400 unless the theme's content width is smaller than that |
||
| 24 | global $content_width; |
||
| 25 | $default_width = intval( ! empty( $content_width ) ? min( $content_width, 400 ) : 400 ); |
||
| 26 | $height = intval( 0.825 * $default_width ); |
||
| 27 | $src = esc_attr( $src ); |
||
| 28 | |||
| 29 | return "<span style='text-align:center;display:block;'><object width='{$default_width}' height='{$height}' type='application/x-shockwave-flash' data='{$src}'><param name='allowScriptAccess' value='never' /><param name='movie' value='$src'/><param name='quality' value='best'/><param name='bgcolor' value='#ffffff' /><param name='scale' value='noScale' /><param name='wmode' value='opaque' /></object></span>"; |
||
| 30 | } |
||
| 31 | add_shortcode( 'googlevideo', 'googlevideo_shortcode' ); |
||
| 32 |