secret
Created

A really slow WordPress plugin

  • Download Gist
slow-plugin.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
<?php
/*
Plugin Name: Slow plugin
Description: Make a site unreasonably slow
Author: Evan Solomon
*/
 
function print_a_slow_script() {
?>
<script>
function so_slow(miliseconds) {
miliseconds += new Date().getTime();
while( new Date() < miliseconds ) {
//Do nothing except be evil and slow
}
}
 
//Let's wait 5 seconds for anything to happen...
so_slow( 5000 );
//Just 2 more seconds now..."
so_slow( 2000 );
</script>
<?php
}
 
//Load a useless, slow script
function make_the_site_slow() {
if( is_admin() )
return;
print_a_slow_script();
}
add_action( 'wp_print_scripts', 'make_the_site_slow' );
 
//Just for fun let's append a huge, uncached photo of earth to each post!
function random_big_earth_photo( $content ) {
return $content . "<img src='http://upload.wikimedia.org/wikipedia/commons/d/db/Nasa_blue_marble.jpg?" . mt_rand(0,1000000) . "'>";
}
add_filter( 'the_content', 'random_big_earth_photo' );

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.