Every Wednesday at 1500 hours it’s time for #redbullonsdag (Red Bull Wednesday).
This post is not in any way endorsed by Red Bull … But it should be … Do you work at Red Bull? Contact me!.

Every Wednesday at 1500 hours it’s time for #redbullonsdag (Red Bull Wednesday).
This post is not in any way endorsed by Red Bull … But it should be … Do you work at Red Bull? Contact me!.
One of my goals for 2012 is to to get credit for a patch in the WordPress core. It feels like it would be neat. Nerdy… But neat.
This vacation week, when I was going to play Skyrim, but ended up watching all Alien movies on Bluray and coding some WordPress, I might have found my bug. A user in a WordPress dev Facebook group asked if anyone had received pingbacks on custom post types. He hadn’t and was starting to believe something was wrong within WP. I thought it sounded like a fun thing to investigate. So I did. And it turns out it is… I think.
The reason seams to be that the XML-RCP server uses a function called url_to_postid() to get the post ID from the pinged URL. So if the ping is for a regular post and the site is using permalinks it might be something like feedmeastraycat.net/2012/01/08/on-the-road-to-a-wordpress-core-patch/ in which case /2012/01/08/on-the-road-to-a-wordpress-core-patch/ is sent in and the post id is returned. The problem seams to be that it doesn’t handle custom post type urls.
If there is a CPT named “products” and you have a post with the slug/name “macbook” you might have the url test.com/products/macbook/. The url_to_postid() function goes through the rewrite rules and tries to find a match. Which it should do. It then creates a query for that match, which in this case looks like this:
Array
(
[products] => macbook
[page] =>
)
The problem here is that this query will fail. WP_Query requires a ‘post_type’ => CPT_Name parameter as well. It should look like this:
Array
(
[post_type] => products
[name] => macbook
)
During a regular page call, this is made in WP->parse_request() (here). Not in WP_Query.
Well. I created a ticket and I’ve also added a suggested patch. In a comment. Cause I don’t know how to do it as a real patch… I hope that I haven’t missed anything. And that the higher up:ers like my patch suggestion. It would be nice to get a patch in early and free up 2012 for new goals.
And it feels pretty good! It actually runs really well on my 12 GB RAM, 27″ display, mid 2010, iMac. In 1080p with settings on high … But I think I might have a smal bug with some face texture display thingy.
Edit: 2011-11-27 — Seams like Bethesda has released a patch during the night. Looks much better now! :-D
I’ve added a page here for some WordPress snippets I’ve created recently. Just for fun. They are small pieces of code where I doesn’t really feel the need to put them into plugins. The plugins feature in WordPress is great. Obviously. But sometimes when you do themes it’s nice to skip the initial fifteen odd plugins that all do one or two, small things. I’ve added the code to my Github repository. I’m a Github newbie. But it’s a lot easier to keep the code there, and make sure it’s updated, instead of posting it on the blog. And you can follow me there as well to see when I post updates… ;)
I just got Google+. There seems to be a bug in the invite system. If you share a link with someone who doesn’t have Google+ they can join. Without invites. Use it before Google fix it! :)
Added explanation:
1) Find someone who has Google+
2) Have them share a link with you (or someone who hasn’t got Google+)
3) Click the link in the e-mail sent
3) Join from that page
If it doesn’t work, Google might have fixed it! :)
In other news I’ve added ShareThis and Flattr. So Flattr me and I’ll use the money for good. I promise!
Updated – Twitter says that Google has closed the backdoor now. It was fun while it lasted … :)
A couple of days ago I wrote about my problems with Å, Ä and Ö in my Twitter import. Read that post first…
Have you read it? No? Ok. I’ll wait a couple of minutes more then…
Done now? Good.
With the help of my co-worker Per I have now a fixed version of Twitter Tools that seams to work 100% with all allowed Twitter tags. The new regexp is as follows:
'/(^|\s)#([\pL\w]+)/u'
I have also remove the double space insert/remove thingy. So the whole thing looks like this:
$tweet = preg_replace_callback( '/(^|\s)#([\pL\w]+)/u' , create_function( '$matches' , 'return aktt_hashtag_link($matches[2], \' #\', \'\');' ) , $tweet );
I’ve made another small change though to the aktt_hashtag_link() function. Which use to look like this:
function aktt_hashtag_link($hashtag, $prefix = '', $suffix = '') {
return $prefix.'<a href="'.aktt_hashtag_url($hashtag).'"
class="aktt_hashtag">'.htmlspecialchars($hashtag).'</a> '.$suffix;
}
See that trailing space after “</a>”, that should be removed. With that extra space the tag “#åsa-nisse” gets a space after “#åsa”, and looks like this: “#åsa -nisse”.
So here is the final look in my Lifestream (red color was added to links for this image only):

Compared to how Twitter does it on their page:

