author | ymh <ymh.work@gmail.com> |
Tue, 22 Oct 2019 16:11:46 +0200 | |
changeset 15 | 3d4e9c994f10 |
parent 9 | 177826044cd9 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* @package Hello_Dolly |
|
9 | 4 |
* @version 1.7.2 |
0 | 5 |
*/ |
6 |
/* |
|
7 |
Plugin Name: Hello Dolly |
|
8 |
Plugin URI: http://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 |
|
9 | 11 |
Version: 1.7.2 |
0 | 12 |
Author URI: http://ma.tt/ |
13 |
*/ |
|
14 |
||
15 |
function hello_dolly_get_lyric() { |
|
16 |
/** These are the lyrics to Hello Dolly */ |
|
17 |
$lyrics = "Hello, Dolly |
|
18 |
Well, hello, Dolly |
|
19 |
It's so nice to have you back where you belong |
|
20 |
You're lookin' swell, Dolly |
|
21 |
I can tell, Dolly |
|
22 |
You're still glowin', you're still crowin' |
|
23 |
You're still goin' strong |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
24 |
I feel the room swayin' |
0 | 25 |
While the band's playin' |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
26 |
One of our old favorite songs from way back when |
0 | 27 |
So, take her wrap, fellas |
9 | 28 |
Dolly, never go away again |
0 | 29 |
Hello, Dolly |
30 |
Well, hello, Dolly |
|
31 |
It's so nice to have you back where you belong |
|
32 |
You're lookin' swell, Dolly |
|
33 |
I can tell, Dolly |
|
34 |
You're still glowin', you're still crowin' |
|
35 |
You're still goin' strong |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
36 |
I feel the room swayin' |
0 | 37 |
While the band's playin' |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
38 |
One of our old favorite songs from way back when |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
39 |
So, golly, gee, fellas |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
40 |
Have a little faith in me, fellas |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
41 |
Dolly, never go away |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
42 |
Promise, you'll never go away |
0 | 43 |
Dolly'll never go away again"; |
44 |
||
9 | 45 |
// Here we split it into lines. |
0 | 46 |
$lyrics = explode( "\n", $lyrics ); |
47 |
||
9 | 48 |
// And then randomly choose a line. |
0 | 49 |
return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] ); |
50 |
} |
|
51 |
||
9 | 52 |
// This just echoes the chosen line, we'll position it later. |
0 | 53 |
function hello_dolly() { |
54 |
$chosen = hello_dolly_get_lyric(); |
|
9 | 55 |
$lang = ''; |
56 |
if ( 'en_' !== substr( get_user_locale(), 0, 3 ) ) { |
|
57 |
$lang = ' lang="en"'; |
|
58 |
} |
|
59 |
||
60 |
printf( |
|
61 |
'<p id="dolly"><span class="screen-reader-text">%s </span><span dir="ltr"%s>%s</span></p>', |
|
62 |
__( 'Quote from Hello Dolly song, by Jerry Herman:' ), |
|
63 |
$lang, |
|
64 |
$chosen |
|
65 |
); |
|
0 | 66 |
} |
67 |
||
9 | 68 |
// Now we set that function up to execute when the admin_notices action is called. |
0 | 69 |
add_action( 'admin_notices', 'hello_dolly' ); |
70 |
||
9 | 71 |
// We need some CSS to position the paragraph. |
0 | 72 |
function dolly_css() { |
73 |
echo " |
|
74 |
<style type='text/css'> |
|
75 |
#dolly { |
|
9 | 76 |
float: right; |
77 |
padding: 5px 10px; |
|
0 | 78 |
margin: 0; |
9 | 79 |
font-size: 12px; |
80 |
line-height: 1.6666; |
|
81 |
} |
|
82 |
.rtl #dolly { |
|
83 |
float: left; |
|
84 |
} |
|
85 |
.block-editor-page #dolly { |
|
86 |
display: none; |
|
87 |
} |
|
88 |
@media screen and (max-width: 782px) { |
|
89 |
#dolly, |
|
90 |
.rtl #dolly { |
|
91 |
float: none; |
|
92 |
padding-left: 0; |
|
93 |
padding-right: 0; |
|
94 |
} |
|
0 | 95 |
} |
96 |
</style> |
|
97 |
"; |
|
98 |
} |
|
99 |
||
100 |
add_action( 'admin_head', 'dolly_css' ); |