echo wp_oembed_get fix

Pure click-bait gold, baby!1 You know I’m focused on those high-traffic titles. And now on to the show . . . I’m doing a site for the esteemed Jon Becker’s school law class. The goal is to take tweets that exemplify really bad legal choices by public school administrators. They even have a hashtag – #schoollawwtf. Since we’re taking tweets into WordPress for further analysis we end up with some weird constraints. I can’t rely on useful titles if we want to automate this as the tweet content might contain any number of things and the regex to try to purify it wouldn’t be worth the hassle. New content wouldn’t have any body text either because it’s just a tweet. Granted, I could duplicate that text in the body but I didn’t really see much point in that. I opted to stick the tweet URL in a custom field. That soon led me to the handy wp_oembed_get function which was new to me.2 That worked very nicely for display on single posts (screenshot and code snippet below). Where it ended up failing me was when we needed to display a bunch of tweets in need of analysis. All I had were the Twitter oEmbed element to show and clicking on them would take you to Twitter-land rather than to thee […]

oEmbed Additions in WordPress

One of the minor hassles of running WordPress Multisite is dealing with the rules about HTML cleansing- mainly the removal of iframe elements. You could install unfiltered MU but the plugin itself warns you that’s end-of-the-world dangerous and the plugin hasn’t been updated in two years. The combination might make one a bit nervous. In this particular case, I have a group who wants to use videos from dotsub.com. Turns out it’s a good site for captioning and other things that make the video more accessible. This group is working on universal design so dotsub makes doubly good sense. WordPress supports a number of sites using oEmbed. That’s the magic that allows you to paste in a YouTube URL and the embed codes are taken care of without you having to do anything. WordPress essentially run off a white list of sites that it accepts off the bat. It turns out that oEmbed lists a bunch of sites that support the API and dotsub.com ended up being one of them.1 That means I just have to add dotsub.com to the WordPress install’s whitelist. The ever handy WordPress codex lets me know that I do that using wp_oembed_add_provider and further down on that page you’ll see that lives wp-includes/media.php. I could have done it this way but I don’t like editing […]