Skip to content

Instantly share code, notes, and snippets.

@cyberwani
Forked from dnaber-de/dna-framebreaker.php
Created December 28, 2012 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyberwani/4396143 to your computer and use it in GitHub Desktop.
Save cyberwani/4396143 to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: dna Framebreaker
* Plugin URI: https://gist.github.com/4045656
* Description: Add a framebreaker javascript to the header. (Requires PHP 5.3)
* Version: 0.1
* Author: David Naber
* Author URI: http://dnaber.de
* License: MIT
* License URI: http://opensource.org/licenses/MIT
*/
// From an idea of tosho: http://toscho.de/2010/wordpress-tutorial-ein-framebreaker-plugin-schreiben/
namespace dna\Framebreaker;
add_action( 'wp_head', __NAMESPACE__ . '\framebreaker' );
/**
* set the js to the head
*
* @wp-hook wp_head
* @return void
*/
function framebreaker() {
$script = <<<EOT
<script type="text/javascript">
if ( self != top )
top.location.replace( self.location.href );
</script>
EOT;
echo apply_filters( 'dna_framebreaker_script', $script );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment