Okay, this is driving me nuts.
I have a VERY simple plugin that I use to coerce the siteurl into a local one for local testing.
However, when I register the filters to change the URI, nothing happens.
If I add the_content, with the same function, it works, but get_option_siteurl and pre_option_siteurl do not work.
Below is the entire text of the plugin (I said it was simple). Any idea why these filters don't seem to be getting registered?
<?php
/*
Plugin Name: test_localhosts
Plugin URI: http://example.com/
Description: Makes things local, for testing.
Version: 1.0
Author: Example
Author URI: http://www.example.com
*/
function test_localhosts( $ret )
{
if ( preg_match ( '|10\.211\.55\.2|', $_SERVER['SERVER_ADDR'] ) )
{
$ret = "http://10.211.55.2/~cmarshall/example.com/public_html/main";
}
elseif ( preg_match ( '|127\.0\.0\.1|', $_SERVER['SERVER_ADDR'] ) || preg_match ( '|localhost|', $_SERVER['REQUEST_URI'] ) )
{
$ret = "http://localhost/~cmarshall/example.com/public_html/main";
}
return $ret;
}
add_filter ( 'pre_option_url', 'test_localhosts' );
add_filter ( 'pre_option_home', 'test_localhosts' );
add_filter ( 'pre_option_siteurl', 'test_localhosts' );
?>