While we're on the Shortcodes and Git subjects, I did some testing on a few themes I have that use shortcodes mostly for static styling, i.e. pricing boxes, author fields, column shortcodes etc that provide some markup layout that wraps some details and forms page output based on this data. <div>
<br>So I wrote a small snippet that does this conversion - <a href="https://github.com/mpeshev/DX-Shortcode-Freezer">https://github.com/mpeshev/DX-Shortcode-Freezer</a></div><div><br>It's probably not optimized or secure enough, but it can actually help when switching themes and prevent the 'hundreds of pages with square bracket snippets' hell. This one evaluates the shortcodes and replaces the DB content with the actual HTML markup at the moment of generation. Then switching between themes is a little less painful. <br clear="all">
<br>Mario Peshev<br>Training and Consulting Services @ DevriX<br><a href="http://www.linkedin.com/in/mpeshev" target="_blank">http://www.linkedin.com/in/mpeshev</a><br><a href="http://devrix.com" target="_blank">http://devrix.com</a><br>
<a href="http://peshev.net/blog" target="_blank">http://peshev.net/blog</a><br><br>
<br><br><div class="gmail_quote">On Fri, Feb 17, 2012 at 10:04 PM, Otto <span dir="ltr"><<a href="mailto:otto@ottodestruct.com">otto@ottodestruct.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Fri, Feb 17, 2012 at 1:26 PM, Bruce Wampler <<a href="mailto:weavertheme@gmail.com">weavertheme@gmail.com</a>> wrote:<br>
> And as for YouTube, my theme is completely responsive, as well as including<br>
> extensive mobile device specific support (things beyond being responsive,<br>
> such as selective excerpt/full display of posts, or using different menus<br>
> depending on the device). There simply are no existing ways to properly<br>
> display YouTube videos without the intimate knowledge my theme has about the<br>
> device it is being displayed on. And it is really critical that the videos<br>
> be displayed properly on a specific device. Not allowing a theme integrated<br>
> shortcode for that would completely break proper display of those videos.<br>
<br>
</div>I was curious about this, so I decided to test a theory.<br>
<br>
If you adjust the $content_width global dynamically based on the<br>
device width detection method you're using (say you detect an iPhone<br>
and so set it to something less than 480),then the built in oEmbed<br>
technique will change to adapt to it.<br>
<br>
For example: make a test site using twentyeleven. Embed a youtube vid<br>
on there using the [embed] code or using the URL-on-its-own-line<br>
method. Load the site and you'll see the youtube video at 584 pixels<br>
wide.<br>
<br>
Now, edit the twentyeleven functions.php file and change the<br>
$content_width to, say 300. Load the site again. Note that you haven't<br>
edited the post or changed the site in any other way. You'll find the<br>
video is now smaller.<br>
<br>
Note that it will take a second longer to display the page the first<br>
time with the new width, because oembed has to get triggered into<br>
making a new call to the Youtube oembed endpoint, but the result of<br>
this will be cached in the post_meta, so it only makes that one hit to<br>
get the new iframe code from Youtube.<br>
<br>
The reason this works has to do with the caching mechanism of oembed.<br>
In processing the normal [embed] shortcode, the handler checks<br>
post_meta for the cached response from the oembed http request.<br>
However, the cache key is an MD5 of the serialized array of<br>
attributes. Those attributes include the URL being requested, of<br>
course, but also the width it's asking for. The $content_width is the<br>
default width used, and if the $content_width changes, then the cache<br>
keys won't match and it'll make a new request with the new attributes.<br>
<br>
So here, you're mistaken. You don't necessarily need to have a special<br>
shortcode for handling youtube videos, or any other videos that are<br>
supported by oEmbed. All you have to do is adjust your $content_width<br>
to one that is appropriate for the device. Then the built in embed<br>
mechanisms will handle it just fine.<br>
<font color="#888888"><br>
-Otto<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
theme-reviewers mailing list<br>
<a href="mailto:theme-reviewers@lists.wordpress.org">theme-reviewers@lists.wordpress.org</a><br>
<a href="http://lists.wordpress.org/mailman/listinfo/theme-reviewers" target="_blank">http://lists.wordpress.org/mailman/listinfo/theme-reviewers</a><br>
</div></div></blockquote></div><br></div>