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