-
-
Save cyberwani/4396143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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