This is the third and final article in my series on using the WordPress weblog and CMS system.
In the first article I introduced WordPress (aka “WP”), provided links to documentation to help you get up to speed with WP, and then showed you how to install and start using it. In the second installment, I provided an overview of WP plugins, made some general plugin recommendations, and showed you how to search for PayPal-related plugins in the WordPress Plugin Directory. I also demonstrated two popular PayPal plugins, one a shopping cart, the other a plugin to accept donations.
This time I want to detail the WordPress plugin model. We’ll get our hands dirty with some code for an example WordPress plugin. And by the end, you’ll know how to go about creating a simple WP plugin of your own.
A note about PHP
In order to hack around in WordPress, and especially to modify or write new WP plugins, you will need to have some PHP programming knowledge.
The good news is that PHP is a relatively straightforward language. There are also some very nice resources for getting up to speed quickly with it.
If you just want a minimalist, WP-oriented introduction to PHP, I’d recommend you work through Adam Brown‘s “PHP Tutorial for WordPress Users“. If you want to go further, dive into the official PHP manual and tutorial. Those resources should give you the prerequisite PHP knowledge to work through the rest of this article.
Understanding The Loop
There’s one more major item you need to understand before we dive into WP plugin code. That item lies at the core of how WP renders post contents. It is The Loop.
The WP Codex summarizes The Loop like this:
The Loop is used by WordPress to display each of your posts. Using The Loop, WordPress processes each of the posts to be displayed on the current page and formats them according to how they match specified criteria within The Loop tags. Any HTML or PHP code placed in the Loop will be repeated on each post. When WordPress documentation states “This tag must be within The Loop”, such as for specific Template Tag or plugins, the tag will be repeated for each post.
Some plugins operate within The Loop, others outside of it. As you design a plugin, keep The Loop in mind and make sure that if your plugin will be manipulating post contents display that it’s setup to be executed within the cycles of The Loop. If you have any questions about what The Loop is or how to interact with it, I would encourage you to take your time reading through its Codex page and the resources linked to from it including “The Loop in Action“.
Note that the “The” is always capitalized in “The Loop” because of its great importance in the WP system. A bit high and mighty I guess, but just go with it.
The anatomy of a WordPress plugin
It’s time to start looking at plugin code. The Codex page “Writing a Plugin” provides a high level overview of the steps required and where to go to learn more about each. The first few steps you need to take are to create:
- A unique plugin name; you should search through the Plugin Directory to make certain your name is unique so that you can avoid naming collisions later
- One or more plugin files; you must have at least one PHP file containing your plugin code but you may have additional files (JavaScript, CSS, images, etc.)
- Optional: A
readme.txtto provide more information if you list your plugin in the Plugin Directory; the format for your readme is described here - Optional: A homepage for your plugin if you are going to distribute it to others; this page should describe what the plugin does, how to install it, version compatibility and prerequisites, how to use the plugin, etc. and you may either use your Plugin Directory page or create a page on your own site for this
Let’s look at an example plugin. We’re going to examine the first plugin ever written for WP, “Hello Dolly“. It is the oldest WP plugin, created by the founding developer of WP. It is also a very good plugin to examine because it’s simple and it’s installed with WP installations by default. If you’re following along with this article series and have installed WP, you should already have a copy of “Hello Dolly” on your server. If for some reason you don’t see it listed on your server’s plugin administration page (http://yourserver/wp-admin/plugins.php) you can install it from its Plugin Directory page (click here).
“Hello Dolly” consists of only one PHP file, hello.php, contained within a hello-dolly directory in the downloadable ZIP distribution.
At the top of the Hello Dolly source code listing you see some standard plugin information. This plugin info header lets WP recognize the plugin, add it to the plugin administration screens, and allow you to activate/deactivate it on your server. The header format is detailed on “Writing a Plugin” as:
<?php /* Plugin Name: Name Of The Plugin Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates Description: A brief description of the Plugin. Version: The Plugin's Version Number, e.g.: 1.0 Author: Name Of The Plugin Author Author URI: http://URI_Of_The_Plugin_Author License: A "Slug" license name e.g. GPL2 */ ?>
Note that at least Plugin Name must be provided. Some plugins may omit one or more of the other header lines. Hello Dolly, for instance, does not provide a License line.
Next in the source you’ll see the lyrics to the song “Hello, Dolly!” and some code that splits the lyrics up into lines based upon newline characters. The code then randomly chooses a line to display using the code below.
After the lyric logic, we get into the meat of the plugin, the hello_dolly and dolly_css functions. These two functions hook into the WP system via action “hooks” that set those functions up to execute when certain actions occur within the WP system. I discussed the WP Plugin API’s action and filter hooks in the previous article in this series; please refer to that article if you need a refresher on WP hooks.
For our purposes here, the key point is that hello_dolly hooks into WP via the admin_footer action (executed at the end of the administration panel) while dolly_css hooks in via admin_head (executed in the HTML head section of the admin interface).
In other words, each of these functions is registered as a callback such that when the specified administrative interface action occurs, they are executed and the previously chosen line from the song is displayed in the upper right portion of the WP admin interface.
Wrap your brain around this critical callback functionality and WP plugin programming becomes fairly straightforward.
By the way, the same gentleman that provides the “PHP Tutorial for WordPress Users” discussed previously also maintains a very useful “WordPress Hooks Database“. Highly recommended for learning about any and all of the large number of action and filter hooks built into WP and available for your use.
Click here to read the complete article on the PayPal X Developer Network including how to build, deploy, and test an example WP plugin that fetches a PayPal account balance.
PayPal recently announced their purchase of FigCard, makers of an emerging mobile payments system.
The official PayPal blog post on the purchase noted:
Fig Card developed an extremely easy way for merchants to accept mobile payments in stores by using a simple and very low cost USB device that plugs into the cash register or point-of-sale terminal. All the consumer needs is the Fig app on his or her smart phone.
The background on the FigCard site is even more intriguing:
A while back, we wondered why we weren’t using our fancy iPhones to pay for things. Why do we have to take our iPhone and our wallet to the gym? Why do we have to carry supermarket cards, drug store cards and lunch loyalty cards around? Obviously the phone can do all of that. It’s not that there haven’t been other attempts at solving this problem. But clearly they haven’t worked, and there’s usually more than one reason. Our patent pending solution requires no new hardware on the phones (iPhone, Android, many Blackberry models) and free hardware for the merchants. Transactions complete faster than credit card and often faster than cash.
The best way to quickly grok the potential of their system, including how it could possibly be faster than a cash payment (think “preloading”) is to watch a demonstration from FigCard co-founder Max Metral. Watch it below or click here if the embedded video isn’t working properly.
Click here to read the complete post on the PayPal X Developer Network including information on the key points called out in the demo video and why I think this holds promise for PayPal X Platform based development.

PayPal X Platform
- Transcription of eBay Q1 2011 earnings call http://bit.ly/kcYov3 via @seekingalpha (tidbit: @PayPal will process > $2B in mobile payments) #
- Too many April showers http://bit.ly/jMXrjY (@PayPalX DevZone monthly recap) #
- More on Visa's investment in @square http://onforb.es/ltcyqp via @forbes #
- Amex and Visa squeeze @PayPal crown jewels http://onforb.es/lDpLGg examines personal payments options #
- Facebook Deals offers let you use Facebook Credits for real world purchases http://bit.ly/iGUk24 (you can also use @PayPal or credit card) #
- Heads-up @PayPalX developers: Android Developer Challenge deadline is May 14th, details at http://bit.ly/jDhPme #
APIs and development
- sort + head work great in Cygwin RE how to get a random line from a file in bash http://bit.ly/izODFn via @hmason #
- Free webinar "Pragmatic REST – API Design Fu" http://bit.ly/iOllUi May 5th from @apigee #
- How to enable site speed (page load time) tracking in Google Analytics http://bit.ly/iLsny2 #
- Researching #Python MediaWiki->RTF conversion possibilities http://bit.ly/kREGQx (any other suggestions, Python-specific or not?) #
- Ever wondered about the mechanics of book publishing? Here's a look at the @OReillyMedia book publishing toolchain http://oreil.ly/l6exZS #
- The @OReillyMedia book toolchain discussion has piqued my curiousity about AsciiDoc in particular http://bit.ly/lHC9pw #
- The only things I'd use different from Matt Neuburg's book creation toolchain http://bit.ly/ieQDEx would be a different editor and @github #
Personal things
- "The Bighorn's Rocky Recovery" http://1.usa.gov/j0RA5G in the latest Montana Outdoors http://1.usa.gov/m9A9Hs #
- MT elk hunting information http://1.usa.gov/iWkOTL from Montana Outdoors #
- National Wildlife Refuges in MT http://1.usa.gov/jEFjFw via Montana Outdoors #
- Virgin Galactic spaceship passes major flight test http://bit.ly/liIjjT with successful "feathering" maneuver #
Running
- Ran 3.15 miles in 35 mins and felt great. Pushing stroller with daughter learning to ride her bike up the hil… http://dailymile.com/e/SyCF #
- Registered today for the Rooster Days 5k http://bit.ly/jyCpFg and Jenks Aquarium Half Marathon http://bit.ly/... http://dailymile.com/e/T0LS #
- Ran 4.1 miles in 41 mins and felt great. Beautiful, effortless, transcendent run with mile paces 8:43, 8:18, … http://dailymile.com/e/T44T #
- Ran 5.01 miles in 48 mins and felt great. Tempo plus cooldown, sustained pace 9:06 (targeting trail half mara… http://dailymile.com/e/T6oR #
I last wrote about PayPal’s third Developer Challenge in March. The Challenge is focused on Android application development and offers some nice prize money for the top three applications, with $25,000 USD up for grabs for first place. And all three of the top finishers get PayPal marketing and PR assistance to help them make their app a success in the market, too.
For more details, please refer to my March post, “Android Apps for money and fame“.
The first major deadline is fast approaching. You must submit your application to PayPal for approval by May 14th if you are going to participate in the challenge. As PayPal said in a recent email to PayPal X Developer Network community members:
If you haven’t registered to get in on the PayPal X Developer Challenge for Android, you could miss out on prizes of up to $25,000, and industry buzz for your app. Registration is closing on May 14, 2011, so be sure to register now at x.com/devchallenge
Click here to read the complete post on the PayPal X Developer Network.
PayPal X Platform
- New @PayPalX series: "Integrating Payments into WordPress, Part 1: Features and Getting Started" http://bit.ly/fGwYea #
- Part 2 of my "Integrating Payments into WordPress" series focuses on @PayPalX plugins http://bit.ly/e3DlIm #
- Comments from @factual CEO in "An iTunes model for data" http://oreil.ly/jqePgT echo my @PayPalX data markets series http://bit.ly/ecZ3Rm #
- How @PayPal can help Where close the loop from mobile intent to purchase http://tcrn.ch/l36Tcc (eBay is acquiring Where) #
- This week I solicited input on @PayPalX & payments pain points http://bit.ly/hI2kGO and WordPress http://bit.ly/lzd5U2 #
- Who will corner the market on mobile card readers? http://bit.ly/m4pa1O @Square, Intuit GoPayment, or someone else? (via @PayPalX DevZone) #
- Thoughts from @gigaom on the p2p economy http://bit.ly/mj5t4b (more to think about RE my @Square @PayPalX post http://bit.ly/lYklw8) #
Wireless and mobility
- Mobile flops article http://bit.ly/eow82W from @infoworld provides a nice summary of how we got to the dominance of iOS and Android #
APIs and development
- Auto-checkin app wins @factual hackathon http://bit.ly/inXY6d via @programmableweb #
Personal things
- It's nice to see Google buying wind energy for its new Oklahoma data center http://bit.ly/dUmns1 but I wonder about transmission efficiency #
Running
- Ran 9.3 miles in 1 hour and 31 mins and felt great. My weekend long run, a couple of days late when the sun f… http://dailymile.com/e/SLJE #
- The skinny on how much carbs and protein, and when, an athlete should consume http://bit.ly/kzo6Wy via @activenetwork #
- Ran 3.36 miles in 29 mins and felt great. Tempo run, 8:45 peak sustained pace. http://dailymile.com/e/SYpm #
- Ran 2.28 miles in 23 mins. 6×0.25mi intervals w/ paces 7:41, 7:29, 7:39, 7:43, 7:51, and 7:10. http://dailymile.com/e/Sd1m #
- Ran 3.53 miles in 47 mins and felt great. Family walk/run pushing the stroller. Yearling deer near the road. http://dailymile.com/e/ShPZ #
Mobile credit card reader competition continues to heat up.
Square credit card readers are now being sold directly by Apple in their retail stores and online. Square readers also work on iPad and iPod touch (i.e. any current iOS-based device) as well as Android devices. The readers connect using a mobile device’s headphone jack.
It’s interesting to note that if you sign up for Square’s service directly via their own site, you get the reader mailed to you for free. If you buy the reader from Apple, it costs $9.95 which Square then offsets for you with a $10 credit to your merchant account.
However you acquire your card reader, Square’s giving you the reader “razor” to be able to sell card swipe fee “blades” repeatedly. Note that you can also use Square’s iOS or Android app to process transactions by keying in details rather than swiping a card. This changes the fees a bit (see table below for details). Either way, you get a free reader for what Square hopes will be many, many transaction fees in return.
There have been some previous allegations that Square’s system wasn’t secure, but they received a huge statement of confidence this week with the announcement that Visa has made a strategic investment in Square. I’d be very surprised if Visa hadn’t done their due diligence on Square’s system before making such an investment and announcing it to the world. You can follow the latest news on this investment via @Square on Twitter.
Click to read the complete post on the PayPal X Developer Network including information on how Square compares to their major competitor, Intuit GoPayment. The post includes a table summarizing the key fees of both systems.
I’m exploring WordPress features including its plugin model in a series of DevZone articles publishing now (click here to read part 1 and here for part 2).

As I’m developing the third part of this series, I’d like to ask for your input. I’ve put together a short three question survey that will help me better understand how many readers are using WordPress, and of those readers, the sort of plugins they’re currently using as well as what payments related plugin they might like to see developed as part of the article series.
Click here to read the complete post on the PayPal X Developer Network or take the survey directly via the form below.
I’ve explored a number of ways to integrate the power of the PayPal X Platform into your applications in my DevZone articles over the last few months. Recent installments have shown you how to accelerate your Adaptive Payments development using the Apigee PayPal API Console and how to buy and sell digital goods in data markets using PayPal Embedded Payments and micropayments.
Now I’d like to explore how to use PayPal payment solutions in the world’s most popular blog and content management system (CMS) software: WordPress.
In this article I’ll introduce WordPress (commonly abbreviated as “WP” by WordPress developers and power users, aka “Pressers“), then take you on a whirlwind tour through installing and using it. Future articles will introduce the WordPress plugin model through which you can greatly extend the capabilities of your WP-powered system. They will also discuss PayPal-based WP plugins and how to write your own payments plugins.
What is WordPress?
WordPress.org, the central WP development and Presser community hub, describes it thusly:
WordPress is web software you can use to create a beautiful website or blog
In essence, WordPress is a freely available, open source, PHP and MySQL based web publishing system. It’s very customizable out of the box, and can be further extended as needed through a little PHP hackery. The WP homepage goes on to note:
The core software is built by hundreds of community volunteers, and when you’re ready for more there are thousands of plugins and themes available to transform your site into almost anything you can imagine. Over 25 million people have chosen WordPress to power the place on the web they call “home”
You can get a feel for what’s possible by visiting the WordPress Showcase page and looking through a few of the thousands of sites powered by the software. Click here to check out the Showcase. Go ahead, I’ll wait.
Pretty impressive, right? Now that you have a feel for what’s possible, let’s examine how to implement a site using WP.
WordPress documentation
The first thing you should do is to visit the WordPress Codex, source of official documentation for the software, its installation and usage, and how to develop WP add-ons such as plugins and themes. The Codex contains the following sections:
- Getting Started with WordPress – where to start, how to install the software, how to publish your first posts, file and plugin management, a “New to WordPress” FAQ, and a section on the latest release family
- Working with WordPress – contains a lot of useful information on WP features and how to use them, theme and plugin administration, creating backups, fighting comment spam, and much more; plan to spend some time here if you’re serious about getting the most out of WP
- Design and Layout – dives into blog design and layout issues with a lot of focus paid to CSS, themes, and templates (all used extensively by WP)
- Advanced Topics – information on multiuser WP, deeper details on important WP concepts such as “The Loop” that displays each post, and tips for optimizing your installation
- Troubleshooting – FAQs galore and how to find answers when you’re having problems
- Developer Documentation – database details, discussion of the plugin API, WP cookies and coding standards, and how to use PHP to bend WP to your will; we’ll be discussing this information in more detail throughout this series
- About WordPress – WP contributor acknowledgements, version information, WP community terminology, how to contribute to WP, documentation and Codex information, etc.
There are a couple of pages linked to from the sections above that I want to specifically call to your attention now, before we dive into installation, usage, and plugin extensions.
The first is the list of WP features (click here to access). If you have a question about whether or not WP can do something, this is a good place to start your search for the answer. The features page also lists the currently required prerequisite software including release numbers (as of this writing, PHP 4.3 or newer and MySQL 4.1.2 or newer, but these are shifting targets as new releases are made). Note that you’ll also need a web server that supports PHP and MySQL (I prefer Apache and will use it for the rest of this series).
In addition to the features and prerequisites, you might also want to spend a little bit of time at this point reading up on WP terminology and jargon (click here to access). Grounding yourself in the language used by Pressers will help to accelerate your learning process and remove unnecessary barriers as you move along.
Installing WordPress
Enough talk, let’s install! WP is famous for its easy installation. In fact, many web hosting companies have easy installation processes that will automatically install WP for you with minimal muss. If your host offers this, I’d suggest trying it.
If your host doesn’t provide a WordPress auto-installer, then you can follow the steps in the “Installing WordPress” Codex page. In brief, you need to:
- Download and unzip the WordPress package (click here for the latest stable release)
- Create a MySQL user and database for use by your WP installation
- Rename the WP configuration file,
wp-config-sample.php, towp-config.phpso you can begin editing it (you might even want to copy it to the new filename rather than renaming it, that way you can reference the initial contents of the file after you make changes to the copied one) - Edit
wp-config.phpin a text editor to configure the database access information you created in the second step above - Place the WP files where you want them on your web server (putting them in the root of your domain has its advantages, but there may be reasons for putting them in a subirectory of your site; whichever you choose, note down the location now as you’ll need it later)
- Remember how I told you that you needed to know where you put your WP files? You’ll use that here. You need to execute the WP installation script by accessing
wp-admin/install.phpin a web browser. If you installed WP in a subdirectory on the example.com domain, for instance, you could access the script athttp://example.com/subdirectory/wp-admin/install.php; if you installed WP to the example.com domain root, the script would be athttp://example.com/wp-admin/install.php
Additional installation details are available from the “Installing WordPress” page.
First steps after installation
Once you’ve installed WP, you’re ready to take it for a spin. The Codex provides a great tutorial for your first time, aptly named “First Steps with WordPress“.
This tutorial will walk you through the basics of logging in to the WP administration interface and performing various admin actions. This includes a look at the WP dashboard which summarizes key information when you first login. For instance, here’s my own site’s dashboard (note that I use several plugins such as the Google Analytics plugin displaying key metrics in my dashboard as pictured here; I’ll discuss these plugins in the next article in this series).
The tutorial goes on to illustrate how to change the look of your content using themes (click here to dive deeper into themes and here for more on WP’s use of CSS for styling). It also details how to write and publish posts, how to manage comments that your site visitors (readers) make on those posts, and much more.
I strongly encourage you to spend some time working your way through “First Steps with WordPress“.
Click here to read the complete post on the PayPal X Developer Network including a bit more about the PayPal WP plugins to be discussed in the next article in the series.











