source: trunk/wp-content/plugins/hello.php @ 16270

Revision 16270, 2.2 KB checked in by nacin, 15 months ago (diff)

Hello Dolly 1.6. fixes typo, props sbressler, fixes #15229. Removes absolute from positioning, props kapeels, fixes #15228. Add some whitespace.

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