Skip to content

Instantly share code, notes, and snippets.

@absynthe
Created June 23, 2015 13:57
Show Gist options
  • Select an option

  • Save absynthe/caaac5525d3f4fc18399 to your computer and use it in GitHub Desktop.

Select an option

Save absynthe/caaac5525d3f4fc18399 to your computer and use it in GitHub Desktop.
Redirection iFrame
<?php
/*
Plugin Name: Redirection iFrame
Description: iframe redirect for Wordpress. Accepts a 'key' parameter which it then redirects to the new URL.
Usage: [myiframe width=640 height=480]http://url.to.redirect.to[/myiframe]
Version: 1.0
Author: Ana Todor
Author URI: http://www.ana-todor.ro
License: GPL2
*/
if ( !function_exists( 'myiframe_shortcode' ) ) :
function myiframe_shortcode( $atts, $content = null ) {
extract( shortcode_atts( array(
'width' => '640',
'height' => '480',
), $atts ) );
if (!wp_is_mobile()) {
$html .= '<iframe width='. $width . ' height='.$height;
$html .= ' src="' . $content;
global $wp_query;
$key = $_GET['key'];
if (isset($key)) {
$html .= '?' . $key;
}
$html .= '"';
$html .= ' frameBorder="0"';
$html .= '></iframe>';
return $html;
}
else{
global $wp_query;
$key = $_GET['key'];
if (isset($key)) {
wp_redirect($content.'?' . $key);
}
}
}
add_shortcode('myiframe', 'myiframe_shortcode');
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment