Skip to content

Instantly share code, notes, and snippets.

@lgladdy
Last active August 29, 2016 18:15
Show Gist options
  • Save lgladdy/9e1a7303c6a6bf43b9b1 to your computer and use it in GitHub Desktop.
Save lgladdy/9e1a7303c6a6bf43b9b1 to your computer and use it in GitHub Desktop.
A WordPress plugin to replace Hello Dolly lyrics with the infinitely better Taylor Swift.
<?php
/*
Plugin Name: Hello Taylor
Plugin URI: https://gist.github.com/lgladdy/9e1a7303c6a6bf43b9b1
Description: This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in <strike>two</strike> words sung most famously by <strike>Louis Armstrong: Hello, Dolly.</strike>Taylor Swift. When activated you will randomly see a lyric from <strike><cite>Hello, Dolly</cite></strike><cite>Taylor Swift</cite> in the upper right of your admin screen on every page.
Author: Liam Gladdy (based on Hello Dolly by Matt Mullenweg)
Version: 1.1
Author URI: http://www.twitter.com/lgladdy & http://ma.tt/
*/
function hello_taylor_get_lyric() {
/** These are just some of the gems dropped by my girl Taylor */
$lyrics = "We were both young when I first saw you
I had the time of my life fighting dragon with you
I believe in whatever you do
I'll do anything to see it through
This isn't Hollywood, This is a small town
I was a dreamer before you came around
Cause I don't know how it gets better than this
I knew your were trouble when you walked in
We came quiet cause we're dead if he knew
My daddy's going to show you how sorry you'll be
I've got a blank space baby
*click* I'll write your name
You take my hand and drag me head first: Fearless
I stay out too late
The haters gonna hate, hate, hate, hate, hate
I'm just gonna shake, shake, shake, shake, shake
All I can say is it was enchanting to meet you
This night is sparkling, don't you let it go
She looks at life like it's a party and she's on the list
She looks at me like I'm a trend and she's so over it
And, she thinks I'm psycho 'cause I like to rhyme her name with things
She took him faster than you could say sabotage";
// Here we split it into lines
$lyrics = explode( "\n", $lyrics );
// And then randomly choose a line
return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] );
}
// This just echoes the chosen line, we'll position it later
function hello_taylor() {
$chosen = hello_taylor_get_lyric();
echo "<p id='taylor'>$chosen</p>";
}
// Now we set that function up to execute when the admin_notices action is called
add_action( 'admin_notices', 'hello_taylor' );
// We need some CSS to position the paragraph
function taylor_css() {
// This makes sure that the positioning is also good for right-to-left languages
$x = is_rtl() ? 'left' : 'right';
echo "
<style type='text/css'>
#taylor {
float: $x;
padding-$x: 15px;
padding-top: 5px;
margin: 0;
font-size: 11px;
}
</style>
";
}
add_action( 'admin_head', 'taylor_css' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment