I threw together a widget for my blog that displays the short URL to a post or page and since multiple expressed interest in using it on their own site, I’ve decided to release it. My YOURLS: Short URL Widget plugin will add a widget (Appearance -> Widgets) that will only show up on individual posts or pages and will output content of your choosing, including the short URL to that item as generated by the YOURLS: WordPress to Twitter plugin which is required for my widget to do anything.
Monthly Archives: November 2009
The Muppets: Bohemian Rhapsody aka YouTube Adds 1080p Support
YouTube has supported 720p video for a while now, but if you have a monitor that’s more than 1280 pixels wide, then you’ll be happy to know that YouTube has been rolling out 1080p support for the past week or two.
So what’s the difference? See for yourself using this hilarious example of The Muppets covering Queen’s Bohemian Rhapsody. Click on the little “HD” button in the bottom-right of the video frame, select “1080p”, and then press the fullscreen button. Of course 1080p video itself is nothing new, however it is something that’s rather rare when it comes to streaming video. I for one am incredibly happy that YouTube has decided to move into the future instead of lagging behind like they have in the past when it comes to video quality.
Now if only I could choose 1080p from the embedded version…
(via Gizmodo)
WordPress Code: Earlier Shortcodes
WordPress shortcodes run at priority 11 which is after wpautop(), wptexturize(), and other various default filters. While this can be desirable so that wpautop() doesn’t affect the output of the shortcode (the function is well known for not being perfect), it can also be a drawback as wptexturize() will malform your shortcode contents.
Take this shortcode usage for example:
[html]This is some text.
[foobar]This is how you "quote" things.[/foobar]
This is some more text.[/html]
The “foobar” shortcode callback will receive the following string:
[html light=”1″]This is how you “quote” things.[/html]
Well that’s not obviously right. Okay, so you could fix it with some str_replace()‘es to reverse the fancy quotes and other changes, but why go to all the trouble?
Instead, let’s just make the shortcode run before priority 10 when wpautop(), wptexturize(), etc. mangle our shortcodes. That way we can process the shortcode as the user typed it and when once we’re done let wpautop() and it’s friends handle the content like they were designed to do.
First, here’s the code I use. I’ll explain it afterward.
[php]// This will do nothing but will allow the shortcode to be stripped
add_shortcode( ‘foobar’, ‘__return_false’ );
// Actual processing of the shortcode happens here
function foobar_run_shortcode( $content ) {
global $shortcode_tags;
// Backup current registered shortcodes and clear them all out
$orig_shortcode_tags = $shortcode_tags;
remove_all_shortcodes();
add_shortcode( ‘foobar’, ‘shortcode_foobar’ );
// Do the shortcode (only the one above is registered)
$content = do_shortcode( $content );
// Put the original shortcodes back
$shortcode_tags = $orig_shortcode_tags;
return $content;
}
add_filter( ‘the_content’, ‘foobar_run_shortcode’, 7 );[/php]
The function starts by global’ing the variable $shortcode_tags. This is the variable that contains a list of all registered shortcodes. We then make a copy of that variable (so we can restore it later) and then empty it out so that no shortcodes are registered.
Now that there’s no shortcodes registered, we register our shortcode and call do_shortcode() which is the function that replaces shortcodes with their contents. Once that’s done, we restore all of the previously registered shortcodes (this also unregisters our shortcode so it doesn’t run again) and return the result of the do_shortcode() call.
Lastly we register that function as a filter but at an earlier priority than wptexturize() so that it will run first. Any number between 1 and 9 will do — I just use 7 as it’s fairly late but still leaves room for other filters to come after it but before wptexturize(). That and it’s my favorite number. 😉
Questions? Improvements? Then leave a comment. 🙂
“3D” Projections On Buildings
Check out this really cool video from a company that uses a powerful projector (or projectors) to overlay a 3D version of the building onto the real building and then manipulates the image to pull of some really awesome effects:
(via @azaaza)
EDIT: The English version of the site at the end of the video is projectionsonbuildings.com.
WordPress 2.9 Beta 1
WordPress 2.9-beta-1 is available! Get it here: zip, tar.gz. Start hammering away.
You can also just install the super handy WordPress Beta Tester plugin to make the one-click upgrade feature upgrade you to WordPress 2.9 Beta 1.
Remember though — it’s still beta software, so backup your database and don’t run it on a site that you can’t afford to be buggy. 😉
Source: wpdevel
EDIT: Here’s two links covering some of the new features, including my embeds feature. The Codex also has a list going although it seems to be missing embeds.
SyntaxHighlighter Evolved v2.3.0
I’ve released a new version of my SyntaxHighlighter Evolved plugin. It’s not a recode of the plugin, however it is a major overhaul of the plugin. It features an update to the highlighting package (with new languages and parameters) and other various things. Here’s the full changelog:
Version 2.3.0
Major overhaul, mainly to extend flexibility so that this plugin could be used on WordPress.com without actual code modification (only actions/filters are used instead to modify it).
- Updated SyntaxHighlighter package to v2.1.364. Highlights of the changelog include:
- ColdFusion brush (aliases:
coldfusion,cf)- Erlang brush (aliases:
erl,erlang)- Objective-C brush (aliases:
objc,obj-c)- Eclipse theme
padlinenumbersparameter. Set it tofalsefor no line number padding,truefor automatic padding, or an integer (number) for forced padding.rbalias for Ruby- Commenters can now use this plugin to post code.
- Plugin’s shortcodes now work inside of the text widget again. Requires WordPress 2.9+ though.
- Overhaul of the TinyMCE plugin that assists in keeping your code sound when switching editor views. Thanks to Andrew Ozz!
- This plugin’s stylesheets are now dynamically loaded. If they aren’t needed, they aren’t loaded.
- Lots of sanitization of shortcode attributes. Invalid keys/values are no longer used.
- Chinese translation thanks to Hinker Liu. Will need updating for v2.3.0.
- New filter to control what shortcodes are registered. Used by WordPress.com to trim down the number of them.
- Saving of user’s settings is now done using
register_setting()instead of manually handing$_POST. Yay!- By default, a post meta is used to mark posts as being encoded using the 2.x encoding format. This is bad for a site like WordPress.com. You can use the new
syntaxhighlighter_pre_getcodeformatfilter to return1or2(based on saypost_modified). SeeSyntaxHighlighter:get_code_format()for more details. Don’t forget toremove_action( 'save_post', array(&$SyntaxHighlighter, 'mark_as_encoded'), 10, 2 );to stop the post meta from being added.- New
syntaxhighlighter_precodefilter to modify raw code before it’s highlighted.- New
syntaxhighlighter_democodefilter to modify example code on the settings page.
New Theme (Work In Progress)
For those of you who have visited my blog before, you may notice that my blog is rocking a new theme. Yes, after over 4 years I’m finally ditching my very hacked up version of the “Neat!” theme for something a bit more modern. It’s called Mystique and it was made by digitalnature.
I’m still making minor tweaks to the theme, so bear with me while I make the transition and feel free to report any issues in the comments for this post. 🙂
More Ken Block Badassitude
I love Ken Block. He does some really crazy shit with rally cars and he’s done it yet again.
(via TopGear.com as usual)
New Plugin: Local Time
Using Javascript, Local Time automatically transforms all dates and times on your blog into the visitor’s timezone. You can see for yourself right here on my blog. Make sure you’re viewing the single post view of this post and look at the grey post info box below. If you aren’t in the PST timezone (Western USA), the date and time will transform into your timezone once the page finishes loading.
For example, for this post I see “This entry was posted on November 1st, 2009 at 3:08 PM” while you may see something different (depending on your timezone). Cool, huh? 🙂
Enthusiastic Co-Driver
I want this guy to be my GPS voice. WARNING: NSFW AUDIO!
(via TopGear.com)