Earlier today, I finished up a WordPress plugin that I’ve been working on for a client. Without divulging too many details, I’ll say that it wasn’t a huge project, nor was it overly complicated, but it was interesting. One fun thing about working on projects for clients, is that it often gives you a chance to explore areas that you might not have looked too closely at on your own.
For example, some of the areas of WordPress (and PHP in general) that I researched and learned more about were:
- The WordPress Settings API
- The WP Cron scheduling system
- Using the WP_Http class to communicate with a third-party web service
- Using the
wp_upload_bits()
function to create an image file - Learning some of the newer bits that were added to
wp_insert_post()
since I originally created it as part of my XML-RPC API work over 6 years ago - PHP’s SimpleXML functions (including some specifics around using
xpath()
with namespaced elements)
I used a combination of the links above, other articles I found, plus some good old exploration in the WordPress core to learn more about these topics. Exploring the core code was most helpful in learning about WP_Http
, wp_upload_bits()
, and some extras for wp_insert_post()
that aren’t documented on the Codex page.
Digging around in these corners of the code can be much like spelunking. You’re digging down into places never seen by most people, and often finding little gems that you suspected might exist, but you weren’t sure until you actually saw them. If you haven’t poked around in the core code lately, maybe you should. I usually prefer to use command-line tools like grep
and a text editor. But the online WordPress phpdoc xref is a nice way to look at the code, too.
14 Responses to WordPress Code Spelunking