[wp-hackers] absolute URLs in plug-ins and custom types

Otto otto at ottodestruct.com
Fri Jul 6 21:23:01 UTC 2012

On Fri, Jul 6, 2012 at 4:08 PM, Bryan Petty <bpetty at bluehost.com> wrote:
> First, at least one level of testing fundamentally includes testing
> against live data, not against the live database itself, but at least
> against a snapshot. I don't force authors to publish their posts on some
> development server, I'm talking about a snapshot, they still write their
> posts on the live server. But I still can't do that without this change.

function my_callback($out) {
    return str_replace('example.com', 'localhost.dev.whatever', $out);

Drop that or something similar to the top of your dev site's
wp-config.php file. No real need to change the URLs in the database at

See, I guess I'm just not getting the problem here. You're talking
about taking content from a live site, putting it on a local server
for testing, and that's fine. But in such a case, absolute URLs simply
aren't a big deal. A few snippets like the above on your dev site and
you can change the URLs being displayed without screwing around with
the database in any way whatsoever.

So you tell me, what am I missing? What is so hard about doing things
like the above code that makes this such a difficult process for you?

> Second, even if everything you said was true of everyone using WordPress
> (that they shouldn't be running live content on *any* server besides the
> live one, period... even though that's not true), we still need this
> change to simplify site domain/sub-folder migrations.

No argument, but moving sites around like this is something that
should be avoided in general, I'd think. Why would anybody ever change
their domain? It's an exceptional, and infrequent, circumstance. One
would hope. Changing the whole system for a very, very minority of a
case doesn't make a whole lot of sense.


More information about the wp-hackers mailing list