|
1 <?php |
|
2 /** |
|
3 * @package Hello_Dolly |
|
4 * @author Matt Mullenweg |
|
5 * @version 1.5.1 |
|
6 */ |
|
7 /* |
|
8 Plugin Name: Hello Dolly |
|
9 Plugin URI: http://wordpress.org/# |
|
10 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. |
|
11 Author: Matt Mullenweg |
|
12 Version: 1.5.1 |
|
13 Author URI: http://ma.tt/ |
|
14 */ |
|
15 |
|
16 function hello_dolly_get_lyric() { |
|
17 /** These are the lyrics to Hello Dolly */ |
|
18 $lyrics = "Hello, Dolly |
|
19 Well, hello, Dolly |
|
20 It's so nice to have you back where you belong |
|
21 You're lookin' swell, Dolly |
|
22 I can tell, Dolly |
|
23 You're still glowin', you're still crowin' |
|
24 You're still goin' strong |
|
25 We feel the room swayin' |
|
26 While the band's playin' |
|
27 One of your old favourite songs from way back when |
|
28 So, take her wrap, fellas |
|
29 Find her an empty lap, fellas |
|
30 Dolly'll never go away again |
|
31 Hello, Dolly |
|
32 Well, hello, Dolly |
|
33 It's so nice to have you back where you belong |
|
34 You're lookin' swell, Dolly |
|
35 I can tell, Dolly |
|
36 You're still glowin', you're still crowin' |
|
37 You're still goin' strong |
|
38 We feel the room swayin' |
|
39 While the band's playin' |
|
40 One of your old favourite songs from way back when |
|
41 Golly, gee, fellas |
|
42 Find her a vacant knee, fellas |
|
43 Dolly'll never go away |
|
44 Dolly'll never go away |
|
45 Dolly'll never go away again"; |
|
46 |
|
47 // Here we split it into lines |
|
48 $lyrics = explode("\n", $lyrics); |
|
49 |
|
50 // And then randomly choose a line |
|
51 return wptexturize( $lyrics[ mt_rand(0, count($lyrics) - 1) ] ); |
|
52 } |
|
53 |
|
54 // This just echoes the chosen line, we'll position it later |
|
55 function hello_dolly() { |
|
56 $chosen = hello_dolly_get_lyric(); |
|
57 echo "<p id='dolly'>$chosen</p>"; |
|
58 } |
|
59 |
|
60 // Now we set that function up to execute when the admin_footer action is called |
|
61 add_action('admin_footer', 'hello_dolly'); |
|
62 |
|
63 // We need some CSS to position the paragraph |
|
64 function dolly_css() { |
|
65 // This makes sure that the posinioning is also good for right-to-left languages |
|
66 $x = ( 'rtl' == get_bloginfo( 'text_direction' ) ) ? 'left' : 'right'; |
|
67 |
|
68 echo " |
|
69 <style type='text/css'> |
|
70 #dolly { |
|
71 position: absolute; |
|
72 top: 4.5em; |
|
73 margin: 0; |
|
74 padding: 0; |
|
75 $x: 215px; |
|
76 font-size: 11px; |
|
77 } |
|
78 </style> |
|
79 "; |
|
80 } |
|
81 |
|
82 add_action('admin_head', 'dolly_css'); |
|
83 |
|
84 ?> |