Dougal Campbell's geek ramblings

WordPress, web development, and world domination.

Jumping Into WordPress Plugin Programming

WordCamp Birmingham 2009In a few weeks, I will be a presenter at WordCamp Birmingham 2009 (that’s Birmingham, Alabama, not England, by the way). Last year, I did a presentation on “The Future of WordPress“, shortly before the release of version 2.7. I briefly considered doing the same thing this year, updated with speculation about the upcoming versions 2.9 and 3.0, but that seemed like a cop-out. I wanted to do something a little deeper.

One of the things that always frustrates me about starting to work with a new programming language, or with a new framework for a language I already know, is the initial learning curve. Everybody wants to start out with the ubiquitous “Hello, World” example, which is great for a quick syntax example, but is pretty useless for practical purposes. I always want a good primer which doesn’t assume I’m a complete beginner, and dives right into useful examples. I want to know how to find the existing pieces of the system that are going to make my life easier. So I thought others might appreciate something like that for WordPress plugin programming.

So that’s going to be my presentation topic this year. I’m going to try to create an introduction to creating plugins for WordPress. While there are bits of the process that can be complex, the real meat of the API hooks (filters and actions) are really pretty simple. And I think that with a good overview, those who aren’t already familiar with programming for WordPress can get up-to-speed more quickly than if they had to discover everything by searching the web and using trial-and-error. While I will try to keep things as simple as possible, I’m going to assume that my target audience will at least have a basic knowledge of programming concepts to include what functions and arrays are. You won’t have to be a PHP expert, or even be able to sit down and write a program from scratch without a reference book handy.

I will, of course, make the presentation available online when the WordCamp arrives. And since I’ll be limited by time in my presentation, I’d like to publish an expanded version here later as a series of articles where I can go into more depth.

I’ve already started a rough outline of what I want to cover. But I’d welcome any ideas or questions on this topic. If you are already familiar with programming, but you’re new to programming in the WordPress framework, what questions have you had? What concepts confuse you? What areas would you like to see covered?

About Dougal Campbell

Dougal is a web developer, and a "Developer Emeritus" for the WordPress platform. When he's not coding PHP, Perl, CSS, JavaScript, or whatnot, he spends time with his wife, three children, a dog, and a cat in their Atlanta area home.
This entry was posted in WordPress and tagged , , , , , , , , , . Bookmark the permalink.

16 Responses to Jumping Into WordPress Plugin Programming

  1. scribu says:

    Hello,

    First of all, great presentation ideea.

    What really confused me after learning about hooks was how to use the wp_enqueue_script() family of functions.

    • Dougal says:

      I think that the enqueue functions might be beyond the scope of my WordCamp presentation. But they will definitely be mentioned as ‘best practice’ examples when I do the expanded series of articles.

  2. arena says:

    One year ago wp 2.6 was released ! since then 11 releases !!!

    Sure 2.7 was a great release with the new admin UI.
    2.8 was also a great plugin ‘breaker’ with the javascript libraries under admin going from top of the page to bottom…

    About plugins, each new wp version release requires a plugin review and most of the time an update.
    It is quite true when your plugin has one or several admin pages.

    I believe that – something like – reengineering core wp admin pages as admin plugin pages, giving by the way a whole set of skeletons/classes/api would :
    * make the learning curve shorter for new comers to build their own plugin admin pages,
    * encourage the stability of code (less wp release dependant),
    * immediately make some wp admin pages options / api’s available for plugins :
    – have to dig hard in wp code to see how customize the “screen options” or “help” tabs;
    – making easier use of facilities such as roles/capabilities + menus, register/enqueue styles and scripts …,
    * give more time on plugin core functions.

    An example : in one of my plugin having some custom admin pages, “show on screen” options (for meta box and columns) was working correctly under 2.7, but not under 2.8

    hope this help !

    • Dougal says:

      If I understand you correctly, you’re suggesting some core functions that would make it easier for plugins to create settings pages, right? If so, I had a similar idea a while back, and I *thought* I had seen some Trac tickets that led me to believe that we might be heading in that direction.

      For simple plugin settings pages, it shouldn’t be hard to add. We just need some functions that allow us to declare a settings page, add sections to it, add forms within the sections, add fieldsets within the forms, and add text and forms fields within the fieldsets. And finally, an easy way to handle the form submission results.

      Once upon a time, back in the very early days of WordPress, much of the back-end settings were handled similar to that. The options were all defined in the database with fields defining how the settings were grouped, the data types of the settings, and descriptions for them. Then the options rendering code dynamically built the forms.

      If they were going to make a dynamic way to create plugin settings pages, that old code could be a good starting point. Though in this case, instead of building things up based on information in the database, you’d set it up in your plugin code, and we’d probably want to do it in an OOP fashion, with some flexible utility classes.

      • online tv says:

        Thanks for the headsup, I’ve only worked with the php code in themes for older versions. I do like how they migrated to a much simpler format for plugins. I really wanted to create a WP plugin but I fear that most of the ideas that I have are already been created.

        I want to create something that people will actually use, and it seems like the plugin market is oversaturated. Would you agree with that sentiment?

  3. dugun salonu says:

    Jumping Into WordPress Plugin is perfect. thank you by dougal

  4. Went through the first 12 slides of the presentation (dont have the time for the entire show) I have to say I was impressed by the conciseness of teh slide text and the comparisons (filters in photography and photoshop!) I use DIY Theme in WordPress and have messed about with hooks but never really put time into it and I cant say I understand the workings. I will go through your presentation on the weekend though – maybe that will start the process!

  5. abrcity says:

    i think we should learn the php and xml really good,then we should take a deep look at the wp code

  6. Aymen.BN says:

    it is really a successful business rather than making good plugins for your blog,you can be making good encomes from making plugins to people

    Cheers
    Aymen.B.R
    Allfreeads

  7. i have to say this is the one of the greatest wordpress plugin

  8. LTL Trucking says:

    I have been designing WordPress themes and uploading them while adding widgets but i m myself a newbie in terms of widget creation. I am looking forward for your demos about widget programming because i want to create one related to my freight website.

  9. I have to say I was impressed by the conciseness of teh slide text and the comparisons (filters in photography and photoshop!) I use DIY Theme in WordPress and have messed about with hooks but never really put time into it and I cant say I understand the workings. I will go through your presentation on the weekend though – maybe that will start the process!

    Jeremy
    hiking tent info

  10. 1skyliner says:

    I m designing WordPress themes and uploading them while adding
    widgets but i am a newbie in widget creation.

  11. Hand Stamped Personalized Jewelry says:

    Would love to take an introductory course on wordpress plugin programming. Also, wish I had a time machine.

Leave a Reply

%d bloggers like this: