Skip to content

Instantly share code, notes, and snippets.

@NikV
Forked from billday/hello.php
Last active August 29, 2015 14:09
Show Gist options
  • Save NikV/66a02a87e4f53de9d13d to your computer and use it in GitHub Desktop.
Save NikV/66a02a87e4f53de9d13d to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: Hey Jude
* Description: This would have probably happened if Matt Mullenweg was a Beatles fan. (Based off Hello Dolly)
* Version: 1.0
* Author: Nikhil Vimal
*/
function hey_jude_get_lyric() {
/** These are the lyrics to Hey Jude */
$lyrics = "Hey Jude
Na, Na Na, Na Na Na Na";
// Remember to split it into lines....
$lyrics = explode( "\n", $lyrics );
// Then you begin to make it random ,random , random...
return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] );
}
// Take a sad echo, and position it later...
function hey_jude() {
$chosen = hey_jude_get_lyric();
echo "<p id='jude'>$chosen</p>";
}
// For well you know that it's an admin_notice who plays it cool
add_action( 'admin_notices', 'hey_jude' );
// The CSS you need is on your shoulder
function jude_css() {
// RTL, you'll do.
$x = is_rtl() ? 'left' : 'right';
echo "
<style type='text/css'>
#jude {
float: $x;
padding-$x: 15px;
padding-top: 5px;
margin: 0;
font-size: 11px;
}
</style>
";
}
add_action( 'admin_head', 'jude_css' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment