I’ve been working on a new WordPress plugin called Instant Content for Demand Media that allows users to search for, purchase, and import article content directly to a WordPress site. You can think of it as a marketplace for written content that’s accessible directly through WordPress dashboard.
Instant Content is launching with over 50,000 titles available for sale, all written by freelance writers working with Demand Media. The articles are mostly practical “How-To” type content.
It’s been an interesting project to work on and I’d like to share some of the ideas behind it, how the code works, and even how the plugin could even be adapted for other purposes.
How the Plugin Works
Here’s a video demo of how purchasing content works in the plugin. I’ll describe the various nuts and bolts in more detail below:
To enable the search and purchasing of content, we needed to build our own API to return results in JSON format. The API also receives the Instant Payment Notification (IPN) from PayPal, which it uses to verify the payments and move into the purchaser’s library.
PayPal is used to handle the purchasing, which was actually much simpler than I thought it was going to be. A form is populated with all the required PayPal information. When a user clicks “Purchase” a hidden field “custom” is populated with the article key and license key, and the form is submitted to PayPal.
Once the user finishes the checkout, the IPN is sent to the API, which decodes the custom field and assigns the correct article to the user’s library (which is public JSON if you have the correct license key). It also removes that specific piece of content from sale so it can’t be purchased by anyone else.
The required fields are all in the search view if you’d like to look at the code.
The importer class uses wp_remote_get to get the article JSON, which is parsed, and then inserted as a draft post using wp_insert_post. If the creation of the post is successful, it returns the post ID back to the ajax function which let’s the user know the draft post has been created and links to it.
Gary Jones did a huge code review and refactor of the entire plugin codebase, and this is one of the many places he helped me break large functions into much smaller and generic components. So if anyone is looking to make their own importer that pulls off a JSON feed (Twitter, Instagram, WordPress.com, Data.gov), this code should be very re-usable.
License Keys / Automatic Updates
Since this is a “storefront” plugin, it could not be hosted at WordPress.org (see guideline #6). For me, automatic updates are essential to any plugin- so not being able to have the plugin on WordPress.org meant I needed to build that functionality from scratch or find an existing library to handle it.
I decided to use Easy Digital Downloads (EDD) along with the licensing add on. The licensing add-on generates licenses keys, which our internal API uses as the user key, as well as EDD to verify the download and deliver automatic updates.
In retrospect (and after some changing legal requirements about user terms), this probably could have been built much more simply by using a GitHub updater class and just making a quick custom plugin to generate unique user keys.
What I Learned
This project was first conceived as a hackathon project. We built a proof of concept in less than two days. It didn’t have the PayPal checkout functionality, or user libraries, but it demonstrated the basic idea of how a user could search and import content.
One big takeaway for me is that it takes much longer than one might think to go from a prototype to finished product. There are bound to be features and requirements that hadn’t even been considered, even big ones like automated updaters and license key generation.
In this project I was also humbled by a brilliant code review and plugin refactor/rewrite by Gary Jones. Until Gary was hired, I was the only one who had even looked at the plugin code.
There’s no reason stock photography and images couldn’t be sold through a plugin like this- there’s already an established market for it and images can also be sold multiple times (in contrast to articles).
Another interesting idea would be to allow individual site owners submit their own titles and editorial guidelines, which could then be written by qualified freelancers specifically for their site. Many sites that publish a lot of content already do this on an individual basis, but this would remove the friction from sourcing qualified freelancers and making sure they get paid.
But the first step is to see if anyone actually uses the plugin to purchase content. I invite you to try it out.
Or you could just use Written.com which licenses existing already successful content. Bloggers install our plugin and they choose which articles they want to license. Then brands make offers to license. If a blogger and a brand agree on terms the deal happens and the article is licensed – automatically transferred to the brand’s website.
Feel free to check us out!
Hi Josh. Neat service. Does the Written.com plugin allow users to import the content to their own site like Instant Content? Or is it more to enable writers to license their content to interested brands?
Instant Content sounds like a superbly useful plugin for budding wordpress bloggers and content publishers.
My first question was, once you buy an article, is that same article still available to others for purchase, or does it get removed from the marketplace and become solely yours? Basically, I want to know if there’s an issue with duplicate content around the web because more than one person bought an article.
Hi Mark. If you purchase an article it is no longer available in the marketplace. No issues with duplicate content.
Thank you for sharing this, we’re trying to do something very similar with JSON import from a site with the content we want to supply.
I noticed that instantcontent.me is no longer, such a great idea.
I owe you a beer for making it open source!
Yes, the service shut down a little while after I left the company. I’m glad you’re finding the code useful! I had a lot of fun building that project.