I did it!
In honor of President-Elect Donald Trump, and in an effort to learn plugin development for WordPress, I made this, an homage to Hello, Dolly of course:
Even though it is effectively a very similar result as Hello, Dolly. I decided to try to up the ante a bit and use a publicly available API to get the random list of quotes, rather than storing them in local memory. Enter the “What Does Trump Think” API. Yes, that’s right, an API that insults you.
Initially I intended to use PHP Curl calls to the API, but soon I found out about wp_http() and decided to use that, to put less of a requirement on users of the plugin. Look, I get that this thing is very simple, but I was using this as a learning opportunity, later on I intend to make more complicated plugins and it’s good to get the fundementals right!
If you haven’t used this http API, it looks something like this:
You can see the last line there sets a WordPress “Transient” for caching. Functionally, at first, I was hitting the API on every page load to grab one of their /random quotes to display on the page, but later I added the update to the plugin that cached “all” quotes from the root /quotes endpoint and randomly selects one from the list to display on each page load from the database. In the same update, I added shortcode support for posts and pages.
All said and done, It was a super cool experience going through the handbook and making sure the readme was up to snuff. I learned a lot, so that the next (admittedly, “REAL”) plugin submission process will hopefully go smoothly.
Does anyone else remember their first plugin? Would love to hear stories and inspiration, or critiques of my simple work haha