Support » Fixing WordPress » Fatal error: Call to undefined function wp_unslash()

  • Hello. I have a problem with my wordpress page. When I’m trying to create new post I receive error: Fatal error: Call to undefined function wp_unslash() in /home/hotspotb/public_html/wp-includes/functions.php on line 1263
    Тhe left side options (files, links, settings etc) of wordpress are still there, but I’m unable to post something.
    When I’m trying to update the wordpress I receive the same error. There is no button “Update”. It is the same with plugins page.
    I did not installed new plugins. The last thing that I did was to create subdomain with another wordpress. On the subdomain everything is OK. I remove it, but the problem still persist.
    I try to update wordpress manually but there is no effect.
    Could you help me to solve this issue

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • You have an error in your functions.php file on line 1263, Can you post the line 1260 – 1266 here?

    Hello f1ss1on, thank you for your help.
    This is the code from lines 1260 – 1268

    * @return string Referer field.
     */
    function wp_referer_field( $echo = true ) {
    	$referer_field = '<input type="hidden" name="_wp_http_referer" value="'. esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />';
    
    	if ( $echo )
    		echo $referer_field;
    	return $referer_field;
    }

    wp_unslash() was introduced in WordPress 3.6.0. You appear to be running: WordPress 3.5.1.

    Time to start upgrading to prevent this sort of thing from happening again.

    WPRanger is right. To update, try to comment out the code

    function wp_referer_field( $echo = true ) {
    	$referer_field = '<input type="hidden" name="_wp_http_referer" value="'. esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />';
    
    	if ( $echo )
    		echo $referer_field;
    	return $referer_field;
    }

    That should allow you to upgrade.

    I made the comment of the code, but now I receive error in another line:
    Fatal error: Call to undefined function wp_referer_field() in /home/hotspotb/public_html/wp-includes/functions.php on line 1241
    The code of function is from line 1236 to 1247

    function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $echo = true ) {
    	$name = esc_attr( $name );
    	$nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />';
    
    	if ( $referer )
    		$nonce_field .= wp_referer_field( false );
    
    	if ( $echo )
    		echo $nonce_field;
    
    	return $nonce_field;
    }

    Hi again. Actually I find a way to fix the problem.
    I fix the error on line 1241 – just comment

    if ( $referer )
    		$nonce_field .= wp_referer_field( false );

    After that I was able to open update page, but when i click update button I receive error with the same file functions.php on line 1312.
    I comment the code on that line

    $ref = wp_unslash( $_SERVER['HTTP_REFERER'] );

    After that it was OK. Now it is successfully updated to version 3.8

    Thanks for the direction to solve the problem

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Fatal error: Call to undefined function wp_unslash()’ is closed to new replies.