WordPress.org

Ready to get started?Download WordPress

Forums

Fatal error: Call to undefined function wp_unslash() (7 posts)

  1. MadAxeman84
    Member
    Posted 7 months ago #

    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

  2. f1ss1on
    Member
    Posted 7 months ago #

    You have an error in your functions.php file on line 1263, Can you post the line 1260 - 1266 here?

  3. MadAxeman84
    Member
    Posted 7 months ago #

    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;
    }
  4. Dave Naylor
    Member
    Posted 7 months ago #

    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.

  5. f1ss1on
    Member
    Posted 7 months ago #

    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.

  6. MadAxeman84
    Member
    Posted 7 months ago #

    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;
    }
  7. MadAxeman84
    Member
    Posted 7 months ago #

    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

Reply

You must log in to post.

About this Topic