PluginProbe
iframe / 2.4
iframe v2.4
trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7 1.8 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0 4.0 4.1 4.2 4.3 All 35 releases
← All changes | iframe.php +57 -34 1.72.4 View file →
@@ -1,15 +1,16 @@
1 1 <?php
2 2 /*
3 -Plugin Name: Iframe
4 -Plugin URI: http://web-profile.com.ua/wordpress/plugins/iframe/
5 -Description: Plugin shows iframe with [iframe src="http://player.vimeo.com/video/3261363" width="100%" height="480"] shortcode.
6 -Version: 1.7
3 +Plugin Name: iframe
4 +Plugin URI: http://wordpress.org/extend/plugins/iframe/
5 +Description: [iframe src="http://player.vimeo.com/video/819138" width="100%" height="480"] shortcode
6 +Version: 2.4
7 7 Author: webvitaly
8 -Author Email: webvitaly(at)gmail.com
9 -Author URI: http://web-profile.com.ua/wordpress/
8 +Author URI: http://profiles.wordpress.org/webvitaly/
9 +License: GPLv2 or later
10 10 */
11 11
12 +
12 13 if ( !function_exists( 'iframe_embed_shortcode' ) ) :
13 14
14 15 function iframe_enqueue_script() {
15 16 wp_enqueue_script( 'jquery' );
@@ -14,50 +15,58 @@
14 15 function iframe_enqueue_script() {
15 16 wp_enqueue_script( 'jquery' );
16 17 }
17 18 add_action('wp_enqueue_scripts', 'iframe_enqueue_script');
18 -
19 +
19 20 function iframe_embed_shortcode($atts, $content = null) {
20 - extract(shortcode_atts(array(
21 + $defaults = array(
22 + 'src' => 'http://player.vimeo.com/video/819138',
21 23 'width' => '100%',
22 24 'height' => '480',
23 - 'src' => '',
24 - 'frameborder' => '0',
25 25 'scrolling' => 'no',
26 - 'marginheight' => '0',
27 - 'marginwidth' => '0',
28 - 'allowtransparency' => 'true',
29 - 'id' => '',
30 26 'class' => 'iframe-class',
31 - 'same_height_as' => ''
32 - ), $atts));
33 - $src_cut = substr($src, 0, 35);
27 + 'frameborder' => '0'
28 + );
29 +
30 + foreach ($defaults as $default => $value) { // add defaults
31 + if (!@array_key_exists($default, $atts)) { // hide warning with "@" when no params at all
32 + $atts[$default] = $value;
33 + }
34 + }
35 +
36 + $src_cut = substr($atts["src"], 0, 35); // special case maps
34 37 if(strpos($src_cut, 'maps.google' )){
35 - $google_map_fix = '&output=embed';
38 + $atts["src"] .= '&output=embed';
39 + }
40 + $html = '';
41 + if( isset( $atts["same_height_as"] ) ){
42 + $same_height_as = $atts["same_height_as"];
36 43 }else{
37 - $google_map_fix = '';
44 + $same_height_as = '';
38 45 }
39 - $return = '';
46 +
40 47 if( $same_height_as != '' ){
48 + $atts["same_height_as"] = '';
41 49 if( $same_height_as != 'content' ){ // we are setting the height of the iframe like as target element
42 50 if( $same_height_as == 'document' || $same_height_as == 'window' ){ // remove quotes for window or document selectors
43 51 $target_selector = $same_height_as;
44 52 }else{
45 - $target_selector = '"'.$same_height_as.'"';
53 + $target_selector = '"' . $same_height_as . '"';
46 54 }
47 - $return .= '
55 + $html .= '
48 56 <script>
49 57 jQuery(document).ready(function($) {
50 - var target_height = $('.$target_selector.').height();
51 - $("iframe.'.$class.'").height(target_height);
58 + var target_height = $(' . $target_selector . ').height();
59 + $("iframe.' . $atts["class"] . '").height(target_height);
60 + //alert(target_height);
52 61 });
53 62 </script>
54 63 ';
55 64 }else{ // set the actual height of the iframe (show all content of the iframe without scroll)
56 - $return .= '
65 + $html .= '
57 66 <script>
58 67 jQuery(document).ready(function($) {
59 - $("iframe.'.$class.'").bind("load", function() {
68 + $("iframe.' . $atts["class"] . '").bind("load", function() {
60 69 var embed_height = $(this).contents().find("body").height();
61 70 $(this).height(embed_height);
62 71 });
63 72 });
@@ -64,17 +73,31 @@
64 73 </script>
65 74 ';
66 75 }
67 76 }
68 - if( $id != '' ){
69 - $id_text = 'id="'.$id.'" ';
70 - }else{
71 - $id_text = '';
77 + $html .= "\n".'<!-- iframe plugin v.2.4 wordpress.org/extend/plugins/iframe/ -->'."\n";
78 + $html .= '<iframe';
79 + foreach ($atts as $attr => $value) {
80 + if( $attr != 'same_height_as' ){ // remove some attributes
81 + if( $value != '' ) { // adding all attributes
82 + $html .= ' ' . $attr . '="' . $value . '"';
83 + } else { // adding empty attributes
84 + $html .= ' ' . $attr;
85 + }
86 + }
72 87 }
73 - $return .= "\n".'<!-- powered by Iframe plugin ver. 1.7 (wordpress.org/extend/plugins/iframe/) -->'."\n";
74 - $return .= '<iframe '.$id_text.'class="'.$class.'" width="'.$width.'" height="'.$height.'" src="'.$src.$google_map_fix.'" frameborder="'.$frameborder.'" scrolling="'.$scrolling.'" marginheight="'.$marginheight.'" marginwidth="'.$marginwidth.'" allowtransparency="'.$allowtransparency.'"></iframe>';
75 - // &amp;output=embed
76 - return $return;
88 + $html .= '></iframe>';
89 + return $html;
77 90 }
78 91 add_shortcode('iframe', 'iframe_embed_shortcode');
79 92
80 93 endif;
94 +
95 +
96 +function iframe_unqprfx_plugin_meta( $links, $file ) { // add 'Support' and 'Donate' links to plugin meta row
97 + if ( strpos( $file, 'iframe.php' ) !== false ) {
98 + $links = array_merge( $links, array( '<a href="http://web-profile.com.ua/wordpress/plugins/iframe/" title="Need help?">' . __('Support') . '</a>' ) );
99 + $links = array_merge( $links, array( '<a href="http://web-profile.com.ua/donate/" title="Support the development">' . __('Donate') . '</a>' ) );
100 + }
101 + return $links;
102 +}
103 +add_filter( 'plugin_row_meta', 'iframe_unqprfx_plugin_meta', 10, 2 );