| [21] | 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | Plugin Name: Hello Dolly |
|---|
| 4 | Plugin URI: http://wordpress.org/# |
|---|
| 5 | Description: This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from <cite>Hello, Dolly</cite> in the upper right of your admin screen on every page. |
|---|
| 6 | Author: Matt Mullenweg |
|---|
| 7 | Version: 1.5 |
|---|
| 8 | Author URI: http://ma.tt/ |
|---|
| 9 | */ |
|---|
| 10 | |
|---|
| 11 | // These are the lyrics to Hello Dolly |
|---|
| 12 | $lyrics = "Hello, Dolly |
|---|
| 13 | Well, hello, Dolly |
|---|
| 14 | It's so nice to have you back where you belong |
|---|
| 15 | You're lookin' swell, Dolly |
|---|
| 16 | I can tell, Dolly |
|---|
| 17 | You're still glowin', you're still crowin' |
|---|
| 18 | You're still goin' strong |
|---|
| 19 | We feel the room swayin' |
|---|
| 20 | While the band's playin' |
|---|
| 21 | One of your old favourite songs from way back when |
|---|
| 22 | So, take her wrap, fellas |
|---|
| 23 | Find her an empty lap, fellas |
|---|
| 24 | Dolly'll never go away again |
|---|
| 25 | Hello, Dolly |
|---|
| 26 | Well, hello, Dolly |
|---|
| 27 | It's so nice to have you back where you belong |
|---|
| 28 | You're lookin' swell, Dolly |
|---|
| 29 | I can tell, Dolly |
|---|
| 30 | You're still glowin', you're still crowin' |
|---|
| 31 | You're still goin' strong |
|---|
| 32 | We feel the room swayin' |
|---|
| 33 | While the band's playin' |
|---|
| 34 | One of your old favourite songs from way back when |
|---|
| 35 | Golly, gee, fellas |
|---|
| 36 | Find her a vacant knee, fellas |
|---|
| 37 | Dolly'll never go away |
|---|
| 38 | Dolly'll never go away |
|---|
| 39 | Dolly'll never go away again"; |
|---|
| 40 | |
|---|
| 41 | // Here we split it into lines |
|---|
| 42 | $lyrics = explode("\n", $lyrics); |
|---|
| 43 | // And then randomly choose a line |
|---|
| 44 | $chosen = wptexturize( $lyrics[ mt_rand(0, count($lyrics) - 1) ] ); |
|---|
| 45 | |
|---|
| 46 | // This just echoes the chosen line, we'll position it later |
|---|
| 47 | function hello_dolly() { |
|---|
| 48 | global $chosen; |
|---|
| 49 | echo "<p id='dolly'>$chosen</p>"; |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | // Now we set that function up to execute when the admin_footer action is called |
|---|
| 53 | add_action('admin_footer', 'hello_dolly'); |
|---|
| 54 | |
|---|
| 55 | // We need some CSS to position the paragraph |
|---|
| 56 | function dolly_css() { |
|---|
| 57 | echo " |
|---|
| 58 | <style type='text/css'> |
|---|
| 59 | #dolly { |
|---|
| 60 | position: absolute; |
|---|
| 61 | top: 2.3em; |
|---|
| 62 | margin: 0; |
|---|
| 63 | padding: 0; |
|---|
| 64 | right: 10px; |
|---|
| 65 | font-size: 16px; |
|---|
| 66 | color: #d54e21; |
|---|
| 67 | } |
|---|
| 68 | </style> |
|---|
| 69 | "; |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | add_action('admin_head', 'dolly_css'); |
|---|
| 73 | |
|---|
| 74 | ?> |
|---|