WordPress Code Spelunking

WordPress

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:

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.

WordPress Code Spelunking
This entry was posted in WordPress and tagged , , , , , , , , , , , , , , , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
  • Digging Into WordPress Book

14 Comments

  1. Viper007Bond viper007bond.com
    Posted February 19, 2010 at 12:30 am | Permalink

    ack > grep :D

  2. Otto ottodestruct.com
    Posted February 19, 2010 at 10:00 am | Permalink

    grep kills small animals.
    ack kills and eats them.

    For straight speed coding, generally I use a text editor with a global directory search built into it. TextPad on Windows, for example.

    When doing more involved PHP development, I use an IDE. I’ve been liking Eclipse with PDT lately. Very handy to be able to point at a function call, press a button, and have the IDE take you straight to that function, even in another file. Far less typing and searching that way.

    • Dave Doolin website-in-a-weekend.net
      Posted February 19, 2010 at 4:18 pm | Permalink

      Otto, I’ve been using Aptana Studio, which is built on Eclipse.

      I have a love/hate relationship with Eclipse, going back at least 10 years. Aptana seems to configure everything about how I like. v2 has the PDT built in, looking forward to checking it out (more spelunking).

      Also, I ran across your blog a month or so ago. Very nice. On my hit list for digging around in.

  3. Dave Doolin website-in-a-weekend.net
    Posted February 19, 2010 at 4:16 pm | Permalink

    Nice.

    I’ve been caving off and on since 1977. Totally agree that poking around in code is like caving.

    Need to do a little WP code exploration myself.

    • monatomic gold fourrealms.com
      Posted March 3, 2010 at 1:46 am | Permalink

      A weekend spelunker myself, I couldn’t agree more, and i’m loving WP just as much!

  4. Anne towelfell.com
    Posted February 19, 2010 at 7:42 pm | Permalink

    What is the plugin used for? Your mind is intuitive judging from the “… often finding little gems that you suspected might exist, but you weren’t sure until you actually saw them.“. I always enjoy when such matters happen to me, like a wake up call sometimes. A new one for me: spelunking.

    • Dougal dougal.gunters.org
      Posted February 19, 2010 at 11:30 pm | Permalink

      I can’t divulge details of the plugin right now. For one thing, it’s not quite finished yet (I have to make some enhancements/fixes based on feedback from the initial review). Plus, it’s work for a client, and though I’m not technically under NDA, they own the code by contract, so I’d rather have their blessing before discussing it.

      And while I understand curiosity about what the plugin might be for, it was really just a backdrop to the main point of my post, which is that working on someone else’s project often leads you to explore interesting areas that you might not have looked at otherwise.

      While this particular project lead to me to investigate the things I mentioned above, other projects have similarly lead me to other areas. For example, I could have talked about a project that had me digging deep into the WordPress eXtended RSS (WXR) export file format and parsing HTML using phpQuery. Or a non-WordPress project that had me creating a lightweight MVC PHP backend, with a jQuery frontend, and AJAX in-between (plus a lot of RSS parsing with SimplePie).

      It’s not the specifics of this particular project that are important. The important part is that it lead me to once again step out of my comfort zone, expand my horizons a little bit, and learn something new. :)

      • Posted February 20, 2010 at 3:09 pm | Permalink

        Using many of the same pieces you’ve mentioned here, so could guess at the type of project. Thanks for bringing some new functions to my attention too.

        Regarding the XML-RPC, would you recommend using this as a mechanism for secure data delivery to paying customers? Can’t think of a better person to ask.

        • Dougal dougal.gunters.org
          Posted February 20, 2010 at 6:42 pm | Permalink

          XML-RPC has no inherent security. You’d want to make sure your endpoint uses SSL.

          • Posted February 20, 2010 at 7:44 pm | Permalink

            Thank you sir! Have a million more questions, but it’s good to know that you take on projects for clients.

      • Anne towelfell.com
        Posted February 21, 2010 at 6:12 pm | Permalink

        I like very much your last sentence (in your reply to my comment.) I surely rely to that too. And if it’s a unique/custom work for a valued client then the privacy can be expected…

  5. Donncha ocaoimh.ie
    Posted February 23, 2010 at 7:13 am | Permalink

    I don’t think “apt-get install ack” is the same ack talked about above is it? Man page says it’s a “Kanji code converter”, nothing to do with grep or killing animals!

    • Dougal dougal.gunters.org
      Posted February 23, 2010 at 9:49 pm | Permalink

      The package they’re talking about is named “ack-grep”. I made the same mistake :)

      Description: grep-like program specifically for large source trees.
      Ack is designed as a replacement for 99% of the uses of grep. ack is intelligent about the files it searches. It knows about certain file types, based on both the extension on the file and, in some cases, the contents of the file.

      Ack ignores backup files and files under CVS and .svn directories. It also highlights matches to help you see where the match was. Ack uses perl regular expressions.

      • Donncha ocaoimh.ie
        Posted February 24, 2010 at 5:07 am | Permalink

        Thank you! Just installed it and will give it a go!

        BTW – I clicked the comments link from the “new comment” email and didn’t see your reply. I had to reload the page. Unfortunately I don’t know if the page was cached by Chromium or your server but I had closed the page after I left the comment yesterday.

Post a Comment

Your email is never published nor shared.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting