Since 2 weeks there’s a voting on Digging into WordPress whether to keep the Hello Dolly plugin in the standard distribution or to chuck it out the house.
One of the most heard reasons for the existence of Hello Dolly that it should be used as a pattern for novice plugin developers. In my mind the problem with this argumentation is that the plugin hasn’t changed essentially since WordPress v1.21 (the version which introduced plugins in May 2004).
Since then the environment for plugins has changed a lot. The main difference is that there are typically ten or more plugins installed on a blog. Therefore it’s mor important than ever that the plugins don’t interfere with each other. This can most easily be achieved by encapsulation and this leads inevitable to object-oriented programming. Here’s my attempt to take Hello Dolly to the next decade:
< ?php /** * @package Hello_Dolly * @author Matt Mullenweg * @version 1.5.1 */ /* Plugin Name: Hello Dolly Plugin URI: http://wordpress.org/# 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 in the upper right of your admin screen on every page. Author: Matt Mullenweg Version: 1.5.1 Author URI: http://ma.tt/ */ if (! class_exists('Hello Dolly')) { class HelloDolly { function hello_dolly_get_lyric() { /** These are the lyrics to Hello Dolly */ $lyrics = "Hello, Dolly Well, hello, Dolly [...] It's so nice to have you back where you belong You're lookin' swell, Dolly Dolly'll never go away Dolly'll never go away again"; // Here we split it into lines $lyrics = explode("n", $lyrics); // And then randomly choose a line return wptexturize( $lyrics[ mt_rand(0, count($lyrics) - 1) ] ); } // This just echoes the chosen line, we'll position it later function hello_dolly() { $chosen = $this->hello_dolly_get_lyric(); echo "<p>$chosen</p>"; } // We need some CSS to position the paragraph function dolly_css() { // This makes sure that the posinioning is also good for right-to-left languages $x = ( 'rtl' == get_bloginfo( 'text_direction' ) ) ? 'left' : 'right'; echo " #dolly { position: absolute; top: 4.5em; margin: 0; padding: 0; $x: 215px; font-size: 11px; } "; } //dolly_css() } //class }//if class_exists() $HelloDolly = new HelloDolly; if (isset($HelloDolly)) { add_action('admin_head', array(&$HelloDolly, 'dolly_css')); // Now we set that function up to execute when the admin_footer action is called add_action('admin_footer', array(&$HelloDolly, 'hello_dolly')); } ?>
As you can see all the code is encapsuled in the HelloDolly class and the only variable names visible to the rest of the system are class HelloDolly and $HelloDolly. It’s not very likely that there will be another plugin using the variables.
This may not be too important in this small plugin but it gives the user a good and up-to-date prototype for more complex code. Maybe this code will convince the 76% that this new Dolly is a cow that is not only sacred but also meaty.

Nachdem Michael Jackson gestern das Zeitliche gesegnet hat werden uns die etablierten Radiosender wohl Wochen oder vielmehr Monate mit Titel wie „Billie Jean“. „Bad“ oder „Dirty Diana“ zumüllen. Solange man allerdings an einem Rechner mit Internetanschluss und Soundkarte sitzt kann man diesem Terror entkommen.
Viele WordPress-Nutzer bevorzugen eine deutsche Oberfläche, weil sie der englischen Sprache nicht mächtig sind oder es einfach als angenehmer empfinden, sich mit ihrem Blogsystem in ihrer eigenen Muttersprache zu verständigen.
I like to listen to web radios of all kind and like to discover new ones. But if you want to keep me from listening to your station on a long term try to avoid the following:
Neueste Kommentare