| @@ -1,26 +1,24 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /* |
| 3 | -Plugin Name: iframe | |
| 4 | -Plugin URI: http://wordpress.org/plugins/iframe/ | |
| 5 | -Description: [iframe src="http://www.youtube.com/embed/A3PDXmYoF5U" width="100%" height="480"] shortcode | |
| 6 | -Version: 2.7 | |
| 3 | +Plugin Name: [iframe] | |
| 4 | +Plugin URI: http://web-profile.com.ua/wordpress/plugins/iframe/ | |
| 5 | +Description: [iframe src="http://player.vimeo.com/video/3261363" width="100%" height="480"] shortcode | |
| 6 | +Version: 2.2 | |
| 7 | 7 | Author: webvitaly |
| 8 | -Author URI: http://web-profile.com.ua/wordpress/plugins/ | |
| 9 | -License: GPLv2 or later | |
| 8 | +Author Email: webvitaly(at)gmail.com | |
| 9 | +Author URI: http://web-profile.com.ua/wordpress/ | |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | +if ( !function_exists( 'iframe_embed_shortcode' ) ) : | |
| 12 | 13 | |
| 13 | -if ( ! function_exists( 'iframe_unqprfx_embed_shortcode' ) ) : | |
| 14 | - | |
| 15 | - function iframe_unqprfx_enqueue_script() { | |
| 14 | + function iframe_enqueue_script() { | |
| 16 | 15 | wp_enqueue_script( 'jquery' ); |
| 17 | 16 | } |
| 18 | - add_action( 'wp_enqueue_scripts', 'iframe_unqprfx_enqueue_script' ); | |
| 17 | + add_action('wp_enqueue_scripts', 'iframe_enqueue_script'); | |
| 19 | 18 | |
| 20 | - function iframe_unqprfx_embed_shortcode( $atts, $content = null ) { | |
| 19 | + function iframe_embed_shortcode($atts, $content = null) { | |
| 21 | 20 | $defaults = array( |
| 22 | - 'src' => 'http://www.youtube.com/embed/A3PDXmYoF5U', | |
| 23 | 21 | 'width' => '100%', |
| 24 | 22 | 'height' => '480', |
| 25 | 23 | 'scrolling' => 'no', |
| 26 | 24 | 'class' => 'iframe-class', |
| @@ -25,35 +23,19 @@ | ||
| 25 | 23 | 'scrolling' => 'no', |
| 26 | 24 | 'class' => 'iframe-class', |
| 27 | 25 | 'frameborder' => '0' |
| 28 | 26 | ); |
| 29 | - | |
| 30 | - foreach ( $defaults as $default => $value ) { // add defaults | |
| 31 | - 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)) { | |
| 32 | 30 | $atts[$default] = $value; |
| 33 | 31 | } |
| 34 | 32 | } |
| 35 | - | |
| 36 | - $src_cut = substr( $atts["src"], 0, 35 ); // special case for google maps | |
| 37 | - if( strpos( $src_cut, 'maps.google' ) ){ | |
| 33 | + // special case maps | |
| 34 | + $src_cut = substr($atts["src"], 0, 35); | |
| 35 | + if(strpos($src_cut, 'maps.google' )){ | |
| 38 | 36 | $atts["src"] .= '&output=embed'; |
| 39 | 37 | } |
| 40 | - | |
| 41 | - // get_params_from_url | |
| 42 | - if( isset( $atts["get_params_from_url"] ) && ( $atts["get_params_from_url"] == '1' || $atts["get_params_from_url"] == 1 || $atts["get_params_from_url"] == 'true' ) ) { | |
| 43 | - if( $_GET != NULL ){ | |
| 44 | - if( strpos( $atts["src"], '?' ) ){ // if we already have '?' and GET params | |
| 45 | - $encode_string = '&'; | |
| 46 | - }else{ | |
| 47 | - $encode_string = '?'; | |
| 48 | - } | |
| 49 | - foreach( $_GET as $key => $value ){ | |
| 50 | - $encode_string .= $key.'='.$value.'&'; | |
| 51 | - } | |
| 52 | - } | |
| 53 | - $atts["src"] .= $encode_string; | |
| 54 | - } | |
| 55 | - | |
| 56 | 38 | $html = ''; |
| 57 | 39 | if( isset( $atts["same_height_as"] ) ){ |
| 58 | 40 | $same_height_as = $atts["same_height_as"]; |
| 59 | 41 | }else{ |
| @@ -69,9 +51,9 @@ | ||
| 69 | 51 | $target_selector = '"' . $same_height_as . '"'; |
| 70 | 52 | } |
| 71 | 53 | $html .= ' |
| 72 | 54 | <script> |
| 73 | - jQuery(function($){ | |
| 55 | + jQuery(document).ready(function($) { | |
| 74 | 56 | var target_height = $(' . $target_selector . ').height(); |
| 75 | 57 | $("iframe.' . $atts["class"] . '").height(target_height); |
| 76 | 58 | //alert(target_height); |
| 77 | 59 | }); |
| @@ -79,9 +61,9 @@ | ||
| 79 | 61 | '; |
| 80 | 62 | }else{ // set the actual height of the iframe (show all content of the iframe without scroll) |
| 81 | 63 | $html .= ' |
| 82 | 64 | <script> |
| 83 | - jQuery(function($){ | |
| 65 | + jQuery(document).ready(function($) { | |
| 84 | 66 | $("iframe.' . $atts["class"] . '").bind("load", function() { |
| 85 | 67 | var embed_height = $(this).contents().find("body").height(); |
| 86 | 68 | $(this).height(embed_height); |
| 87 | 69 | }); |
| @@ -89,11 +71,11 @@ | ||
| 89 | 71 | </script> |
| 90 | 72 | '; |
| 91 | 73 | } |
| 92 | 74 | } |
| 93 | - $html .= "\n".'<!-- iframe plugin v.2.7 wordpress.org/plugins/iframe/ -->'."\n"; | |
| 75 | + $html .= "\n".'<!-- Iframe plugin v.2.2 (wordpress.org/extend/plugins/iframe/) -->'."\n"; | |
| 94 | 76 | $html .= '<iframe'; |
| 95 | - foreach( $atts as $attr => $value ) { | |
| 77 | + foreach ($atts as $attr => $value) { | |
| 96 | 78 | if( $attr != 'same_height_as' ){ // remove some attributes |
| 97 | 79 | if( $value != '' ) { // adding all attributes |
| 98 | 80 | $html .= ' ' . $attr . '="' . $value . '"'; |
| 99 | 81 | } else { // adding empty attributes |
| @@ -103,17 +85,7 @@ | ||
| 103 | 85 | } |
| 104 | 86 | $html .= '></iframe>'; |
| 105 | 87 | return $html; |
| 106 | 88 | } |
| 107 | - add_shortcode( 'iframe', 'iframe_unqprfx_embed_shortcode' ); | |
| 89 | + add_shortcode('iframe', 'iframe_embed_shortcode'); | |
| 108 | 90 | |
| 109 | - | |
| 110 | - function iframe_unqprfx_plugin_meta( $links, $file ) { // add 'Plugin page' and 'Donate' links to plugin meta row | |
| 111 | - if ( strpos( $file, 'iframe.php' ) !== false ) { | |
| 112 | - $links = array_merge( $links, array( '<a href="http://web-profile.com.ua/wordpress/plugins/iframe/" title="Plugin page">' . __('Iframe') . '</a>' ) ); | |
| 113 | - $links = array_merge( $links, array( '<a href="http://web-profile.com.ua/donate/" title="Support the development">' . __('Donate') . '</a>' ) ); | |
| 114 | - } | |
| 115 | - return $links; | |
| 116 | - } | |
| 117 | - add_filter( 'plugin_row_meta', 'iframe_unqprfx_plugin_meta', 10, 2 ); | |
| 118 | - | |
| 119 | -endif; // end of if(function_exists('iframe_unqprfx_embed_shortcode')) | |
| 91 | +endif; | |