A Call to Arms

WordPress 2.9 was just released, And several users have run into a bug. Surprising? Not really. Theres one simple reason for this, While thousands of people Test each and every WordPress release, These users are not You.

I’d like to use this as an example to all here, Why WordPress needs your help. No, I’m not talking about Coding help specifically, I’m talking about Testing. WordPress requires that users test the product throughout the development period.

WordPress is an open source application written by hundreds of contributors. While those hundreds probably use the Development version of WordPress every day, They do not use the same webhost as you, nor do they have the same theme, nor do they have the same requirements, They use different functions of WordPress than you.

During The beta and RC stages, thousands of people download and test, These testers are end users like you, In order to prevent these bugs getting into a released product, It requires that users actually take part in the developement of WordPress and report the bugs encountered.

Testing WordPress is not just something that Developers should do. If you use WordPress and enjoy using it, Please take some time once every few months to test WordPress, Its announced on the Dev blog when Beta’s are available, On a default install of WordPress, The Dashboard should have a RSS feed mentioning the releases too.

So please, For 3.0, When a Beta is released (Theres generally ~2-3 weeks of beta, with 2-3 beta’s from my quick recolection) Install it on your website, It doesnt have to be your main one, it can be in a subdirectory (ie. your usual one at http://my-site.com/ and the test at http://my-site.com/testing/), and test that things works ok for you, and your plugins, This does take an hour out of your time, and i realise not everyone can afford it, But it may spare you 2-3 hours of your time, when after a release, a bug that affects you is found, that a Developer had not noticed.

WordPress requires your input, Whilst I agree there are some downfalls in reporting bugs sometimes (Please do not flame me with related messages here, I’m not after that, This is mearly a request for more contributions) overall, your contributions would be greatly appreciated by all.

In order to make it easier to test Beta’s and nightly versions, Westi wrote this great plugin It allows you to use the inbuilt upgrader to upgrade to a beta, to make it easier for you, to be involved with the project you love using.

How to do it right! (Part 0)

And another series is born.

How to do it RIGHT.

My writing skills are severely lacking, And so is my ability to explain things sometimes,  and i’ve not contributed much back into the developing community of recent.. So this has spawned my new idea..

The series will be aimed at explaining how to achieve things in WordPress in a up to date manner, Aimed more at Theme Functions.php and Plugins rather than a Theme perspective.

So, To those few who are currently subscribed, Please comment with any ideas of what you’d like to see me write about, I’ll be starting off with some rather basic postings, but aim to keep the technical level around mid-range, with more advanced topics covered as well.

It is likely that i’ll repeat what is said in a few other blogs, but i hope to write it in a more understandable, and future proof manner, without the ancient hold-overs which I’ve seen over the past year..

My other thought was writing a sample plugin, and using that as the basis for the entire series, or maybe thats a different series, To build a semi-complex system, from the ground up, to solve a problem, and looking at the steps needed to solve it.. Any suggestions for plugins? I have something in mind, specifically, solve those problems some people think “Just can be done with WordPress”.

You’re doing it wrong #2

 

Welcome to part #2, If you missed #1, go check it out.

As i mentioned in the last posting, This time wp125 is featured again, No, Please dont get me wrong, i’m not just targeting certain plugins here, It’s merely the plugins which I use, which i have to modify  and/or cleanup for whatever reason, I’ve chosen WP125 to be used for this project, so here i am cleaning up some code. Also featured in the 2nd part of this posting, is TDO Mini Forms.

Who has ever seen an error message like this one?

Notice: Undefined index: wp125action in G:\www\nrtt\wp\wp-content\plugins\wp125\adminmenus.php on line 9
Notice: Undefined index: wp125action in G:\www\nrtt\wp\wp-content\plugins\wp125\adminmenus.php on line 13
Notice: Undefined index: wp125action in G:\www\nrtt\wp\wp-content\plugins\wp125\adminmenus.php on line 22
Notice: Undefined index: wp125action in G:\www\nrtt\wp\wp-content\plugins\wp125\adminmenus.php on line 26

I’m willing to bet  a lot of people would’ve seen this one time or another, It comes down to a very very VERY lazy developer in my opinion, Simply because its best programming practice to never actually hit this case..

The code which is causing this:

function wp125_write_managemenu() {
…<snip>…
//Handle deactivations
if ($_GET[‘wp125action’] == “deactivate”) {

Doesnt look too harmful really, now does it? Thats because, By itself, Its not harmful at all other than an annoying message, The harmful part, is where similar code is used, and its merely assumed that certain array items exist, The issue arises that it can make bugs slip by unnoticed..

So, Whats the correct way? Simply check that the Array item exists before comparing it against something else.

The simplest method would be:

if ( isset($_GET['wp125action']) && ($_GET['wp125action'] == "deactivate") {

Or alternatively, If you never want to fire when the array item is empty:

 if ( !empty($_GET['wp125action']) && ($_GET['wp125action'] == "deactivate") {

Now, that wasnt too hard was it? Much cleaner, reduces warnings, and potentially reduces the risk of bugs.

Once again, All changes made are available as a Diff, This diff also includes the changes made in par #1, This has been written as of version 1.3.6.

Now, Onto the second plugin, TDO Mini Forms, This isnt actually a half bad plugin overall,  However, The code can be a bit messy for lack of a better word thanks to the many many many options and defines it uses.

Most of the issues i’ve got with this plugin, boils down to mis-use of constants, for example:

Notice Use of undefined constant TDOMF_OPTION_WIDGET_MAX_HEIGHT - assumed 'TDOMF_OPTION_WIDGET_MAX_HEIGHT' in G:\www\nrtt\wp\wp-content\plugins\tdo-mini-forms\admin\tdomf-options.php on line 604

Upon actually looking through he code, The Define was used in many places, but never actually defined. However, TDOMF_OPTION_WIDGET_MAX_WIDTH, and TDOMF_OPTION_WIDGET_MAX_LENGTH were, But guess what, The latter was never actually used, other than during option creation.. It’s a simple typo really.. But a quick fix never the less.

The main thing that has been bugging me with this plugin however, are these splattered around:

Notice: Use of undefined constant REQUEST_URI - assumed 'REQUEST_URI' in G:\www\nrtt\wp\wp-content\plugins\tdo-mini-forms\admin\tdomf-form-options.php on line 15

It looks like the plugin is expecting some form of register_globals for  the $_SERVER items to be enabled, Well, Do i have news for you… Its not! To many programmers that  may have sounded like the actual problem, But the problem is actually a coding flaw.. (as expected)

if(preg_match('/tdomf_show_form_menu/',$_SERVER[REQUEST_URI])) {

May not see something wrong with that, But, You should. $_SERVER contains an array element called ‘REQUEST_URI’, which is what the author intended to access, But instead, what they have asked for, Is the $_SERVER array element whose name is within the REQUEST_URI definition.. PHP is smart enough to convert that REQUEST_URI into a string, and so the code works as expected, for now.. But it’s still sloppy, Adding 2 apostrophe’s into the mix fixes everything.. Quick and simple really..

if(preg_match(‘/tdomf_show_form_menu/’,$_SERVER[‘REQUEST_URI’])) {

And the final piece of the puzzle for this posting:

Notice: Trying to get property of non-object in G:\www\nrtt\wp\wp-content\plugins\tdo-mini-forms\admin\tdomf-edit-post-panel.php on line 36

Another common type of warning produced by PHP, Very similar to the first Array item above:

function tdomf_edit_post_panel_admin_head() {
   global $post;
   // don't show on new post/page
   if($post->ID > 0) {

Now, This wouldnt be all that bad really.. If it wasnt for this code:

add_action( 'admin_head', 'tdomf_edit_post_panel_admin_head' );

The end result, much like I explained in Post #1, Is that running code designed for a SINGLE page on EVERY page load, is not a good thing to do, eventually you’ll hit a road bump like this one..

While the most appropriate fix for this, would be to simply only hook the function to run on the post edit page, Due to this plugins insisting to be backwards compatible at one stage or another utilising the latest hook names is not always possible, So merely adding an is_object() call in there can silence and fix everything quickly:

function tdomf_edit_post_panel_admin_head() {
 global $post;
 // don't show on new post/page
 if(is_object($post) && $post->ID > 0) {

I should however note, That this plugin includes compat code for WordPress < 2.5, Whilst, It utilises WordPress 2.8 functionalities now. Plugin Authors: Keep an eye on your obsolete code, it increases complexity, and will eventually end up causing a bug. My methodology is to only support the latest WordPress release.. It’s not worth your time developing for users not upgrading their version of WordPress. Yes, You’re going to have people complain the plugin isnt compatible, but in reality, you’re doing them a favour, If they dont upgrade WordPress, they’ll have other bugs.. Your plugin not working is the least of their worries (Or should be) .

Thats it for now, TDO Mini Forms also contains many MANY uses of undefined variables, eg:

Notice: Undefined variable: edit in G:\www\nrtt\wp\wp-content\plugins\tdo-mini-forms\include\tdomf-form.php on line 387

But the plugin is too large for me to want to go in and fix everything,  what has impacted me the most has been fixed, i’ll leave it as that.

Until next time, The changes made to TDO Mini Forms is available as a Diff, as of version 0.13.5. Apologies for the Diff here,I’m having issues with Line endings, Tortoise SVN isn’t respecting its own setting – You’ll have to patch a local copy and set it to ignore line ending changes..

 

EDIT: Fixed typo’s and lack of English. Sorry, I need a new computer, this T key hardly ever works when i want it to..

Announcing WordPress Automatic Installer

Good evening peoples.

I’d originally been planning on announcing/releasing this at another time, but plans have fallen through. So instead, Its happening now. This is a small preview video of whats to come, All in all, the  script (as you see it below) is ready to go, I have a few more things i want to add to it, but for now, its working quite nicely, Installing WordPress and configuring it all in one sweep, in under 65KB of code (Which might i add, Could be made much smaller, But I’m using WordPress Libraries – HTTP + Filesystem + WP DB + Various Functions for the ease of use they provide)

Now, Onto the video, Its a 1024x800px video, So i’m not sure how this is going to embed, I’m trying out Vimeo for this, But heres a direct link to the file anyway: WordPress Automatic Installer

I’ll be posting a link to download the script/App in the coming days, I’m not going to be very available in the next few days, So i’m delaying it until i’m available to answer questions/etc. If you’ve got any, ask away in the comments, and i’ll write a FAQ up based off them.

I fully expect this Vimeo video to be unwatachable due to the resolution.. So the above xvid may be the only way, Or wait till mid week for a post with images instead.. (I found clicking the full screen icon helps a lot)

Stats:
Over 14,000 lines of code (Much from the WordPrss Libararies)
520KB worth of code before my custom Builder/minimiser hits it
228KB worth of code after my custom minimiser hits it
65KB worth of code after Gzip’d and Base 64’d for distribution.
1 file installer – Yep, No need to upload 8MB of files, just a single 65KB file, and let your web browser do the rest.

Edit: I’ve promised people alpha’s of this, and never gotten around to it, Simple reason has been that i’ve been having less time available for WordPress, and i just need to get things out there rather than letting them be tested, So run a much, go make conspiracies about what  my code may bring, But return and review  the code when its released in a few days.

Oh one more thing, I need a name! So start suggesting names, “WordPress automatic Installer” it is for now, But i’ve got 3 others in mind, of course, the domains are taken on all of them, So if you’ve got something you think is a go-er, Send me a email via my contact page, I’m sick of people squating on good domain names..

Oh, One more thing! The Carrington Blog theme SUCKS ASS. Not only did i have to recode crap in it, but now i find out the content column is more than just fixed width, its damn scrollbar width…. I wish i had the time to actually code something decent for myself once in awhile instead of giving back to the community..

You know what sucks? Installing WordPress..

Yep. I’ve always hated installing WordPress, When i’m creating a new WordPress install, its because I want to play with it right NOW, not in 10 minutes, not in 30 minutes..

Many people will quote the “famous 5 minute WordPress install” but like nearly every other decent sized Web app. out there, This simply isnt true

I mean, Step back for a moment, and look at the steps that you have to do:

  1. Download the Install package from the website – 7MB ~1 minute on a 1.5Mbit connection
  2. Extract the Archive – 20 seconds
  3. Open your FTP Application, Upload the 10MB of files, ~30 minutes
  4. Visit the Location you installed it in, Run the install ~2 minutes
  5. Realise PHP cant create its config file automatically, Create it manually, ~5 minutes

Hooray! We have it installed!

..Now, that  “quick” install took nearly 40 minutes.. I dont know about you, But by that time I’ve usually nearly lost interest in what I was originally doing..

Luckily, Since we now have the Core Upgrades as part of WordPress,  We dont have to deal with a 30-minute FTP Upgrade.. Its more like a 1-2 minute upgrade..

Thankfully.. People like to automate things, And there are a few other alternative methods of installing,  For example, Some hosts now offer Auto-Installers such as Fantastico, Unfortunately these are not always 100% up-to-date when a new release comes out, and often only allows English installs.

(Side note: Yes, I now use SSH + SVN, so a new setup only takes me ~2 minutes via the Command line)

Remove WordPress 2.8’s Default Password Nag

WordPress 2.8 includes a Password Nag for when you’re using a default generated password. This was done intentionally to help forgetful people like myself who make new installs, and promptly forget the admin password.. You can find the Trac Ticket for it here:  #9710

I’ve been asked how to disable it, A fair enough request, and a very simple thing to achieve.

Simply put this code into a plugin, Or your theme’s functions.php:

[sourcecode lang=”php”]
remove_action(‘admin_notices’, ‘default_password_nag’);
[/sourcecode]

And you’ll never see that red box again..

My WordPress Plugins..

This is just a note to all the users of my various plugins.

As of today, All my plugins are going to be moved to a maintenance only release cycle.

The reasoning for this?

  • I have -dev branches of all my plugins with new great features, better written, and better UI..
  • Unfortunately however, I do not actually use the plugins myself anymore
  • Which means:  That the plugins are written in my spare time only, and i have no pressing reason for me to spend time i do not have spare working on them
  • And I initially wasnt going to mention this, But part of the reason are grumpy end users Yes, I mean you, Those of you who just complain and bitch when something doesn’t work 100% of the way you expect, completely ignoring any technical considerations, or knowledge of anything related.

So to continue on the line of that last one.. Sorry to those of you who love my plugins, and the very small minority of those of you  who have ever shown the appreciation, Hopefully the plugins will continue to fulfill your current needs, and hopefully the next versions of these plugins will be worth while the wait.

Perhaps those of you who use open source/free applications/plugins/themes/tutorials should take a moment to thank those who make it happen, to make it worth while their time and effort, There are many more like me, who instead of working on new things or new versions, simply toss it aside, and leave users hung out to dry.. I’m not interested in doing that, But at the same time, For the benefit of few, I’m not going to put great effort in anymore for things which either i dont use, or i dont feel like solving.

To that last point, Things i like solving..  I like to Automate things, Thats what most of my plugins will generally aim to do,  automate a process which you could do manually, but would prefer not to. The WordPress Plugin upgrader, Plugin Installer, Theme Upgrades and Installs, Pars of the WordPress Core upgrader, etc. The main reason behind them has been to automate a rather manual process and  make it simpler for end users.. End  users you’ll probably never hear from.

Ironically, Seems someone else may’ve taken this thought from a similar aspect the other day:
http://www.daemonology.net/blog/2009-07-14-a-call-for-schwag.html

Two things happened this morning which started me thinking. First, I read Zed Shaw’s rant[Dion: See next link] about how he thinks he deserves more recognition and money from his Open Source work; and second, I looked at my pile of t-shirts, and realized that while I have 4 Google t-shirts (one from August 2006, when I interviewed there; and three from Google Summer of Code), I don’t have a single t-shirt from any company which is using code I’ve written.

and another (Which talks about why he uses the GPL, you’re better off reading the entire articles rather than just my sniplets..)

http://zedshaw.com/blog/2009-07-13.html

My final reason for using the GPL is I think my projects have value, and I want people who use them to perceive that value in them. I think they are so valuable that I’m willing to put a complex untested legal document down as my bet to their utility. If I wanted it easy I would simple BSD license it and everyone would use it.

I want people to appreciate the work I’ve done and the value of what I’ve made.

Not pass on by waving “sucker” as they drive their fancy cars.

I can relate to both of these people.. If you use one of my plugins daily.. Or love a feature of WordPress i’ve helped with.. Then show your appreciation, A simple thanks would go a long way, I’m not begging for money, or goods, or for you to shout my name to the neighbourhood, Just reconise that you know i’m there perhaps.. Or that you use my Software, and love it :)

(I’m actually in a similar situation to Colin, What Schwag have i recieved? Well, GSOC which started my main Open Source-ness, 2x GSOC T-Shirts(2007, 2008) & the accompanying ~$5k which comes with that( For time put in, IIRC the return in AUD is about $7/hr, GSOC is about the experience and the learning rather than the money however), 1x WordPress Hoodie (Thanks!  Too small for me now though), Oh and how could i forget, A postcard from Automattic. W0uld’ve I done what i’ve done without those? Definately, Do I want more? Well.. More is always nice :) But in reality, No. The money doesnt mean much to me at all, As long as i can live day-to-day, I’ll be right. Some appreciation once in awhile from certain people would probably weigh over the negitive feedback from the minority I’m sure.

EDIT: How could i forget… Thanks to you-know-who-you-are, another WordPress developer who also recently donated $20 via paypal, to say thanks for the code i’ve contributed which he in turn has been able to take advantage of. Not publishing your name.. unless you read this and A-OK it :) Sure, $20 isnt much in the scheme of things, but its the “thanks” part of it that matters (And hey, an extra hour i can relax on the weekend!)

So.. Go hug a developer today, Or show appreciation to those who’s plugins or WordPress features you use, I’m sure they’ll be glad to hear it.