WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Missing functions at the end of functions.php (8 posts)

  1. stemar
    Member
    Posted 7 years ago #

    I upgraded from v2.0.3 to v2.0.4 this past week. I was no longer able to change themes. I was getting PHP warnings and fatal errors that were related to $_SERVER['HTTP_REFERER'] and a missing 'wp_get_referer()' function.

    I found out that some functions have been moved from 'functions.php' to 'functions-post.php'; however there are 4 missing functions that no longer show up towards the end of 'functions.php' and 1 incomplete function.

    The missing ones are:
    wp_referer_field
    wp_get_original_referer_field
    wp_get_referer
    wp_get_original_referer

    The incomplete one is:
    wp_nonce_field
    (this is the last function in 'functions.php')

    My setup is with Dreamhost. My WordPress v2.0.3 was working fine. I was able to get a copy of the above 5 functions from an earlier version of WordPress (don't know which one). I appended them to my 'functions.php'. Now my v2.0.4 works correctly but I haven't thoroughly tested the entire blog yet.

    Did anyone encounter similar problems? Can a WordPress guru check if the functions are in fact missing or if it's only my setup that's wrong?

    Would you mind posting the above 5 functions so I could have a current version of these?

  2. vkaryl
    Member
    Posted 7 years ago #

    Here's what's in my distro of 2.0.4:

    function wp_referer_field() {
    $ref = wp_specialchars($_SERVER['REQUEST_URI']);
    echo '<input type="hidden" name="_wp_http_referer" value="'. $ref . '" />';
    if ( wp_get_original_referer() ) {
    $original_ref = wp_specialchars(stripslashes(wp_get_original_referer()));
    echo '<input type="hidden" name="_wp_original_http_referer" value="'. $original_ref . '" />';
    }
    }

    function wp_original_referer_field() {
    echo '<input type="hidden" name="_wp_original_http_referer" value="' . wp_specialchars(stripslashes($_SERVER['REQUEST_URI'])) . '" />';
    }

    function wp_get_referer() {
    foreach ( array($_REQUEST['_wp_http_referer'], $_SERVER['HTTP_REFERER']) as $ref )
    if ( !empty($ref) )
    return $ref;
    return false;
    }

    function wp_get_original_referer() {
    if ( !empty($_REQUEST['_wp_original_http_referer']) )
    return $_REQUEST['_wp_original_http_referer'];
    return false;
    }

    function wp_nonce_field($action = -1) {
    echo '<input type="hidden" name="_wpnonce" value="' . wp_create_nonce($action) . '" />';
    wp_referer_field();
    }

    I haven't had any problems of that nature in over a dozen upgrades, plus about that many new installs.

    [The nonce field one isn't at all the last function. I think you should probably get a fresh distro downloaded and extracted, myself.]

  3. stemar
    Member
    Posted 7 years ago #

    Thank you very much for the code!
    A fresh distro download is a good idea.

  4. stemar
    Member
    Posted 7 years ago #

    I just downloaded a fresh distro and turns out I was missing more functions at the end of 'functions.php'.
    Thank you for your help.

  5. vkaryl
    Member
    Posted 7 years ago #

    Glad you got it sorted out....

  6. kalico
    Member
    Posted 7 years ago #

    I found this thread which answered part of the problem I am having. I have downloaded a new distro of 2.0.5 and got the function.php file, which now contains wp_nonce_field. HOWEVER.....my plugin now reports a different error message:

    Fatal error: Call to undefined function: wp_create_nonce() in /home/timeless/public_html/wp-includes/functions.php on line 2358

    wp_create_nonce is mentioned many times in functions.php, so I'm not sure what it's trying to do.....can anyone direct me how to resolve this? A search for wp_create_nonce turned up only two threads, neither gave me a solution and I am lost.

    Thanks in advance.

  7. Chris_K
    Member
    Posted 7 years ago #

    Goodness - 2.0.5 is old and unsafe. Why not consider updating to 2.0.10 or 2.1.3 and see if your problem persists?

  8. kalico
    Member
    Posted 7 years ago #

    Done and fixed. Thanks HandySolo.

Topic Closed

This topic has been closed to new replies.

About this Topic