Aliso the Geek

Follow @alisothegeek LinkedIn
Menu
Hide This Forever

First time here?

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:

8 Comments on Avoid Breaking All the Things: How to Develop Safely
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! spacer

— 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.

No Comments on Coming soon: a new wp-wallpaper.com
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!

Resources for getting started with unit testing:

  • PHPUnit Manual (including installation instructions)
  • A great list of resources from @aaroneaton
  • Unit testing with wp-cli (thanks @JS_Zao for the link on Twitter)
No Comments on WordCamp San Francisco 2013 Presentation: Lessons Learned in Unit Testing
Event Coverage

BuddyCamp Minneapolis begins!

BuddyCamp begins! #wcmpls twitter.com/alisothegeek/s…

— Alison Barrett (@alisothegeek) April 28, 2013

No Comments on BuddyCamp Minneapolis begins!
News

Next MSP WordPress Meetup: Thursday, April 25

MSP WordPress

Thursday, Apr 25, 2013, 7:00 PM

The Nerdery
9555 James Ave S, Suite 245 Minneapolis, MN

49 WordPress Enthusiasts Went

spacer
spacer
spacer
spacer
spacer
spacer
spacer
spacer

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 →

No Comments on Next MSP WordPress Meetup: Thursday, April 25
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):

add_action( 'init', 'ag_add_oembed_handlers' );
function ag_add_oembed_handlers() {
	wp_oembed_add_provider( '#https?://(www\.)?speakerdeck.com/.*#i', 'https://speakerdeck.com/oembed.json', true );
}

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:

  1. Pattern to look for in post content
  2. oEmbed endpoint for service
  3. 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:

 https://speakerdeck.com/aliso/advanced-actions-and-filters
 speakerdeck.com/aliso/advanced-actions-and-filters
 https://www.speakerdeck.com/aliso/advanced-actions-and-filters
 www.speakerdeck.com/aliso/advanced-actions-and-filters

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.

add_action( 'init', 'ag_add_oembed_handlers' );
function ag_add_oembed_handlers() {
	wp_oembed_add_provider( '#https?://(www\.)?speakerdeck.com/.*#i', 'https://speakerdeck.com/oembed.json', true );
	wp_oembed_add_provider( '#https?://(www\.)?meetup.com/.*#i', 'api.meetup.com/oembed', true );
}

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!

2 Comments on Adding oEmbed Handlers to WordPress
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

spacer
spacer
spacer
spacer
spacer
spacer
spacer
spacer

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, …

Check out this Meetup →

No Comments on MSP WordPress Meetup incoming: Thursday, January 24
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.