hello.php 2.5 KB

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