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

Bryan Petty bpetty at bluehost.com
Fri Jul 6 21:47:13 UTC 2012


On 07/06/2012 03:23 PM, Otto wrote:
> ob_start('my_callback');
> 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
> all.
> 
> 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?

It's not hard, but it's a "hack" to a bug that needs to be fixed in
core. I can do this, and right now, that's fine, but I absolutely *have*
to do this to get this to work right, and it's one more thing I have to
do with every WordPress site I work on, but I shouldn't have to at all.

No-one is saying this doesn't work. It's just not the ideal solution to
the problem.

> 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.

Not if it doesn't break anything or hurt anyone to do it (and it
wouldn't). This would save a whole bunch of people a lot of headaches
and support time, as responses to this thread have already proven.

You're right, it should be avoided, and is a very infrequent
circumstance, but it still happens.

-- 
Bryan Petty
WordPress Developer
bpetty at bluehost.com




More information about the wp-hackers mailing list