I think that’s a success!? I’m gonna go ahead and send this to Crowd Favorite and see if they can implement it into the plugin.
Edit 2012-08-20 I’ve noticed that there still are some issues with this. I would recommend that you use the Twitter APIs entities to check what should be replaced and where. I’ve done that in the latest update to a small WordPress script that you can see here.
I use the plugin Twitter Tools to import tweets into my blog which I put in my “Lifestream” to the right. It works really good, except that it seams to have a problem with Swedish characters like Å, Ä or Ö. I haven’t had the time or the will to try to fix it. But tonight … I did.
So here is the problem:

The tag should be #GöteborgsVarvet.
I started with The Google and found this thread on the WordPress support forum. But I didn’t like the look of it since it just adds to the reg exp character list. I could have just added my missing characters. But what if a Norwegian dude gets Internet and starts using The Twitter. That won’t do.
So I searched some more and came up with this solution. First I changed the reg exp to this:
'/(^|\s)#([\w\pL]{1,})(\W)/u'
It will search for any “word character” using unicode. Which should make it find å, ä, and ö. But also “the other ones”. From other languages. Then it breaks the tag when it finds any non-word character. For example a “-” or a “(” or something like that. This brings it closer to how Twitter does it:

What we see here is that Twitter gets all the strange tags, even with å or ö in them, but it breaks at the dash character.
However, I still had a problem with the reg exp. It couldn’t find tags in a row. If the tweet had three tags in a row it only matched the first and the last. I solved this, ugly, by first changing all white spaces to double white spaces. And after the hash tag match I change them back. So the full code now looks like this:
$tweet = preg_replace("/(\s)/", " ", $tweet);
$tweet = preg_replace_callback(
'/(^|\s)#([\w\pL]{1,})(\W)/u'
, create_function(
'$matches'
, 'return aktt_hashtag_link($matches[2], \' #\', \'\');'
)
, $tweet
);
$tweet = preg_replace("/(\s\s)/", " ", $tweet);
The only problem left now is that if you have a tag with a dash, it will remove the dash. So instead of “#åsa-nisse” with a link on “åsa”, like Twitter does. It outputs “#åsa nisse” with a link on “åsa”. Like this:

All tags are found, but the dash is missing from “åsa-nisse”.
Now I just hope that the guys over at Crows Favorite sees my e-mail and fixes this in the official release. Hopefully with an even nicer solution.
By the way…
To fix this hack, from home, on a Saturday, I finally bought Coda in the Mac App Store. It’s a bit expensive. I’m using Eclipse at work, which is free and has more features. I really miss the autocomplete features. But for quick hacks on Saturdays, Coda is really nice. Eclipse is bloaty and slow. I hope I can find some good plugins for autocomplete or that Panic can add it. I would love to be able to Switch. Coda feels more like Xcode 4. I would love to be able to do all my work in Xcode 4. But since I code PHP and not Objective-C at work … Well. Let’s give Panic some money by buying Coda and hope for the best! /rant
Time to go and give my Emma some cuddle before she gets totally bored out of her mind. Peace.
Ordered a new custom Gelaskin, designed by Smäm (still), this time for my iPhone 4. It looks almost as good as last time… I also put a front cover on it. All of a sudden I feel like those old people who keeps plastic cover on their sofas. But… Well. After hearing how Apple and the phone companies treat warranties on these things, I’m keeping it on for at least a year!

I’ve been using an old and modified version of Twitter Tools on my blog to import my tweets. They are imported as blog posts and then viewed on the Lifestream sidebar. I had to modify it cause the version I downloaded had a bug and a missing feature. It included @-replies, even though I told it in the settings not to. And I wanted to be able to exclude all twitter posts in the feed for any RSS subscribers.
A couple of days ago the old version of Twitter Tools stopped working though. It was missing oAuth. I downloaded the latest version and the bug had been fixed, it ignored @-reply like it where suppose to, but I still couldn’t remove the posts from the feed. (Which I had forgotten all about when my girlfriend asked me why all my tweets where appearing in her NetNewsWire all of a sudden).
This time thought, instead of hacking the plugin to fix my feature, I’ve created a small plugin extension. If you also uses Twitter Tools and wishes to exclude the twitter posts in your feed, you can check it out here or go straight to the download page.
It was time for me to replace Vader (my black, big, loud breathing, evil Windows, PC). So I bought myself an iMac 27″ Core i7 2,93 GHz. Anakin is here. And he is a thing of beauty.
Most games I play these days are available for Mac. Which is good. But I recently bought Monkey Island™ 2 Special Edition: LeChuck’s Revenge™ on Steam, which is only available for Windows. So I started to install Boot Camp… Which was troublesome. Apparently the iMac and Windows 7 64bit isn’t compatible. Trying to install Boot Camp in Windows from the Snow Leopard DVD just gave me an error. I found out that I needed Boot Camp 3.1. Which can be downloaded from apple.com. However. To install 3.1 I first need 3.0. And we already know that 3.0 can’t be installed… Damn you Joseph Heller.
However. I found this guide which solved my Boot Camp installation issues. Cliffs:
Now my only issue is that I can’t use the native resolution of 2560 x 1440. It doesn’t recognize that it’s a 16:9 screen and is stuck on 1920 as max horizontal pixels. I’ll update if I find a fix for this …
Disclaimer: Sure, I could install Parallels, which I own … And I will … But I want both options. I want to be able to start Windows 7 inside OS X when I just need it to play easy going games or other stuff. Where I don’t need all the power. But I guess that Boot Camp will give Windows 7 better performance. So I want to have that option to.
Disclaimer 2: I’ve tried Apples display driver. Windows default drivers. And ATI Catalyst for Radeon HD, Mobility Radeon HD and their old Boot Camp specific drivers… The ATI Radeon HD 5750 in the iMac, apparently, in reality, is a Radeon HD Mobility 5850.
Update 2009-08-12 – Got a tip about which driver to download. Actually, I got two. Can’t get it working though. The drivers install fine. But I can’t access the catalyst settings. And it is still maxed out at 1920×1440. It runs fine in Parallels though. But if I switch between Boot Camp and Parallels I need to re-activate Windows. Which might make it sad and lock me out. Rumors has it Ultimate does not require this. I might upgrade. But for the time being I will stay in Parallels. Only need Windows for Monkey Island at the moment anyway. (And my girlfriend need it for poker).
Ordered a custom Gelaskin, designed by Smäm, for my iPad. It looks perfect! Now I don’t need to keep TheBrad in a case all the time for fear of scratches on the back!

So I got myself an iPad and I must say I like it. I still miss some Swedish characters on the keyboard. And iOS4 would be nice. But that will come. It would be nice if I didn’t have to jailbreak any of my devices to share my 3G connection from the iPhone. But I know that isn’t going to happend any time soon.
One thing I really don’t like though is some app developers separation of iPhone and iPad. I understand that some games are different on the two devices. It’s still kind off cheap but I’m ok with buying an excellent game like Plants vs. Zomies twice. I played it on my iPhone and it was such a fun ride I was more then ok with spending money on it again for the HD experience. I didn’t buy Angry Birds on the iPhone. But I did on the iPad. But when an app just changes the layout in the iPad version I’m a bit annoyed.
I got Net News Wire on the iPhone. Bought it again on the iPad. I really like Beejive on my phone and even though I spent over 100 SEK on it for the phone I bought it again for 75 SEK for my new device. But I’m not happy about it. But I use these softwares alot so. Ok. I can let it go. Somewhere I draw my line though. When Weather PRO want my money again I have to say now. It’s a really good weather app and I use it quiet alot on the phone. But I’m not buying it again just to get a new layout. Nooo sir. Not having it. That’s just wrong.
I wish more devs where like Twitterific. The new app is an universal app. It’s the same app you install on both devices. And if I upgrade to the ad free, which is an in app purchase, on one device. I can upgrade for free on the other. Kudos. You’re still a bit ‘effed if you bought the old version of the app though. But I’m ok with paying for new major upgrades. Like from Leopard to Snow Leopard.
I understand that devs have to get payed. And changing apps from one device to another can’t be done without the devs. But. No. I’m not having it. I don’t like it. So some apps will have to stay iPhoney on my iPad. And we can just hope that this won’t streach to iPhone pre 4 vs. iPhone 4. Non retina vs. retina. But I guess we would have seen it already. So. I guess my iWhine can stop. For now.
Still loving the iPad though.
- Sent from my iPad.
I heard that WordPress, for some reason, removes the ability to change the ping sites through the Update Services form under Settings > Writing in the admin area. I dug around a bit, I asked a WordPress developer and I found out that you can add a filter to get it back. It was westi who showed me the way. And said:
@westi: @DMRsweden The best thing to do is to use the add_filter but with priority 11 that way it will run after the default filter and win
So basically this is all the plugin needs to do:
add_filter(‘enable_update_services_configuration’, ‘__return_true’, 11);
But you can check for yourself. Download it here.
Update: It was brought to my attention that the plugin didn’t work as expected. The Update Services form was shown, but the data was never saved. Obviously I thought that I had tested it. But I worked on two different solutions and rather quickly… I guess I worked to quickly. :) Anyway, I found out that I needed a second filter, whitelist_options, to add the ping_sites form to the whitelist when saving the form data.
Now I only need a confirmation on that all the sites you add actually gets pinged to … Check out the source code here.
Update 2: @jonasbjork have reported that it seams to work. :)
I tried to explain the concept of Fredagsmys for my new, english, friend Mark (Mr. Panini).