Introducing Shortcake. UI framework for your WordPress shortcodes. Fusion’s first (of many) open source projects.
deliciousbrains/testdriiive. MVP application for premium theme shops to provide a “test drive” experience of their designs. Users get a fully-functional WordPress install where they can upload a WXR file to see how their theme works with their content.
This past week, I got to do my first client project using WP-API. The scope of the project is to create custom endpoints for a WordPress-based web application. The endpoints will eventually be used to power iOS and Android apps.
I thought I’d use the opportunity to gauge usability of using it in a project. My feedback is from the perspective of a developer needing to create custom endpoints for WordPress — I haven’t written any client-facing code yet.
These notes are roughly edited. Mostly I just want to get them up before WCSF.
What I like
WP-API has a comfortable implementation of using WP_Error for returning error responses in my endpoint callbacks. Being able to specify the HTTP status code is a great touch.
Extending WP-API’s core classes is really nice for DRY. They should be designed to be extended — I’d suggest they’ll be more commonly extended than used standalone.
For instance, I was able to get a lot of mileage out of extending
WP_JSON_CustomPostType and customizing the response values for
prepare_post(). However, I basically reset the original array (because the project has different data models), so it would be cool if there was some reusability there.
Also, I was able to easily add an authentication check for get_posts(). But, I wasn’t able bypass delete_post()’s capability check, so I needed to create my own.
Context argument is proving to be easily reusable. I invented my own context that seemed to fit in the paradigm.
Route registry is pretty much copy and paste == it works. I love the style of route definition too:
What can be improved
Using bitmask operators to map HTTP methods to callback isn’t terribly intuitive, although it’s easy enough to get going by copy and paste. I’ve never liked that part of the Rewrite API, and don’t think we should repeat it.
It would be nice to be able to modify the “data” field associated with a WP_Error entry. I’ve set up my models to return WP_Errors, but then I need to recreate that error in my controller to include the status code.
Because we have a variety of content models that are often mixed and mashed (e.g. a Post displayed with Author, Terms, and “Featured Image” Attachment), we should do embedded media really well. I think this is lacking in WP-API right now — you basically need to reinvent the wheel on each endpoint.
I’ve spent way too much time writing code to define and validate supplied arguments. I know this is something I like and Ryan hates, but it would be cool if we could nail field definition and validation for endpoints. This is something we did with H-API. It seems like we’re part of the way there by using Reflection for argument definition in our endpoint callbacks. Easy type validation is just the next step — maybe it could be introduced as an optional library.
On that note too, using Reflection against the defined method arguments to decide which request arguments are passed is too magical. It’s new to PHP and will be completely baffling to Joe Shmo WordPress developer.
Slow cooker prep for tomorrow.
On Zack’s indirect suggestion, I’ve decided to do a clean install of Yosemite. As I wait for Yosemite to download, I thought I’d do an itemization of the software I’m using these days. The last time I did this was January 2011 — fun to see how some things change and others remain the same.
Writing code and leading development teams is my full-time job. For local development, I use Vagrant and Salty WordPress. I was using VMWare Fusion for a while, but the filesystem caching issues drove me back to Virtualbox. I edit files with Sublime Text 3 running the Colbalt 2 theme. iTerm 2 (full-screen mode, duh) tames my terminal windows. Only on a rare occasion do I have to open Cyberduck to SFTP somewhere.
On the command line, my life is complete with ZSH, autojump, Git, hub, and WP-CLI. I consider every day I don’t have to use Subversion to be a good day. Most projects I’m on use Github with a as-simple-as-possible feature branch pull-request workflow.
Bartender wrangles my menu bar into submission. If I didn’t have it, my menu bar would be overrun with icons for:
- 1Password – The only sane way to use passwords these days.
- Quickcast – Shareable screencasts in just a few minutes.
- Glui – Annotated screengrabs. Far superior to Skitch.
- Alfred – Maybe obsoleted by Yosemite.
- RescueTime – Keeps track of which applications I’m using. I mostly use it for the weekly email summaries.
- Sidestep – Securely your internet traffic over any SSL connection.
- Flux – For the rare occasion I have the computer on past 7 pm.
- Clocks – Menu bar clock replacement for those who always be coordinating in multiple timezones.
- Caffeine – Jiggles your mouse when you need your screen to stay awake. Useful when giving presentations, etc.
- Crashplan – Affordable service for keeping everything backed up in the cloud.
How I run my business is really a post in itself. Harvest is indispensable — I use it for sending estimates, time tracking, and billing. Things is awesome for keeping track of what needs to be done and when. A long time Remember The Milk user, I love having a dedicated desktop application for task management. Mailplane is the best way to deal with email in 2014.
Oh, last but not least, I use a mid-2011 13 inch Macbook Air with a 256 GB SSD and 4 GB of RAM. It’s the best computer I’ve ever owned.
“Use different Apple IDs for iCloud and iTunes?” Yes, but not willingly…
The Dispatch – Daniel Bachhuber. I made it on a podcast! Although I’m too embarrassed to hear myself speak — someone will have to tell me how I did.
InVision. Slick web app for reviewing / commenting on design comps. (via Matthew E.)
Turning questions into metrics. I love it when Stijn writes long blog posts. Gets me all warm and fuzzy about journalism.