Plugin Directory

source: hello-dolly/trunk/hello.php

Last change on this file was 2052855, checked in by Otto42, 6 years ago
  • Update banner art and add thanks to Sanjib Ahmad to readme.txt.
  • Update trunk version to 1.7.2, leave stable tag at 1.6 until WP 5.2 release.
  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1<?php
2/**
3 * @package Hello_Dolly
4 * @version 1.7.2
5 */
6/*
7Plugin Name: Hello Dolly
8Plugin URI: http://wordpress.org/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.7.2
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
24I feel the room swayin'
25While the band's playin'
26One of our old favorite songs from way back when
27So, take her wrap, fellas
28Dolly, never go away again
29Hello, Dolly
30Well, hello, Dolly
31It's so nice to have you back where you belong
32You're lookin' swell, Dolly
33I can tell, Dolly
34You're still glowin', you're still crowin'
35You're still goin' strong
36I feel the room swayin'
37While the band's playin'
38One of our old favorite songs from way back when
39So, golly, gee, fellas
40Have a little faith in me, fellas
41Dolly, never go away
42Promise, you'll never go away
43Dolly'll never go away again";
44
45        // Here we split it into lines.
46        $lyrics = explode( "\n", $lyrics );
47
48        // And then randomly choose a line.
49        return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] );
50}
51
52// This just echoes the chosen line, we'll position it later.
53function hello_dolly() {
54        $chosen = hello_dolly_get_lyric();
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:', 'hello-dolly' ),
63                $lang,
64                $chosen
65        );
66}
67
68// Now we set that function up to execute when the admin_notices action is called.
69add_action( 'admin_notices', 'hello_dolly' );
70
71// We need some CSS to position the paragraph.
72function dolly_css() {
73        echo "
74        <style type='text/css'>
75        #dolly {
76                float: right;
77                padding: 5px 10px;
78                margin: 0;
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                }
95        }
96        </style>
97        ";
98}
99
100add_action( 'admin_head', 'dolly_css' );
Note: See TracBrowser for help on using the repository browser.