SIDEBAR
»
S
I
D
E
B
A
R
«
Arras Theme with WPMU
September 7th, 2009 by Andrew Chlup

****No longer works in WP 3.0****

So I had a teacher who really wanted to use the Arras theme with their class. Unfortunately, it didn’t play nicely with WPMU.

I tinkered for a couple of hours and I think that I have a semi-workable solution.

Basically, I did two things:

  1. I added the necessary WP includes so that you can use all of the regular WPMU functions.
  2. I added some logic that made it work with a multiple blog setup.

***I am not a programmer by trade, so there may be major mistakes in my logic. Hopefully this will help you get started. ***

First, I added the WPMU includes to the top of the /library/timthumb.php

[code]
include('../../../../wp-blog-header.php');
include('../../../../wp-includes/general-template.php');
[/code]

This made it possible to use regular WPMU function calls.

Next, I went down to line 520 and added some code to the function using WPMU functions.

[code]
/**
* tidy up the image source url
*/
function cleanSource($src) {
//Added Globals for functions
global $current_blog, $current_site;

// remove slash from start of string
if(strpos($src, "/") == 0) {
$src = substr($src, -(strlen($src) - 1));
}

// remove http/ https/ ftp
$src = preg_replace("/^((ht|f)tp(s|):\/\/)/i", "", $src);
// remove domain name from the source url
//Changed path logic
$path = $current_blog->path;
$path = str_replace("/", "", $path);
$host = $_SERVER["HTTP_HOST"]. '/'. $path ;

$src = str_replace($host, "", $src);

//Added blogs.dir logic
$src = str_replace("/files/", "blogs.dir/". $current_blog->blog_id . "/files/", $src);
$host = str_replace("www.", "", $host);
$src = str_replace($host, "", $src);

// don't allow users the ability to use '../'
// in order to gain access to files below document root

// src should be specified relative to document root like:
// src=images/img.jpg or src=/images/img.jpg
// not like:
// src=../images/img.jpg
$src = preg_replace("/\.\.+\//", "", $src);

//print_r($_SERVER);

// get path to image on file system. Changed from original.
$src = $_SERVER['DOCUMENT_ROOT'] . '/wp-content/'. $src;

return $src;

// get path to image on file system. Appended 10/4
if ($current_blog->blog_id == 1) {
$src = $_SERVER['DOCUMENT_ROOT'] . '/wp-content/blogs.dir/1/'. $src;

return $src;

}else{

$src = $_SERVER['DOCUMENT_ROOT'] . '/wp-content/'. $src;

return $src;
}

}

[/code]

It worked for me and hopefully it will work for you. Here is the php timthumb that I used.

timthumb.php

Updated 10/4 – timthumb.php


3 Responses  
  • Mattew writes:
    October 3rd, 20097:13 amat

    Hi,
    Thank you for provided solution, but it doesn’t work for me :(
    I use WPMU 2.8.4a on Nginx, but also tried on Apache – no results.

    Any help would be tremendously appreciated.

    • Andrew Chlup writes:
      October 4th, 20098:36 pmat

      Hi Mattew,

      It was my mistake. I never had the demo site using Arras for the home site. The if then at the bottom seems to fix it and allow anybody else in your WPMU site use it.

      Andy :)

  • rj writes:
    July 1st, 20106:29 pmat

    Nice work. Have you used it with WP3 and multisite? I have tried and unfortunately, no bueno :o ( – Thx. ./rj


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
»  Substance:WordPress   »  Style:Ahren Ahimsa