Integrating bit.ly with WordPress 3.0 Shortlinks Support

2 Jul

The official release of WordPress 3.0 being a bit recent, I’ve had a hell of a time trying to find bit.ly plugin that supports WordPress 3.0. The idea is to get your bit.ly short URL instead of the WordPress 3.0 short URL that uses your own domain name when you press the “Get Shortlink” button of a post editor.

bit.ly support in WordPress 3.0

I found the “WP Bit.ly” plugin which looks pretty good but does not yet support WordPress 3.0.

So what does an unsatisfied geek do on a Friday evening instead of having dinner? He finds a solution.

1. Download the WP Bit.ly plugin

2. Fix the plugin code

In file wp.bitly.php, put lines 47-48 in comment:

/*add_action( 'wp',      'wpbitly_shortlink_header' );
add_action( 'wp_head', 'wpbitly_shortlink_wp_head' ); */

If you too are a geek and you need to know, this will make sure WordPress 3.0 continues to take care itself of the HTML response header and the Web page HTML header as per the rel=”shortlink” proposed standard. Otherwise, the WP Bit.ly plugin would add these twice to a page which wouldn’t be clean.

3. Modify your theme’s function.php

Add the following code to your theme’s functions.php file:

/* bit.ly shortlink */

function get_bitly_shortlink($shortlink, $id, $context, $allow_slugs) {
   if (function_exists('wpbitly_get_shortlink')) {
      $slink = wpbitly_get_shortlink($id);
      if (empty($slink)) {
         wpbitly_generate_shortlink($id);
         $slink = wpbitly_get_shortlink($id);
         }
      return !empty($slink) ? $slink : $shortlink;
      }
   return $shortlink;
}
add_filter( 'get_shortlink', 'get_bitly_shortlink',10,4);

This code links the plugin code to the new WP 3.0 shortlink feature. It also makes sure that WordPress 3.0 will continue to operate as before if you do not enable the WP bit.ly plugin or you disable it.

Generate the bit.ly links from the plugin

So that the “Get Shortlink” button gets you a bit.ly link (instead of the default permalink), these should be generated once from the plugin’s settings. For new posts new bit.ly links should be created automatically.

Be aware that visits and crawls to your site will generate bit.ly links for each visited posts if no link already existed for each visited post. This is due to the fact that the short links are included in the code of each of your page to support new standards.

Fix for Facebook URL Linter / Open Graph Protocol Bug with WordPress 3.0

2 Jul

I’ve been helping At Home with Kim Vallee support the Open Graph Protocol promoted by Facebook. It’s easy to implement and great research that we’ll be adding immediately to Shwowp. If you want to learn a bit more why it’s important for your site to implement the Open Graph Protocol, read this article: “Facebook Unleashes Open Graph Search Engine, Declares War On Google”.

URL Linter is a handy Facebook Developer tool that allows you to analyze a Web page meta data to see how Facebook understands it.

The problem is that URL Linter was working for the home page but not for the article pages. After much lost sleep and a call for help on Facebook Developer Forums, Paul from Facebook confirmed it was a bug:

  • WordPress 3.0 added a shortlink feature
  • If you changed your WordPress permalinks to friendly names instead of the default, it adds an HTTP header variable in the form
    • Link    <http://domain.com/?p=12345>; rel=shortlink
    • This new header variable is part of a proposed microformat standard.
    • The Facebook URL Linter and crawler currently has trouble parsing the page when it sees this HTTP header

The Fix

The bug should be fixed by Facebook in about a week. In the meanwhile, if you run WordPress 3.0 and are implementing Open Graph Protocol support to your site, you can add the following code in your theme’s functions.php to disable the shortlink in the HTTP header output:


/* Remove WP 3.0 shortlink */
function empty_shortlink($shortlink, $id, $context, $allow_slugs) {
return NULL;
}
add_filter( 'get_shortlink', 'empty_shortlink',10,4);

Twitter allows to follow Facebook friends, Facebook blocks feature

23 Jun

In their recent Mashable article, HUGE: Twitter Lets You Automatically Follow Your Facebook Friends, we learn that we can now use Twitter’s Facebook Application to find friends to follow in Twitter.

It looks like it was short lived because minutes after this article was published, it seems that Facebook blocked that capability:

Really wondering what game is being played right now! The Twitter Facebook app allow you (as an option) to publish your tweets to Facebook and it now seems that you can’t find new friends through Facebook so you can follow them on Twitter (and optionally post back to Facebook!). Strange!

Facebook was really quick in blocking Twitter and I’m wondering which Term of Service Facebook thinks Twitter did not respect.

UPDATE: on Techcrunch, there’s now an update article from MG Siegler which says this might be an issue on Facebook’s end. Maybe a coding error or, more probable: a) an API problem on Facebook’s end or b) Facebook really blocked Twitter.

UPDATE 2: it seems it is not intentional. Facebook is working with Twitter to solve the problem.

How to fix the WordPress plugin WP-SpamFree to avoid the “Your location has been identified as part of a reported spam network” error

11 Mar

My wife Kim is the successful editor behind At Home with Kim Vallee. She uses the WordPress platform.

With success and a popular platform, problems with comment and contact form spam becomes quickly a pain to manage. That’s why you need a good toolset to keep your sanity intact. Good WordPress plugins to protect against spamming and keep your installation secure include:

  • Akismet – protects against spam
  • Login LockDown – adds extra security to your login form
  • WP Security Scan – security
  • WP-SpamFree – extra spam protection

