Creating Clean Amazon Affiliate Links in WordPress

One way bloggers can earn incremental income is through affiliate marketing programs, among which Amazon’s is perhaps the most popular. Bloggers simply link to Amazon products, adding a special referral code, and they are given credit for the sales they generate.

Generating these tracking codes can be something of a pain. Amazon’s own utility is clumsy and offers up a long, clunky URL. Ragaskar’s WordPress plugin aims to fill the void by automatically appending tracking codes to Amazon links in posts, but this can still generate clunky links.

Based on Ragaskar’s plugin, I whipped up the following code:


    add_filter('the_content','filter_amazon_associate_filter');

    add_filter('comment_text','filter_amazon_associate_filter');

    

    function filter_amazon_associate_filter($content) {

        $affiliate_code="YOURCODEHERE";

    

        $content=preg_replace(

            '/http:\/\/[^>]*?amazon.([^\/]*)\/([^>]*?ASIN|gp\/product|exec\/obidos\/tg\/detail\/-|[^>]*?dp)\/([0-9a-zA-Z]{10})[a-zA-Z0-9#\/\*\-\?\&\%\=\,\._;]*/i',

            'http://www.amazon.$1/exec/obidos/ASIN/$3/'.$affiliate_code,

            $content

        );

        return $content;

    }

Very simply, this code scans through your posts and comments and replaces ugly Amazon links with somthing like http://www.amazon.com/exec/obidos/ASIN/B0048EJXCK/nathward-20.

To add this to your site, simply place the above code in your WordPress template’s functions.php file and replace YOURCODEHERE with your Amazon affiliate code.


LinkedIn’s April Fool’s Joke

LinkedIn's 2011 April Fool's Joke

Technology firms have often used April 1 as a chance to play pranks on their customers. Google, for example, is famous for these hoaxes, to the point that its 2004 launch of Gmail (on April 1) was originally viewed as a joke.

In a crowded field of 2011 pranks that includes elaborate videos and even browser extensions, LinkedIn’s prank is perhaps the subtlest and thus the funniest. They added historical figures and fictional characters to their “people you may know” tool, including Albert Einstein, Robin Hood (“Activist/​ Chief Fundraiser at Nottingham”) and J. R. R. Tolkien. Unfortunately, you can’t actually add these people to your network, but it’s a fun gesture nonetheless.

 


Wednesday Links: Unintended Consequences


Why the District of Columbia Lacks a Vote in Congress and How to Fix the Problem

Fifty years ago, the states ratified the 23rd Amendment to the Constitution, which allowed the District of Columbia to appoint electors for President as if it were a state. Yet while District residents may vote for President, they remain without representation in Congress.

Writing in the New York Times, Northwestern’s Kate Masur argues that race and partisanship are the principal reasons why the District lacks representation:

The 23rd Amendment is a reminder that support can be rallied for greater democracy for the district. And yet, in our polarized political climate, the powerful argument for voting representation in Congress seems perpetually stymied.

One problem is indifference; most Americans are unaware of the capital’s anomalous status, the city’s “Taxation Without Representation” license plates notwithstanding. A second is partisanship; to establish a vote in Congress for Washingtonians, who are overwhelmingly Democrats, Republicans would have to place a moral imperative ahead of partisan interests.

Another is race. A half-century after the dawn of the civil rights era, many Americans still have a hard time seeing African-Americans as citizens entitled to the rights that so many white people take for granted. For residents of a place once known as “Chocolate City,” these attitudes are a sadly familiar obstacle to equality.

Even if Masur is right that partisanship and race define the politics of granting representation to the District, Congress still has an obligation to uphold the Constitution. As Andrew Grossman and I explained two years ago, “Congress lacks the constitutional authority to grant the city a representative by legislation; the District of Columbia is not a state, and representation is limited to states alone.”

This is not to say there’s no moral case for representation. The District’s status violates the principle of consent of the governed.

Fortunately, there are solutions to this problem that do not violate the Constitution. For example, Grossman and I argued that

Congress could propose an amendment granting the District a representative in Congress, perhaps using the 1978 proposal noted earlier as a model. Adding such representation directly to the Constitution would by definition avoid running afoul of the nation’s supreme law. In addition, the amendment solution would retain the Founders’ intention that the capital city remain subject to the “exclusive legislation” of Congress–even as it grants the city’s residents a more direct voice in that legislation.

Another, less constitutionally problematic approach would resolve the “taxation without representation” complaint by eliminating federal taxes for the District.

No matter the solution, it’s important that it be consistent with the Constitution. Even a powerful moral grievance is no excuse for ignoring the nation’s highest law.


Monday Links: Creative Job Listings