Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've just pushed a wordpress website to the production host and on top appeared an URL which should not be there. Here's the link.

I checked the source code, but I can't find anything that can output that url and anyway on the localhost and testing environments that url does not appear.

Any idea what is generating it?

Here's the header.php file.

share|improve this question
Please paste your header.php. Something is going on there. – Miha Rekar Oct 12 '12 at 13:36
This doesn't seem solvable without hands-on debug. Please add more details or it will likely be closed as too localized. – Rarst Oct 12 '12 at 13:47
Ok, I added a link to the header.php file on pastebin – Carlo Oct 12 '12 at 14:31
1  
It's happening within the wp_head() function, which includes many hooks - it's not within header.php, but rather within functions.php or any other plug-in. First thing to do is deactivate all plugins: if it's still there, check functions.php, if not, enable one by one until the culprit is found, then check functions running within 'wp_head' action or related; likely a misplaced echo statement when trying to define a var? – tbuteler Oct 12 '12 at 14:40
@tbuteler, thanks for your answer. I deactivated all the plugins, but nothing, so I'm guessing the problem is to be searched inside 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
show 6 more comments

closed as too localized by Rarst Oct 15 '12 at 22:25

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

1 Answer

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.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.