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.
My goal: have a place for Leah and I to store all of our photos and videos (and maybe documents too). Both of us have gigabytes of media from the last decade or so, with more to come. I’d like for the hardware layer to work well with the software layer — it should be easy to access and upload on a daily basis. Ideally, it should be in the cloud so I don’t have to worry about hardware failure. Realistically, I only care about catastrophic backup.
Options I’ve looked into over the last two hours:
- Attach a USB hard drive to our ASUS N66U router to serve as NAS. Reportedly, this is possible. However, when I began my search, I came across this article from February 2014: “Dear Asus router user: You’ve been pwned, thanks to easily exploited flaw.” This doesn’t give me much confidence, particularly considering I’ve never upgraded our router’s firmware and have no desire to do so.
- Buy a Time Capsule, connect a secondary USB hard drive, and put a common iPhoto library on it. However, this comes with a bunch of caveats. Namely: it doesn’t really work. Plus you really need to commit to a wired connection.
- Chuck all of our media assets into one of those fancy file sharing services. Box appears to have the best deal: unlimited storage for $15/month. However, that’s on the Business plan with a 5 user minimum.
- Use Dropbox or BitTorrent Sync to sync files between our computers. We’d get an additional layer of redundancy. Leah has 500 GB free and I have… 30 GB free (SSD).
- Buy an iMac and use it as our shared family computer. We can use whatever we want, but we’d have to figure out where to put it in our small condo.
- Or buy a Mac Mini, put it in the figurative closet (actually the bottom of the changing table, where our printer is), and VNC into it when want to manage photos. Might be on to something there.
P.S. Crashplan supports backing up a NAS drive as long as you can mount it. It’s $60/year for unlimited data. And Dropbox is $100/year for 100 GB. How does that work?