hello.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * @package Hello_Dolly
  4. * @version 1.7
  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
  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. echo "<p id='dolly'>$chosen</p>";
  52. }
  53. // Now we set that function up to execute when the admin_notices action is called
  54. add_action( 'admin_notices', 'hello_dolly' );
  55. // We need some CSS to position the paragraph
  56. function dolly_css() {
  57. // This makes sure that the positioning is also good for right-to-left languages
  58. $x = is_rtl() ? 'left' : 'right';
  59. echo "
  60. <style type='text/css'>
  61. #dolly {
  62. float: $x;
  63. padding-$x: 15px;
  64. padding-top: 5px;
  65. margin: 0;
  66. font-size: 11px;
  67. }
  68. </style>
  69. ";
  70. }
  71. add_action( 'admin_head', 'dolly_css' );
  72. ?>