| @@ -1,13 +1,13 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /* |
| 3 | 3 | Plugin Name: iframe |
| 4 | 4 | Plugin URI: http://web-profile.com.ua/wordpress/plugins/iframe/ |
| 5 | -Description: [iframe src="http://player.vimeo.com/video/819138" width="100%" height="480"] shortcode | |
| 6 | -Version: 2.3 | |
| 5 | +Description: Plugin shows iframe with [iframe src="http://player.vimeo.com/video/3261363" width="100%" height="480"] shortcode. | |
| 6 | +Version: 2.1 | |
| 7 | 7 | Author: webvitaly |
| 8 | +Author Email: webvitaly(at)gmail.com | |
| 8 | 9 | Author URI: http://web-profile.com.ua/wordpress/ |
| 9 | -License: GPLv2 or later | |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | if ( !function_exists( 'iframe_embed_shortcode' ) ) : |
| 13 | 13 | |
| @@ -14,12 +14,11 @@ | ||
| 14 | 14 | function iframe_enqueue_script() { |
| 15 | 15 | wp_enqueue_script( 'jquery' ); |
| 16 | 16 | } |
| 17 | 17 | add_action('wp_enqueue_scripts', 'iframe_enqueue_script'); |
| 18 | - | |
| 18 | + | |
| 19 | 19 | function iframe_embed_shortcode($atts, $content = null) { |
| 20 | 20 | $defaults = array( |
| 21 | - 'src' => 'http://player.vimeo.com/video/819138', | |
| 22 | 21 | 'width' => '100%', |
| 23 | 22 | 'height' => '480', |
| 24 | 23 | 'scrolling' => 'no', |
| 25 | 24 | 'class' => 'iframe-class', |
| @@ -24,26 +23,21 @@ | ||
| 24 | 23 | 'scrolling' => 'no', |
| 25 | 24 | 'class' => 'iframe-class', |
| 26 | 25 | 'frameborder' => '0' |
| 27 | 26 | ); |
| 28 | - | |
| 29 | - foreach ($defaults as $default => $value) { // add defaults | |
| 30 | - if (!@array_key_exists($default, $atts)) { // hide warning with "@" when no params at all | |
| 27 | + // add defaults | |
| 28 | + foreach ($defaults as $default => $value) { | |
| 29 | + if (!array_key_exists($default, $atts)) { | |
| 31 | 30 | $atts[$default] = $value; |
| 32 | 31 | } |
| 33 | 32 | } |
| 34 | - | |
| 35 | - $src_cut = substr($atts["src"], 0, 35); // special case maps | |
| 33 | + // special case maps | |
| 34 | + $src_cut = substr($atts["src"], 0, 35); | |
| 36 | 35 | if(strpos($src_cut, 'maps.google' )){ |
| 37 | 36 | $atts["src"] .= '&output=embed'; |
| 38 | 37 | } |
| 39 | 38 | $html = ''; |
| 40 | - if( isset( $atts["same_height_as"] ) ){ | |
| 41 | - $same_height_as = $atts["same_height_as"]; | |
| 42 | - }else{ | |
| 43 | - $same_height_as = ''; | |
| 44 | - } | |
| 45 | - | |
| 39 | + $same_height_as = $atts["same_height_as"]; | |
| 46 | 40 | if( $same_height_as != '' ){ |
| 47 | 41 | $atts["same_height_as"] = ''; |
| 48 | 42 | if( $same_height_as != 'content' ){ // we are setting the height of the iframe like as target element |
| 49 | 43 | if( $same_height_as == 'document' || $same_height_as == 'window' ){ // remove quotes for window or document selectors |
| @@ -72,9 +66,9 @@ | ||
| 72 | 66 | </script> |
| 73 | 67 | '; |
| 74 | 68 | } |
| 75 | 69 | } |
| 76 | - $html .= "\n".'<!-- iframe plugin v:2.3 - wordpress.org/extend/plugins/iframe/ -->'."\n"; | |
| 70 | + $html .= "\n".'<!-- Iframe plugin v.2.1 (wordpress.org/extend/plugins/iframe/) -->'."\n"; | |
| 77 | 71 | $html .= '<iframe'; |
| 78 | 72 | foreach ($atts as $attr => $value) { |
| 79 | 73 | if( $attr != 'same_height_as' ){ // remove some attributes |
| 80 | 74 | if( $value != '' ) { // adding all attributes |