Version Description
- 2012-11-03 =
- added 'get_params_from_url' (thanks to Nathanael Majoros)
Download this release
Release Info
Developer | webvitaly |
Plugin | iframe |
Version | 2.5 |
Comparing to | |
See all releases |
Code changes from version 2.4 to 2.5
- iframe.php +27 -11
- readme.txt +5 -1
iframe.php
CHANGED
@@ -3,21 +3,21 @@
|
|
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.
|
7 |
Author: webvitaly
|
8 |
Author URI: http://profiles.wordpress.org/webvitaly/
|
9 |
License: GPLv2 or later
|
10 |
*/
|
11 |
|
12 |
|
13 |
-
if ( !function_exists( '
|
14 |
|
15 |
-
function
|
16 |
wp_enqueue_script( 'jquery' );
|
17 |
}
|
18 |
-
add_action('wp_enqueue_scripts', '
|
19 |
|
20 |
-
function
|
21 |
$defaults = array(
|
22 |
'src' => 'http://player.vimeo.com/video/819138',
|
23 |
'width' => '100%',
|
@@ -33,10 +33,26 @@ if ( !function_exists( 'iframe_embed_shortcode' ) ) :
|
|
33 |
}
|
34 |
}
|
35 |
|
36 |
-
$src_cut = substr($atts["src"], 0, 35); // special case maps
|
37 |
-
if(strpos($src_cut, 'maps.google' )){
|
38 |
$atts["src"] .= '&output=embed';
|
39 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
$html = '';
|
41 |
if( isset( $atts["same_height_as"] ) ){
|
42 |
$same_height_as = $atts["same_height_as"];
|
@@ -54,7 +70,7 @@ if ( !function_exists( 'iframe_embed_shortcode' ) ) :
|
|
54 |
}
|
55 |
$html .= '
|
56 |
<script>
|
57 |
-
jQuery(
|
58 |
var target_height = $(' . $target_selector . ').height();
|
59 |
$("iframe.' . $atts["class"] . '").height(target_height);
|
60 |
//alert(target_height);
|
@@ -64,7 +80,7 @@ if ( !function_exists( 'iframe_embed_shortcode' ) ) :
|
|
64 |
}else{ // set the actual height of the iframe (show all content of the iframe without scroll)
|
65 |
$html .= '
|
66 |
<script>
|
67 |
-
jQuery(
|
68 |
$("iframe.' . $atts["class"] . '").bind("load", function() {
|
69 |
var embed_height = $(this).contents().find("body").height();
|
70 |
$(this).height(embed_height);
|
@@ -74,7 +90,7 @@ if ( !function_exists( 'iframe_embed_shortcode' ) ) :
|
|
74 |
';
|
75 |
}
|
76 |
}
|
77 |
-
$html .= "\n".'<!-- iframe plugin v.2.
|
78 |
$html .= '<iframe';
|
79 |
foreach ($atts as $attr => $value) {
|
80 |
if( $attr != 'same_height_as' ){ // remove some attributes
|
@@ -88,7 +104,7 @@ if ( !function_exists( 'iframe_embed_shortcode' ) ) :
|
|
88 |
$html .= '></iframe>';
|
89 |
return $html;
|
90 |
}
|
91 |
-
add_shortcode('iframe', '
|
92 |
|
93 |
endif;
|
94 |
|
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.5
|
7 |
Author: webvitaly
|
8 |
Author URI: http://profiles.wordpress.org/webvitaly/
|
9 |
License: GPLv2 or later
|
10 |
*/
|
11 |
|
12 |
|
13 |
+
if ( !function_exists( 'iframe_unqprfx_embed_shortcode' ) ) :
|
14 |
|
15 |
+
function iframe_unqprfx_enqueue_script() {
|
16 |
wp_enqueue_script( 'jquery' );
|
17 |
}
|
18 |
+
add_action('wp_enqueue_scripts', 'iframe_unqprfx_enqueue_script');
|
19 |
|
20 |
+
function iframe_unqprfx_embed_shortcode($atts, $content = null) {
|
21 |
$defaults = array(
|
22 |
'src' => 'http://player.vimeo.com/video/819138',
|
23 |
'width' => '100%',
|
33 |
}
|
34 |
}
|
35 |
|
36 |
+
$src_cut = substr( $atts["src"], 0, 35 ); // special case for google maps
|
37 |
+
if( strpos( $src_cut, 'maps.google' ) ){
|
38 |
$atts["src"] .= '&output=embed';
|
39 |
}
|
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 |
$html = '';
|
57 |
if( isset( $atts["same_height_as"] ) ){
|
58 |
$same_height_as = $atts["same_height_as"];
|
70 |
}
|
71 |
$html .= '
|
72 |
<script>
|
73 |
+
jQuery(function($){
|
74 |
var target_height = $(' . $target_selector . ').height();
|
75 |
$("iframe.' . $atts["class"] . '").height(target_height);
|
76 |
//alert(target_height);
|
80 |
}else{ // set the actual height of the iframe (show all content of the iframe without scroll)
|
81 |
$html .= '
|
82 |
<script>
|
83 |
+
jQuery(function($){
|
84 |
$("iframe.' . $atts["class"] . '").bind("load", function() {
|
85 |
var embed_height = $(this).contents().find("body").height();
|
86 |
$(this).height(embed_height);
|
90 |
';
|
91 |
}
|
92 |
}
|
93 |
+
$html .= "\n".'<!-- iframe plugin v.2.5 wordpress.org/extend/plugins/iframe/ -->'."\n";
|
94 |
$html .= '<iframe';
|
95 |
foreach ($atts as $attr => $value) {
|
96 |
if( $attr != 'same_height_as' ){ // remove some attributes
|
104 |
$html .= '></iframe>';
|
105 |
return $html;
|
106 |
}
|
107 |
+
add_shortcode('iframe', 'iframe_unqprfx_embed_shortcode');
|
108 |
|
109 |
endif;
|
110 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://web-profile.com.ua/donate/
|
|
4 |
Tags: iframe, embed, youtube, vimeo, google-map, google-maps
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.5
|
7 |
-
Stable tag: 2.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -40,6 +40,7 @@ Embed iframe using shortcode `[iframe src="http://player.vimeo.com/video/819138"
|
|
40 |
* **class** - allows to add the class of the iframe `[iframe class="my-class"]` (by default class="iframe-class");
|
41 |
* **style** - allows to add the css styles of the iframe `[iframe style="margin-left:-30px;"]` (removed by default);
|
42 |
* **same_height_as** - allows to set the height of iframe same as target element `[iframe same_height_as="body"]`, `[iframe same_height_as="div.sidebar"]`, `[iframe same_height_as="div#content"]`, `[iframe same_height_as="window"]` - iframe will have the height of the viewport (visible area), `[iframe same_height_as="document"]` - iframe will have the height of the document, `[iframe same_height_as="content"]` - auto-height feature, so the height of the iframe will be the same as embedded content. [same_height_as="content"] works only with the same domain and subdomain. Will not work if you want to embed page "sub.site.com" on page "site.com". (removed by default);
|
|
|
43 |
* **any_other_param** - allows to add new parameter of the iframe `[iframe any_other_param="any_value"]`;
|
44 |
* **any_other_empty_param** - allows to add new empty parameter of the iframe (like "allowfullscreen" on youtube) `[iframe any_other_empty_param=""]`;
|
45 |
|
@@ -49,6 +50,9 @@ Embed iframe using shortcode `[iframe src="http://player.vimeo.com/video/819138"
|
|
49 |
|
50 |
== Changelog ==
|
51 |
|
|
|
|
|
|
|
52 |
= 2.4 - 2012-10-31 =
|
53 |
* minor changes
|
54 |
|
4 |
Tags: iframe, embed, youtube, vimeo, google-map, google-maps
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.5
|
7 |
+
Stable tag: 2.5
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
40 |
* **class** - allows to add the class of the iframe `[iframe class="my-class"]` (by default class="iframe-class");
|
41 |
* **style** - allows to add the css styles of the iframe `[iframe style="margin-left:-30px;"]` (removed by default);
|
42 |
* **same_height_as** - allows to set the height of iframe same as target element `[iframe same_height_as="body"]`, `[iframe same_height_as="div.sidebar"]`, `[iframe same_height_as="div#content"]`, `[iframe same_height_as="window"]` - iframe will have the height of the viewport (visible area), `[iframe same_height_as="document"]` - iframe will have the height of the document, `[iframe same_height_as="content"]` - auto-height feature, so the height of the iframe will be the same as embedded content. [same_height_as="content"] works only with the same domain and subdomain. Will not work if you want to embed page "sub.site.com" on page "site.com". (removed by default);
|
43 |
+
* **get_params_from_url** - allows to add GET params from url to the src of iframe; Example: page url - `site.com/?prm1=11`, shortcode - `[iframe src="embed.com" get_params_from_url="1"]`, iframe src - `embed.com?prm1=11` (disabled by default);
|
44 |
* **any_other_param** - allows to add new parameter of the iframe `[iframe any_other_param="any_value"]`;
|
45 |
* **any_other_empty_param** - allows to add new empty parameter of the iframe (like "allowfullscreen" on youtube) `[iframe any_other_empty_param=""]`;
|
46 |
|
50 |
|
51 |
== Changelog ==
|
52 |
|
53 |
+
= 2.5 - 2012-11-03 =
|
54 |
+
* added 'get_params_from_url' (thanks to Nathanael Majoros)
|
55 |
+
|
56 |
= 2.4 - 2012-10-31 =
|
57 |
* minor changes
|
58 |
|