WordPress Plugin – an example of bad programming

When you have to break out a debugger to try and figure out why an obvious modification to a piece of third party code isn’t working it’s usually down to bad code. Here’s the problem:

I was trying to add a submenu page to an existing WordPress menu.

Unfortunately, the developer had decided to write a convenience wrapper around some of the existing WordPress Add Menu functionality. Whilst a neat idea (you simply used a render function to that would parse the page name to call the function that rendered the content), they had managed to shoot themselves in the foot by hard-coding the page names in this render function.  E.g. in this render function you had:

What it meant was you had to basically step through the code to find out why things weren’t working.