root/afridex/plugins/hello.php @ 21

Revision 21, 2.0 kB (checked in by admin, 18 years ago)
RevLine 
[21]1<?php
2/*
3Plugin Name: Hello Dolly
4Plugin URI: http://wordpress.org/#
5Description: 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.
6Author: Matt Mullenweg
7Version: 1.5
8Author URI: http://ma.tt/
9*/
10
11// These are the lyrics to Hello Dolly
12$lyrics = "Hello, Dolly
13Well, hello, Dolly
14It's so nice to have you back where you belong
15You're lookin' swell, Dolly
16I can tell, Dolly
17You're still glowin', you're still crowin'
18You're still goin' strong
19We feel the room swayin'
20While the band's playin'
21One of your old favourite songs from way back when
22So, take her wrap, fellas
23Find her an empty lap, fellas
24Dolly'll never go away again
25Hello, Dolly
26Well, hello, Dolly
27It's so nice to have you back where you belong
28You're lookin' swell, Dolly
29I can tell, Dolly
30You're still glowin', you're still crowin'
31You're still goin' strong
32We feel the room swayin'
33While the band's playin'
34One of your old favourite songs from way back when
35Golly, gee, fellas
36Find her a vacant knee, fellas
37Dolly'll never go away
38Dolly'll never go away
39Dolly'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
47function 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
53add_action('admin_footer', 'hello_dolly');
54
55// We need some CSS to position the paragraph
56function 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
72add_action('admin_head', 'dolly_css');
73
74?>
Note: See TracBrowser for help on using the browser.