Last night I spoke at a meetup of the Cape Town PHP Group. I was speaking alongside the excellent Gareth McCumskey who was giving a run down of what we can expect in PHP 7 (we can expect a lot of awesomeness by the way – you should really check that out). My presentation for the evening was a primer on WordPress development and a guide on how to bend WordPress to your will (which would have made a way more awesome title for the talk).
There are many use cases for allowing users to upload files from the frontend, but the trick is making sure the file is uploaded and saved in the WordPress media…
With WooCommerce 2.1 having just been released, you’ll find that a number of functions that you have been using in your plugins and themes have now been deprecated in favour of better and more aptly named functions. Here is a simple function that checks if a site is running the specified version of WooCommerce or higher.
If you have ever wanted to display your posts (or a post type archive) in a random order, but keep the pagination consistent then here’s your solution.
Having a drop down menu for month selection is a relatively common need, but it can be a pain to write from scratch each time. Here’s a short snippet that will generate a select input (drop down menu) for all 12 months of the year – the option values will be the month numbers with leading zeros.
When building a plugin that has its own settings page, it’s often handy to create a link to the settings page straight from the Plugins list – this saves users the time it takes to find where exactly your plugin appears in the admin menu. Here is a simple code snippet that creates the settings link for you – all you need to do is tell it where to go.
In order to minimise the amount of plugins your site uses, here’s a simple function I use to show a post’s featured image in the RSS feed (something WordPress does not do by default).
When creating web apps, there’s often a need to generate a random password for your users. There are a number of ways to do this, but in needing to do this recently I came up with this very simple function that will generate a password (or other random string) of whatever length you wish.
The other day I was working on a project that required me to extract a numeric ID from the current page’s URL. The problem was that the ID could either be at the end of the URL string or in the middle, depending if there were any parameters added on or not. Here is how I worked around the problem by looping through each character of the string.