WP-SpamFree is quite invaluable against robots and contact form spam. However, it came to our attention that some people would see the following message instead of the contact form:

Your location has been identified as part of a reported spam network. Contact form has been disabled to prevent spam.

See the message when it would appear instead of Kim’s contact form:

image

This was really annoying. People were telling Kim they couldn’t send comments.

By chance, one PC at our office had this bug. The unique IP address assigned to our network by Videotron seemed clean. So I dug further and looked at the plugin code to understand and debug what’s happening. It seems some browsers in some configurations (in our case a particular Firefox installation on Windows XP) do not transmit the HTTP_ACCEPT_LANGUAGE variable to servers. There is a check in the WP-SpamFree plugin that identifies the visitor as a spammer if this variable is empty.

Once the problem identified, the fix is easy: simply disable this verification. The quick fix to the plugin is to modify the wp-spamfree.php file in the plugin directory to put this condition in comment. See my changes in red:

/*
            $user_http_accept_language = trim($_SERVER['HTTP_ACCEPT_LANGUAGE']);
            if ( !$user_http_accept_language ) {
                $contact_form_blacklist_status = ’2′;
                $spamfree_error_code .= ‘ CF-HAL1001′;
                }
*/
            // Add blacklist check – IP’s only though.

            if ( $contact_form_blacklist_status ) {
                $spamfree_contact_form_content = ‘<strong>Your location has been identified as part of a reported spam network. Contact form has been disabled to prevent spam.</strong>’;
                }
            $content_new = str_replace(‘<!–spamfree-contact–>’, $spamfree_contact_form_content, $content);

That’s it. No more false positives for Kim’s visitors!

I’ll send this issues to the WP-SpamFree devs.

The iPad: The Emperor says you shall pass through our gates – Mac App Store next?

28 Jan

Yesterday Steve Jobs announced his latest creation, the Apple iPad.Bite_me_in_the_rain_by_sherryetal

The Emperor has spoken and it’s very telling. Apple’s present and future is no longer about a fine-tuned combination of hardware and software. It’s also about being the content gatekeeper.

The announcement

We finally know what kind of tablet computer the Apple folks were cooking! Basically, it’s a blend of an oversized iPod Touch and iPhone. At the same time, it’s really a computer; the chip looks much more powerful. It’s supposedly very fast. Like any first generation Apple product, it has a lot going for it while missing a few things. No real surprises except maybe the starting price and very surprised about seeing a touch version of iWorks.

What’s more telling about Steve’s strategy is the lack of support for Adobe Flash. Not that I am very fond of Flash, but it is very telling.

It’s all about control

It’s no secret Steve Jobs is a control freak. It has worked well for him. Since the first Apple computer, Apple has had an aversion for clones. Apple wants to control the whole experience starting from hardware. Forget about having an Orange, a Pear or a Peach. Like Eve, all you need is to get a bite out of the Apple and you’re hooked. (Their logo is really telling). By controlling hardware and software combined with their sense of design and controlled user experience they’ve been able to do what most tech giants still dream of.

But today, controlling the user experience is also all about controlling content distribution.

They’ve done a really good job with iTunes out of distributing songs for people to buy. Then, Apple added an App Store to iTunes to distribute and install software. It made sense: it is more user-friendly and practical. What a success it has been!

Now enters the iPad which uses exactly the same model than the iPhone or iPod Touch. To download and install and application you still need to go through the Apple store. Oh, and you can download books now.

The excuse for the lack of Flash support on the iPhone Safari browser was that it was using too much CPU. It would deter the user experience. It wasn’t a bad excuse. Heck! Flash is known to bring underpowered computers to a crawl. But that excuse doesn’t fly well with the iPad. Those who got to try the device were all raving on how fast it is with its new Apple designed chip.

I do not care that much about the lack of Flash on Web sites. It is usually more a pain than a gain.

On the other hand, Adobe is prepping Flash CS5 which allows to build iPod Touch, iPhone and iPad applications. Who needs Flash support? Adobe is building it in some way! Who needs Adobe Air support on the iPad computer? Here’s a solution!

The thing is these Flash applications will have to be distributed by the App Store and approved and censored by Apple. There is no other way to do it unless you want to break Apple’s terms of use.

That’s why I don’t see Flash being supported natively in the browser on the iPad or the iPhone. It would be a way for developers to distribute software in a Web page without going through the content distribution gatekeeper Apple has become. Do pass go, but we’ll charge a fee on your 200$!

What’s next?

Apple’s announcement of the iWorks software suite for the iPad was quite a surprise to me. Digesting this announcement means Apple does not see the iPad as just an oversized iPhone. It’s also a computer where you can get some sort of work done. With the new screen estate, I can see a lot of exciting business applications being built for this new toy. But again, all these will have to pass through the gatekeeper.

To conclude, I predict we will see App Store support for Mac applications in the near future. It would make perfect sense when you think of it. Users get to download everything in a single place. Invoices are easy to find. You are dealing with a single company you trust. Why download and install something from somewhere else? That’s really too hard and too risky!

I wouldn’t be surprised to someday see a new computer from Apple which will make everything even easier for the computer illiterate. It will support a mouse and keyboard when touch is not yet as efficient. You will be able to get some real work done with it. It will use a blend of the Mac OS and the iPad OS to offer a seamless experience from hardware to content consumption. We almost have this device with the iPad but it’s just a start. In a future near you, your Adobe PhotoShop or Microsoft Office installations for a Mac will probably be downloaded from Apple.

Image source: Bite me in the rain by *sherryetal

Update:

Some interesting articles popped-up on the subject after I wrote this: