PageRenderTime 48ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/hello.php

https://bitbucket.org/crypticrod/sr_wp_code
PHP | 82 lines | 53 code | 9 blank | 20 comment | 0 complexity | 613264886d181541bda93bda07e77986 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1, GPL-3.0, LGPL-2.0, AGPL-3.0
  1. <?php
  2. /**
  3. * @package Hello_Dolly
  4. * @version 1.6
  5. */
  6. /*
  7. Plugin Name: Hello Dolly
  8. Plugin URI: http://wordpress.org/extend/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. */
  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. We feel the room swayin'
  24. While the band's playin'
  25. One of your old favourite songs from way back when
  26. So, take her wrap, fellas
  27. Find her an empty lap, fellas
  28. Dolly'll never go away again
  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
  36. We feel the room swayin'
  37. While the band's playin'
  38. One of your old favourite songs from way back when
  39. Golly, gee, fellas
  40. Find her a vacant knee, fellas
  41. Dolly'll never go away
  42. Dolly'll never go away
  43. Dolly'll never go away again";
  44. // Here we split it into lines
  45. $lyrics = explode( "\n", $lyrics );
  46. // And then randomly choose a line
  47. return wptexturize( $lyrics[ mt_rand( 0, count( $lyrics ) - 1 ) ] );
  48. }
  49. // This just echoes the chosen line, we'll position it later
  50. function hello_dolly() {
  51. $chosen = hello_dolly_get_lyric();
  52. echo "<p id='dolly'>$chosen</p>";
  53. }
  54. // Now we set that function up to execute when the admin_notices action is called
  55. add_action( 'admin_notices', 'hello_dolly' );
  56. // We need some CSS to position the paragraph
  57. function dolly_css() {
  58. // This makes sure that the positioning is also good for right-to-left languages
  59. $x = is_rtl() ? 'left' : 'right';
  60. echo "
  61. <style type='text/css'>
  62. #dolly {
  63. float: $x;
  64. padding-$x: 15px;
  65. padding-top: 5px;
  66. margin: 0;
  67. font-size: 11px;
  68. }
  69. </style>
  70. ";
  71. }
  72. add_action( 'admin_head', 'dolly_css' );
  73. ?>