Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Back in May, I recall seeing a post on the WordPress Development blog by Alex M ( where he added functionality for Automatic Ticket/Revision/Diff Linking which allows for linking to Trac tickets, Trac revisions, and Trac diff comparisons.

I am wanting to do the same thing with an internal WordPress blog and Trac that I have for my business. I haven't seen where this was released as a WordPress plugin so I was hoping that people could point me in the right direction on how to do this in how to do this integration between Trac and WordPress. Thanks.

share|improve this question

2 Answers 2

up vote 6 down vote accepted

Here's the source of the functionality. It's just a content filter and some basic regex that one of my coworkers at Automattic wrote.

add_filter( 'the_content', 'markup_wporg_links' );
add_filter( 'comment_text', 'markup_wporg_links' );

function markup_wporg_links( $content ) {
    $find = array(
        '/(\ |^)#(\d{3,6})(\b|$)/i', // core trac ticket #1234-core in
        '/(\ |^)r(\d{3,6})(\b|$)/i', // core changeset r1234-core in
        '/(\ |^)diff:@(\d{3,6}):(\d{3,6})(\b|$)/i', // core diff diff-core:@20:30

    $replace = array(
        '<a href="$2">$0</a>', // core trac ticket
        '<a href="$2">$0</a>', // core trac changeset
        '<a href="$3&old=$2">$0</a>', // core diff

    preg_match_all( '#[^>]+(?=<[^/]*[^a])|[^>]+$#', $content, $matches, PREG_SET_ORDER );

    foreach ( $matches as $val )
        $content = str_replace( $val[0], preg_replace( $find, $replace, $val[0] ), $content );

    return $content;

Modify it to suit your needs.

share|improve this answer
Thanks Alex, that is exactly what I was looking for. I greatly appreciate your help and providing the code for this. – ChristLuvsU2 Nov 1 '10 at 20:03

Also take a look at RTC (free for 10 users on it is the next big thing.

It automatically combines changing your stuff with the work items attached / diffs / with even your planning. It's the followup of Eclipse (which provided an open source framework).

IMHO the best thing out there currently

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.