I’m Alison Barrett, and I like WordPress. A lot. I’m a PHP developer at GoKart Labs. You might want to read a little more about me, check out some of my WordPress tutorials, or drop me a line. Or just do some clicks on the hyperspot links on the Web Page below.
Presentations
WordPress
Avoid Breaking All the Things: How to Develop Safely
I spoke at WordCamp Minneapolis 2014 this past weekend. My talk was about development best practices, especially when it comes to non-destructive coding (i.e. version control). Here’s the video, along with my slides:
WordPress
Coming soon: a new wp-wallpaper.com
When I’m at WordCamps, I always get asked by at least one person where I got my WordPress-branded desktop wallpapers from. I got most of them from wp-wallpaper.com, which had a few dozen nice wallpapers available for download. I always refer the aforementioned people to that URL.
Today I discovered the site was down. The domain didn’t even resolve to anything. Lo and behold, wp-wallpaper.com was up for grabs. So I grabbed it.
Anyone know who used to run t.co/nA29tAPOKj, or who made the wallpapers? I want to relaunch the site but don't know who to credit.
— Alison Barrett (@alisothegeek) August 5, 2013
Also, if you have an original WordPress wallpaper you want posted on the new t.co/nA29tAPOKj, ping me!
— Alison Barrett (@alisothegeek) August 5, 2013
I plan on keeping the site’s spirit alive. It will be a curated collection and the downloads will all be free.
I have no idea when it will be up, or how many wallpapers it will have. (Under-promise, over-deliver, right?) If you have a wallpaper you want to submit, please do so! You can ping me on Twitter or contact me here.
Presentations
WordCamp San Francisco 2013 Presentation: Lessons Learned in Unit Testing
Here are the slides and the video for the presentation I gave at WordCamp San Francisco 2013. Yay!
The Nerdery 9555 James Ave S, Suite 245 Minneapolis, MN
49 WordPress Enthusiasts Went
WordCamp Extravaganza!We look forward to welcoming some out-of-town guests to our local WordPress meetup.Sessions will include:Grant Landram (Seattle) – “Customizing WP-Admin”John Hawkins (Las Vegas) – “Membership using Restricted Content Pro”John Havlik (Minneapolis) – “Benchmarking WordPress”Kiko Doran (Hudson, WI) – “Using CodeKit for SASS…
Check out this Meetup →
Code Snippets
WordPress
Adding oEmbed Handlers to WordPress
In the past week, I’ve added a couple of oEmbed handlers to my WordPress theme to enable easy embedding of external media, specifically SpeakerDeck (example) and Meetup.com (example). It’s really easy, and I figured I’d share the knowledge for those who want it.
oEmbed wha?
oEmbed is a standardized format to allow for easy embedding of external content in a website. A service that supports oEmbed functionality will have an “endpoint URL” that all requests point to. Usually, you just pass the URL of the item you want to embed to that endpoint, and it returns the HTML required to embed it. This is what allows you to embed YouTube videos in WordPress by putting the URL on its own line in the editor.
Here’s how!
We need to hook into an action in WordPress to make sure we’re adding the oEmbed handler at the right time, and then use a built-in WordPress function to register a new URL pattern to look for. In this case, the init hook will do the trick.
In your theme’s functions.php file, add the following code (replacing ag with your own function prefix if desired):
Now if you put a SpeakerDeck URL on its own line in the WordPress editor, you’ll have an embedded SpeakerDeck presentation!
Explaining the code
The wp_oembed_add_provider function accepts three parameters:
Pattern to look for in post content
oEmbed endpoint for service
Whether the first parameter is a regex pattern instead of a simple wildcard string (defaults to false)
First parameter: pattern to look for
The first parameter can be either a wildcard string (using an asterisk * for the wildcard) or it can be a full-blown regex pattern. I prefer regex, because I’m nerdy and that’s what I’m supposed to prefer. Let’s look at the regex pattern I used:
#https?://(www\.)?speakerdeck.com/.*#i
We’ll work from the outside in. # is marking the beginning and end of the pattern. The i at the very end is telling it to use a case insensitive search.
A ? means that the item immediately preceding it is optional. It’s used twice here: for the “s” in “https” and the “www.” before the domain. Since the “s” and “www.” are optional, all of the following URLs would match this pattern:
At the end of the pattern is .*. The period will match any character except for a line break character (\r or \n). The asterisk is similar to the question mark in that it applies to the item immediately preceding it. It means “0 or more of the previous item.” This accounts for the rest of the URL after speakerdeck.com/.
Second parameter: oEmbed endpoint
If a service supports oEmbed, you can usually find the oEmbed endpoint in the developer or API documentation for that service. When in doubt, use Google: “_______ oembed endpoint” usually gets you the information you need.
Third parameter: is it regex?
When this is set to true, the function treats the first parameter as a regex pattern. The other option is to use a simple wildcard string, which would look something like this:
https://speakerdeck.com/*
It’s not as powerful or flexible as regex, but it still gets the job done.
What about Meetup.com? You added that too, right?
The code for adding oEmbed support for Meetup.com looks very similar to the code for SpeakerDeck. I can use the same function and just add another line to it.
That’s it! Once I added that to my theme, I could embed SpeakerDeck presentations and Meetup events. Now go add oEmbed handlers to your own site! Have fun!
News
MSP WordPress Meetup incoming: Thursday, January 24
I’ll be giving my “Advanced Actions & Filters” talk at the next MSP WordPress meetup.
MSP WordPress
Thursday, Jan 24, 2013, 7:00 PM
The Nerdery 9555 James Ave S, Suite 245 Minneapolis, MN
45 WordPress Enthusiasts Went
We will be gathering for WordPress and pizza-related conversations on Thursday, Jan. 24, 2013 at 7 p.m. at The Nerdery. Lightning rounds will kick off the evening, so come ready to share a 2-minute promo of something you are working on or something you built – a website, a plugin, a new t-shirt, etc. Then, Alison Barrett, a genius Automattician, …