Fixing JavaScript Affiliate Links in Wordpress 2.1.1

Wordpress 2.1.1 was released yesterday so I took the time to upgrade my blogs to this latest version. Some of my sites were running 2.0.7, so I figured now was a good a time as any to get to the 2.1 release.

All was good, however, until I found out that any links created by JavaScript that were embedded inside of Wordpress posts or pages were creating a nasty spacing issue.

At some point between Wordpress 2.0.7 and 2.1.1 the developers decided it was a good idea to add the SCRIPT tag as an element that should get some extra spacing to make sure it looks good.

I’m fine with that, I guess, but there’s one major problem I have with this: some Commission Junction (CJ.com) affiliates require that links be JavaScript instead of normal A tags. As such, when you try to use these links in the flow of a Wordpress post or page with Wordpress 2.1.1 you get undesired spacing above and below the link.

As you can imagine this doesn’t flow well inside of the post or page, but thankfully there’s an easy way to fix the problem.

To fix this problem you’ll need to edit wp-includes/formatting.php. Go to line 59 and remove ‘|script’ from the $allblocks variable. Each of the items in this variable is delimited by a ‘|’ (pipe), so make sure you remove one of those along with the word ’script’.

Thankfully this is an easy thing to fix, but it’ll be a change you’ll have to do whenever you upgrade Wordpress in the future.

Tags: , , , , , , ,

If you enjoyed this post, get free updates by email or RSS.

Checkout These Related Posts

  • Shortening (Affiliate) Links For Prettier Linking
  • Taking Advantage of the NOSCRIPT tag when using AdSense (or other) Ads
  • Fixing the Tab Index with Brian’s Threaded Comments
  • Building SAJAX Applications with Wordpress
  • How To Work Around the Transparent PNG Issue with IE
  • 4 Comments so far »

    1. used tires said

      on January 16 2010 @ 5:15 am

      Wow its fun looking to a 2007 post, and now here we are in early 2010 and we are at wordpress 2.9.1 =D

      Till then,

      Jean

    2. Evden eve nakliye said

      on January 17 2010 @ 9:31 am

      So now We are using Wp 2.9.1 its funny to see wp 2.1.1 js.

    3. Comment RSS · TrackBack URI

    Leave a comment

    Name: (Required)

    eMail: (Required)

    Website:

    Comment:

    Pingbacks/Trackbacks

    1. Pingback on February 23 2007 @ 6:31 pm

    2. Pingback on March 1 2007 @ 11:10 am