September 26, 2012Web · Platform

Building the WordPress plugin

Matt Kelly

In my last couple of years at Facebook, I've worked on some exciting third-party integrations. More recently, I spearheaded the Facebook for WordPress plugin, which launched in June and has already seen more than 180,000 downloads.

We chose to build an integration with WordPress because it has a massive footprint on the web (powering 16.6% of all websites), it has a very active community, and it could serve as a good case study for showing interesting ways sites could integrate with Facebook to become more social.

Building on platform

In order to get a fresh view of what it was like to build on Facebook, I built the plugin based on what was publicly available for developers.

From the outset, I knew it was important to work closely with the WordPress community. Many folks have already put a lot of effort into Facebook integration for WordPress and, as a result, are familiar with many intricacies that we previously weren’t aware of. We ended up collaborating closely with WordPress folks, including Matt Mullenweg (the founder of WordPress) and Automattic, for ideas and code contributions.

When I started the project, I built the initial prototype and proceeded to grow the working team based on interest in the project. In a little over a month, we launched a plugin that addressed the needs of most people, but also contained new functionality: the ability to mention Facebook friends and Pages in WordPress posts, as part of publishing them back to Facebook.

The plugin introduced Open Graph integration including a new action, called news.publish. This allows authors to post a new blog post to their Timeline as soon as it’s live. Shortly after launch, our Platform Operations team was inundated with requests to get this action approved. We quickly realized that the process was confusing. As a result, we ended up shipping it as a new global Open Graph action, which drastically simplified the developer experience.

Shortly after launch, we got a detailed view into the unique setups of WordPress sites, their themes, and their plugins (including a few features that overlapped with our plugin's functionality). On top of that, we had to deal with a large combination of PHP versions, PHP enabled modules, WordPress versions, and host configurations that resulted in other issues.

Resolving issues

The top issue consisted of websites not having cURL installed. By default, our PHP SDK relies on cURL to make API calls, so we had to make changes to use WordPress’s abstraction that automatically routes calls to fopen(), streams, or cURL. The second major issue we ran into is namespace collisions, particularly with other plugins that used the PHP SDK. We had checks to see if the SDK had already been included, which solved any fatals, but we didn’t realize that many plugins use an old version of the PHP SDK that is missing crucial functions that we need in our plugin. So we had to make several changes, including with the namespace, to make sure our version of the SDK was always included.

Another issue that we encountered is that we had pushed a recent change that removed the ability to get access tokens with infinite life (via the offline_access permission). Our PHP SDK hadn’t been updated to include functionality to easily extend a short-lived access token. As part of our work with the WordPress plugin, we updated the SDK to include this (via the setExtendedToken function).

Launch

Once the plugin was ready to launch, I knew I needed to get help to make sure that it found the right external audience. Internally, I found folks from PR, design, partnerships, security, marketing, policy, legal, and other teams to help launch it. It took only a little more than a

I really appreciated the fluidity of this experience, something that I think is unique to Facebook. It feels like being at a startup, except that you actually have resources to get stuff done—lots of smart people, a strong brand, and a bunch of other qualities that aren’t usually available to a startup. While I could still build things like a WordPress plugin at a startup, there’s no way that the WordPress plugin would have seen the success it had without all of these things.

Open source and beyond

At release, the plugin was downloaded more than 12,000 times in 24 hours, and the blog post received some of the highest engagement we’ve seen. Since launch, we've begun fixing all the issues we ran into. We’ve also open sourced the code on GitHub, so that anyone can contribute code and track our progress. You can check it out here.

Developing the WordPress plugin gave us a great opportunity to dogfood our own tools. It's been a great reminder of what a developer experiences on a daily basis, and as a result, we've uncovered some bugs and work flows that we will continue to improve.

Keep Updated

Stay up-to-date via RSS with the latest open source project releases from Facebook, news from our Engineering teams, and upcoming events.

Subscribe
Facebook © 2017