| @@ -2,16 +2,17 @@ | ||
| 2 | 2 | /* |
| 3 | 3 | Plugin Name: iframe |
| 4 | 4 | Plugin URI: http://wordpress.org/plugins/iframe/ |
| 5 | 5 | Description: [iframe src="http://www.youtube.com/embed/4qsGTXLnmKs" width="100%" height="500"] shortcode |
| 6 | -Version: 3.0 | |
| 6 | +Version: 4.3 | |
| 7 | 7 | Author: webvitaly |
| 8 | -Author URI: http://web-profile.com.ua/wordpress/plugins/ | |
| 8 | +Author URI: http://web-profile.net/wordpress/plugins/ | |
| 9 | 9 | License: GPLv3 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | +define('IFRAME_PLUGIN_VERSION', '4.3'); | |
| 12 | 13 | |
| 13 | -function iframe_unqprfx_embed_shortcode( $atts, $content = null ) { | |
| 14 | +function iframe_plugin_add_shortcode_cb( $atts ) { | |
| 14 | 15 | $defaults = array( |
| 15 | 16 | 'src' => 'http://www.youtube.com/embed/4qsGTXLnmKs', |
| 16 | 17 | 'width' => '100%', |
| 17 | 18 | 'height' => '500', |
| @@ -25,33 +26,17 @@ | ||
| 25 | 26 | $atts[$default] = $value; |
| 26 | 27 | } |
| 27 | 28 | } |
| 28 | 29 | |
| 29 | - // get_params_from_url | |
| 30 | - if ( isset( $atts["get_params_from_url"] ) && ( $atts["get_params_from_url"] == '1' || $atts["get_params_from_url"] == 1 ) ) { | |
| 31 | - $encode_string = ''; | |
| 32 | - if ( $_GET != NULL ) { | |
| 33 | - if ( strpos( $atts["src"], '?' ) ) { // if we already have '?' and GET params | |
| 34 | - $encode_string = '&'; | |
| 35 | - } else { | |
| 36 | - $encode_string = '?'; | |
| 37 | - } | |
| 38 | - foreach( $_GET as $key => $value ) { | |
| 39 | - $encode_string .= $key.'='.$value.'&'; | |
| 40 | - } | |
| 41 | - } | |
| 42 | - $encode_string = rtrim($encode_string, '&'); // remove last '&' | |
| 43 | - $atts["src"] .= $encode_string; | |
| 44 | - } | |
| 45 | - | |
| 46 | - $html = "\n".'<!-- iframe plugin v.3.0 wordpress.org/plugins/iframe/ -->'."\n"; | |
| 30 | + $html = "\n".'<!-- iframe plugin v.'.IFRAME_PLUGIN_VERSION.' wordpress.org/plugins/iframe/ -->'."\n"; | |
| 47 | 31 | $html .= '<iframe'; |
| 48 | 32 | foreach( $atts as $attr => $value ) { |
| 49 | - if ( $attr != 'same_height_as' ) { // remove some attributes | |
| 33 | + if ( strtolower($attr) != 'same_height_as' AND strtolower($attr) != 'onload' | |
| 34 | + AND strtolower($attr) != 'onpageshow' AND strtolower($attr) != 'onclick') { // remove some attributes | |
| 50 | 35 | if ( $value != '' ) { // adding all attributes |
| 51 | - $html .= ' ' . $attr . '="' . $value . '"'; | |
| 36 | + $html .= ' ' . esc_attr( $attr ) . '="' . esc_attr( $value ) . '"'; | |
| 52 | 37 | } else { // adding empty attributes |
| 53 | - $html .= ' ' . $attr; | |
| 38 | + $html .= ' ' . esc_attr( $attr ); | |
| 54 | 39 | } |
| 55 | 40 | } |
| 56 | 41 | } |
| 57 | 42 | $html .= '></iframe>'."\n"; |
| @@ -60,10 +45,10 @@ | ||
| 60 | 45 | $html .= ' |
| 61 | 46 | <script> |
| 62 | 47 | document.addEventListener("DOMContentLoaded", function(){ |
| 63 | 48 | var target_element, iframe_element; |
| 64 | - iframe_element = document.querySelector("iframe.' . $atts["class"] . '"); | |
| 65 | - target_element = document.querySelector("' . $atts["same_height_as"] . '"); | |
| 49 | + iframe_element = document.querySelector("iframe.' . esc_attr( $atts["class"] ) . '"); | |
| 50 | + target_element = document.querySelector("' . esc_attr( $atts["same_height_as"] ) . '"); | |
| 66 | 51 | iframe_element.style.height = target_element.offsetHeight + "px"; |
| 67 | 52 | }); |
| 68 | 53 | </script> |
| 69 | 54 | '; |
| @@ -70,16 +55,20 @@ | ||
| 70 | 55 | } |
| 71 | 56 | |
| 72 | 57 | return $html; |
| 73 | 58 | } |
| 74 | -add_shortcode( 'iframe', 'iframe_unqprfx_embed_shortcode' ); | |
| 59 | +add_shortcode( 'iframe', 'iframe_plugin_add_shortcode_cb' ); | |
| 75 | 60 | |
| 76 | 61 | |
| 77 | -function iframe_unqprfx_plugin_meta( $links, $file ) { // add 'Plugin page' and 'Donate' links to plugin meta row | |
| 78 | - if ( strpos( $file, 'iframe.php' ) !== false ) { | |
| 79 | - $links = array_merge( $links, array( '<a href="http://web-profile.com.ua/wordpress/plugins/iframe/" title="Plugin page">Iframe</a>' ) ); | |
| 80 | - $links = array_merge( $links, array( '<a href="http://web-profile.com.ua/donate/" title="Support the development">Donate</a>' ) ); | |
| 81 | - $links = array_merge( $links, array( '<a href="http://codecanyon.net/item/advanced-iframe-pro/5344999?ref=webvitaly">Advanced iFrame Pro</a>' ) ); | |
| 62 | +function iframe_plugin_row_meta_cb( $links, $file ) { | |
| 63 | + if ( $file == plugin_basename( __FILE__ ) ) { | |
| 64 | + $row_meta = array( | |
| 65 | + 'support' => '<a href="http://web-profile.net/wordpress/plugins/iframe/" target="_blank"><span class="dashicons dashicons-editor-help"></span> ' . __( 'Iframe', 'iframe' ) . '</a>', | |
| 66 | + 'donate' => '<a href="http://web-profile.net/donate/" target="_blank"><span class="dashicons dashicons-heart"></span> ' . __( 'Donate', 'iframe' ) . '</a>', | |
| 67 | + 'iframe_pro' => '<a href="http://codecanyon.net/item/advanced-iframe-pro/5344999?ref=webvitalii" target="_blank"><span class="dashicons dashicons-star-filled"></span> ' . __( 'Advanced iFrame Pro', 'iframe' ) . '</a>', | |
| 68 | + 'pro' => '<a href="http://codecanyon.net/item/silver-bullet-pro/15171769?ref=webvitalii" target="_blank" title="Speedup and protect WordPress in a smart way"><span class="dashicons dashicons-star-filled"></span> ' . __( 'Silver Bullet Pro', 'iframe' ) . '</a>' | |
| 69 | + ); | |
| 70 | + $links = array_merge( $links, $row_meta ); | |
| 82 | 71 | } |
| 83 | - return $links; | |
| 72 | + return (array) $links; | |
| 84 | 73 | } |
| 85 | -add_filter( 'plugin_row_meta', 'iframe_unqprfx_plugin_meta', 10, 2 ); | |
| 74 | +add_filter( 'plugin_row_meta', 'iframe_plugin_row_meta_cb', 10, 2 ); | |