ok, it took me a while but in the end (with the help of user tbuteler) I found the problem.
Here's the code:
$url = 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'; // the URL to check against
$test_url = @fopen($url,'r'); // test parameters
if( $test_url !== false ) { // test if the URL exists
function load_external_jQuery() { // load external file
wp_deregister_script( 'jquery' ); // deregisters the default WordPress jQuery
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'); // register the external file
wp_enqueue_script('jquery'); // enqueue the external file
wp_register_script('jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js'); // register the external file
wp_enqueue_script('jquery-ui'); // enqueue the external file
}
add_action('wp_enqueue_scripts', 'load_external_jQuery'); // initiate the function
} else {
function load_local_jQuery() {
wp_deregister_script('jquery'); // initiate the function
wp_register_script('jquery', get_template_directory_uri() .'/javascripts/jquery.min.js', __FILE__, false, '1.7.2', true); // register the local file
wp_enqueue_script('jquery'); // enqueue the local file
wp_register_script('jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js'); // register the external file
wp_enqueue_script('jquery-ui'); // enqueue the external file
}
add_action('wp_enqueue_scripts', 'load_local_jQuery'); // initiate the function
}
In the "else" part of the code there is a call to bloginfo('template_url). The idea would be to return the path with the theme directory, but bloginfo() seems to echo that path, so it appears on the page. I changed it with this:
wp_register_script('jquery', get_template_directory_uri() .'/javascripts/jquery.min.js', __FILE__, false, '1.7.2', true); // register the local file
So now it's working. The other problem is that the it shouldn't enter the "else" part, since it should just use the google url, but it seems that some setting on the server is making the call to fopen() to fail.
functions.php. Is there a smart way to debug this file? I have no clue, since in the other environments everything seems just fine, for example: test environment – Carlo Oct 12 '12 at 16:13