Created
April 16, 2019 16:49
-
-
Save lordmatt/e59e92d718cc7a696b5617c2bf926303 to your computer and use it in GitHub Desktop.
This is an example of doing silly things with headers in WordPress
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 | |
/** | |
* This is an example of doing silly things with headers in WordPress | |
* | |
* @author Lord Matt <http://lordmatt.co.uk> | |
*/ | |
function fun_with_headers(){ | |
$jokes = array(); | |
$jokes[]='Did you hear about the restaurant on the moon? Great food, no atmosphere.'; | |
$jokes[]='What do you call a fake noodle? An Impasta.'; | |
$jokes[]='How many apples grow on a tree? All of them.'; | |
$jokes[]="I just watched a program about beavers. It was the best dam program I have ever seen."; | |
$jokes[]='Why did the coffee file a police report? It got mugged.'; | |
$jokes[]="How does a penguin build its house? Igloos it together."; | |
$jokes[]='Dad, did you get a haircut? No I got them all cut.'; | |
$jokes[]='What do you call a Mexican who has lost his car? Carlos.'; | |
$jokes[]="Dad, can you put my shoes on? No, I do not think they will fit me."; | |
$jokes[]='Why did the scarecrow win an award? Because he was outstanding in his field.'; | |
$jokes[]="Why do skeletons never go trick or treating? Because they have no body to go with."; | |
$jokes[]="What do you call cheese that is not yours? Nacho Cheese."; | |
$jokes[]="Why could the bicycle not stand up by itself? It was two tired."; | |
$jokes[]='What did the grape do when he got stepped on? He let out a little wine.'; | |
$thisjoke = $joke[rand(0,count($jokes)-1)]; | |
header( 'X-Silly: These headers are very silly' ); | |
header( 'X-Also-Powered-By: Mutant Gremlins' ); | |
header( "X-dad-joke: {$thisjoke}" ); | |
} | |
add_action( 'send_headers', 'fun_with_headers' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment