WordPress REST API Meta Endpoints

Over the past couple of days I have been helping to contribute to the WP-API Meta Endpoints feature plugin.  It has been a great experience and has taught me a lot about the WordPress REST API, Unit Tests and GitHub.

Meta Endpoints

The WordPress REST API is moving along quite well.  Certain parts of the API are larger than others and some of those have now been broken off into their own separate feature plugins, WordPress’s way of adding small features into core.  The WordPress REST API Meta Endpoints are no different as they have now been put into this feature plugin release workflow.  I like this idea and I think it is really helpful for newer core contributors, like myself, to really come into the space with a low barrier to entry.

When I saw that the WordPress REST API Meta Endpoints were being put into a feature plugin I rushed over to the GitHub repo to see if there were any outstanding issues I can help with.  Instead of finding issues I found out that the Post meta endpoint had be created as well as the foundation of the meta endpoint in general but the User, Comment and Term meta endpoints had yet to be created.  So I figure that a great way to help would be to add in those endpoints 🙂  This was not a super hard task at all since most of the work was already done via the great WP_REST_Meta_Controller class.  Most of the work was creating the proper test cases to make sure that the new endpoints actually worked.  This is where most of my learning came from.

Unit Tests

To make sure that all the code written for the WordPress REST API is sound and secure, WordPress uses PHPUnit to test all of the edge cases and functionalities of the code written.  PHPUnit is fantastic but if you use a continuous deployment service like Travis CI with your unit test then you have a really solid development workflow.  By contributing to the WordPress REST API Meta Endpoints feature plugin I was able to experience using Travis in a real world environment and it was awesome.  I loved how I was able to create a GitHub pull request and see it pass or fail in real-time from Travis CI.  It made it very easy to know when your pull request was ready to merge because it would should a little green checkmark next to it indicating that it passed all of the Travis CI tests.


I have been using GitHub for a while now but I have not used it where I was not the owner of the repo.  Usually I would just write the code myself and go through my own tests and then commit the code.  Since I do not own the WP-API Meta Endpoints repo, the only way to contribute via a pull request was to fork the repo and then create a new branch.  After a created my local branch I could then commit it to my forked repo and then create a pull request form that branch.  I learned a lot about GitHub that I did not know previously from this experience.  Also, I ran into a lot of merge conflicts, which I had not run into before so I had to learn how to workaround those.

Overall contributing to the WP-APi Meta Endpoints repo was a great learning experience and also I hope the code I wrote helped out the REST API team to advance the API 🙂

1 thought on “WordPress REST API Meta Endpoints”

  1. Great post, thank you for contribution. It really helped me, maybe i can make it too 😀

    I like how you found way to contribute, coded and even tested out your solution.

Leave a Reply