Stephan van Rooij

Software architect with a passion for home automation.

Hosting a wordpress plugin on Github

H

Someone at WordPress decided that if you want to create a plugin for WordPress, you’ll have to host it at their SVN server. Personally I’m not a big fan of SVN, I’m more a GIT person.

Lucky for me, it appears I’m not the only one. So for my latest WordPress plugin (REST API – Filter Fields) I used Github. Then I came to a few problems that had to be solved.

Small problems

  • Github wants a README.md (markdown) file and WordPress wants a readme.txt file with some required options
  • How do I deploy a new version of my plugin to the WordPress SVN server?
  • And how can I make this proces as easy as possible?

Grunt to the rescue

Grunt is a Javascript Task Runner build in node.
You can instruct it to do some tasks for you. These steps I created to make my life as a WordPress Plugin developer easier:

  • Use ‘wp_readme_to_markdown‘ to create a README.md file right from the required README.txt
  • Use ‘grunt-contrib-copy‘ to create a ‘build’ folder with all the files required for the plugin
  • Use ‘grunt-wp-deploy‘ to parse the ‘readme.txt‘ and the ‘rest-api-filter-fields.php‘, to verify their version tags match (required) and to deploy this new version to the wordpress svn

This way when I edit my readme.txt, I run ‘grunt build‘ to create the readme.md file (for Github). This takes about 1 second. And it makes sure they both have the same text (only formatted slightly different).
If I edited the plugin (and the version number / changelog), I enter the command ‘grunt deploy‘. It then copies all the files to the ‘build’ directory, asks me if I want to deploy the version x. And then it prompts for my wordpress svn password.

Sounds good, how do I use it?

Before you get started you’ll have to make sure that you install node, npm and grunt-cli.
The first two should be easy, the last one can be installed by using npm install -g grunt-cli
Getting started with Grunt is described at their site, see Getting Started. Using the modules to create the readme.md and to publish the plugin, are also not that hard. Just check-out their repositories.

If you cannot get this setup (for publishing your wordpress plugin) working, you can always have a look at the Gruntfile.js file in the repository.

Install wordpress server site

I

You can install wordpress by using FTP, but sometimes it’s much quicker to do it server site. Basic linux knowledge is needed!. First SSH into the server.

WordPress just got even better!

W

Yesterday WordPress 4.4 was released, with this version they improved this product even more.

The most notable new features are, support for oEmbed and an integrated REST API.

What is oEmbed and why is this a new amazing feature? oEmbed is a specification for embedding content from an other website right inside the consuming website. This enables (for instance) Twitter to display the excerpt of a post instead of just a link to your wordpress website. This specification is originally design by (members of) Flicr, but with the wordpress implementation the adoption will get even bigger.

Like what you're seeing? Consider Sharing on Twitter or Sponsoring me