[wp-hackers] Wordpress in Multiple Environments

Helen Hou-Sandi helen.y.hou at gmail.com
Wed Jan 19 15:28:41 UTC 2011


On Sun, Jan 16, 2011 at 8:07 PM, Andrew Nacin <wp at andrewnacin.com> wrote:

>
> The simplest solution is to run an output buffer in staging that rewrites
> any live links. Works extremely well and doesn't put any additional burden
> onto the production site. It also helps in a number of other areas outside
> the media library. You might want to conditionally filter the uploads stuff
> anyway the same way you're filtering home and siteurl.
>
> It could literally be as simple as this in wp-config.php:
>
> ob_start( 'mysite_staging_links' );
> function mysite_staging_links( $content ) {
>   return str_replace( 'http://mysite.com/', 'http://staging.mysite.com',
> $content );
> }


We are doing this on our dev server (going to root relative paths instead),
but replacing everything messed with the Dashboard and breaks things like
the TinyMCE editor (using !is_admin() didn't work, I guess because it's way
too early for that). I found that doing a str_replace on href="
http://mysite.com/ and src="http://mysite.com/ (and also the single quote
versions) instead worked fine, at least as far as I've discovered so far.

--
Helen Hou-Sandi


More information about the wp-hackers mailing list