As part of a recent Sensei update we added some custom capabilities to the editor role, but we discovered that some people have deleted that role from the database as a way of cleaning up unused data on their sites. This meant that our add_cap() calls were causing fatal errors for these sites. Here’s how we solved this problem for ourselves.
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…
Building an options page for a plugin can be a daunting prospect, so here’s a single class that will help you to create a versatile and user-friendly options page for your plugin that fits neatly into the WordPress dashboard.
The WordPress dashboard includes a handy widget that displays some brief information about your site at a glance – this snippet will show you how to add your own custom post types to that widget.
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.
I’ve been using Gist for a while, but only as a way to quickly share snippets of code with people. I’ve now decided to change that a bit and make better use of the service – as a result I have added all my snippets from this blog to my Gists and I will continue to add even the smallest snippets as I develop them.
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.
If you use links to navigate to other elements on the same page, it’s generally a good idea to animate the scrolling so you don’t disorientate your users. This snippet will make that easy for you.