• Resolved sushi_nut

    (@sushi_nut)


    Greetings all.

    Tried to upgrade to 3.6 from 3.5.2 this morning and received errors about a function not existing or being invalid:

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function '_show_post_preview' not found or invalid function name in /home/USER/.../wp-includes/plugin.php on line 406
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/develop/macrumors-web-admin/wp-includes/plugin.php:406) in /home/USER/.../wp-includes/pluggable.php on line 875

    Sure enough, it doesn’t exist in 3.6. Along with that, here are some others that were found after manually adding _show_post_preview:

    /**
     * Retrieve the format slug for a post
     *
     * @since 3.1.0
     *
     * @param int|object $post A post
     *
     * @return mixed The format if successful. False if no format is set. WP_Error if errors.
     */
    function get_post_format( $post = null ) {
            $post = get_post($post);
    
            if ( ! post_type_supports( $post->post_type, 'post-formats' ) )
                    return false;
    
            $_format = get_the_terms( $post->ID, 'post_format' );
    
            if ( empty( $_format ) )
                    return false;
    
            $format = array_shift( $_format );
    
            return ( str_replace('post-format-', '', $format->slug ) );
    }
    
    function _show_post_preview() {
    
            if ( isset($_GET['preview_id']) && isset($_GET['preview_nonce']) ) {
                    $id = (int) $_GET['preview_id'];
    
                    if ( false == wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . $id ) )
                            wp_die( __('You do not have permission to preview drafts.') );
    
                    add_filter('the_preview', '_set_preview');
            }
    }
    
    /**
     * Determines if the specified post is a revision.
     *
     * @package WordPress
     * @subpackage Post_Revisions
     * @since 2.6.0
     *
     * @param int|object $post Post ID or post object.
     * @return bool|int False if not a revision, ID of revision's parent otherwise.
     */
    function wp_is_post_revision( $post ) {
            if ( !$post = wp_get_post_revision( $post ) )
                    return false;
            return (int) $post->post_parent;
    }
    
    /**
     * Gets a post revision.
     *
     * @package WordPress
     * @subpackage Post_Revisions
     * @since 2.6.0
     *
     * @uses get_post()
     *
     * @param int|object $post Post ID or post object
     * @param string $output Optional. OBJECT, ARRAY_A, or ARRAY_N.
     * @param string $filter Optional sanitation filter. @see sanitize_post()
     * @return mixed Null if error or post object if success
     */
    function wp_get_post_revision(&$post, $output = OBJECT, $filter = 'raw') {
            $null = null;
            if ( !$revision = get_post( $post, OBJECT, $filter ) )
                    return $revision;
            if ( 'revision' !== $revision->post_type )
                    return $null;
    
            if ( $output == OBJECT ) {
                    return $revision;
            } elseif ( $output == ARRAY_A ) {
                    $_revision = get_object_vars($revision);
                    return $_revision;
            } elseif ( $output == ARRAY_N ) {
                    $_revision = array_values(get_object_vars($revision));
                    return $_revision;
            }
    
            return $revision;
    }
    
    /**
     * Retrieve the autosaved data of the specified post.
     *
     * Returns a post object containing the information that was autosaved for the
     * specified post.
     *
     * @package WordPress
     * @subpackage Post_Revisions
     * @since 2.6.0
     *
     * @param int $post_id The post ID.
     * @return object|bool The autosaved data or false on failure or when no autosave exists.
     */
    function wp_get_post_autosave( $post_id ) {
    
            if ( !$post = get_post( $post_id ) )
                    return false;
    
            $q = array(
                    'name' => "{$post->ID}-autosave",
                    'post_parent' => $post->ID,
                    'post_type' => 'revision',
                    'post_status' => 'inherit'
            );
    
            // Use WP_Query so that the result gets cached
            $autosave_query = new WP_Query;
    
            add_action( 'parse_query', '_wp_get_post_autosave_hack' );
            $autosave = $autosave_query->query( $q );
            remove_action( 'parse_query', '_wp_get_post_autosave_hack' );
    
            if ( $autosave && is_array($autosave) && is_object($autosave[0]) )
                    return $autosave[0];
    
            return false;
    }
    
    /**
     * Internally used to hack WP_Query into submission.
     *
     * @package WordPress
     * @subpackage Post_Revisions
     * @since 2.6.0
     *
     * @param object $query WP_Query object
     */
    function _wp_get_post_autosave_hack( $query ) {
            $query->is_single = false;
    }
    
    /**
     * Returns all revisions of specified post.
     *
     * @package WordPress
     * @subpackage Post_Revisions
     * @since 2.6.0
     *
     * @uses get_children()
     *
     * @param int|object $post_id Post ID or post object
     * @return array empty if no revisions
     */
    function wp_get_post_revisions( $post_id = 0, $args = null ) {
            if ( ! WP_POST_REVISIONS )
                    return array();
            if ( ( !$post = get_post( $post_id ) ) || empty( $post->ID ) )
                    return array();
    
            $defaults = array( 'order' => 'DESC', 'orderby' => 'date' );
            $args = wp_parse_args( $args, $defaults );
            $args = array_merge( $args, array( 'post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit' ) );
    
            if ( !$revisions = get_children( $args ) )
                    return array();
            return $revisions;
    }

    Is anyone else having these errors? Some of these were found in revision.php but not all. Not a very graceful upgrade.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Try:
    – switching to the default theme by renaming your current theme’s folder inside wp-content/themes and adding “-old” to the end of the folder name using FTP or whatever file management application your host provides.

    resetting the plugins folder by FTP or phpMyAdmin.

    – re-uploading all files & folders – except the wp-content folder – from a fresh download of WordPress. Make sure that you delete the old copies of files & folder before uploading the new ones.

    – running the upgrade manually via wp-admin/upgrade.php

    Thread Starter sushi_nut

    (@sushi_nut)

    esmi,

    Greatly appreciate the help; upgrade was finally successful.

    Excellent ??

    so which one options worked for you?

    Hi,

    I am also facing the same problem. However, want to know which options does it worked for you? Same as Sagbee’s question.

    Up to this time, still could not figure how to solve the issues.

    Thanks.

    Similar problems for me after the update to 3.6, I had a page-template.php error so I:

    – re-uploading all files & folders – except the wp-content folder – from a fresh download of WordPress, making sure to say override all existing files

    and that fixed it.

    Hi, the problem has been fixed already by re-uploading WordPress files. This forum is so helpful.

    Thank you esmi, much obliged.

    Identical issue solved by:

    * database upgrade with wp-admin/upgrade.php
    * then uploading all folders manually, except wp-content

    Very helpful thread.

    I had a very similar error message…
    “call_user_func_array() expects parameter 1 to be a valid callback, function ‘false’ not found or invalid function name in…”
    …showing at the top of my page.

    I fixed it by changing this line in my functions.php file…
    add_filter('show_admin_bar', 'false');
    …to…
    add_filter( 'show_admin_bar', '__return_false' );

    I ran into this same problem and followed the recommendations by esmi. This was after I had already updated to the latest WP version, and the site was still working. I thought it may have been due to a plugin I was working on. But I’m just learning how to work with the entire WP plugin architecture. So my database was up-to-date.

    However, the first point:

    – switching to the default theme by renaming your current theme’s folder inside wp-content/themes and adding “-old” to the end of the folder name using FTP or whatever file management application your host provides.

    … doesn’t cause WP to automatically revert to the default theme. It didn’t for me, in any case.

    After applying all of the suggested steps, the error went away but the site was totally blank. So, I removed the “-old” suffix on my theme folder, and voila! the site is fixed.

    I am not a master WP engineer, and I appreciate the suggestions esmi. Awesome stuff.

    I really really need someones help. I have these two warnings:

    Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘_show_post_preview’ not found or invalid function name in /home/askwarok1/amandaskwarok.com/wp-includes/plugin.php on line 406

    Warning: Cannot modify header information – headers already sent by (output started at /home/askwarok1/amandaskwarok.com/wp-includes/plugin.php:406) in /home/askwarok1/amandaskwarok.com/wp-includes/pluggable.php on line 874

    My hosting site automatically upgraded me to php5 and this is what happened.

    I have already tired:

    -everything listed by esmi’s advice.
    -I tried reverting back to the old php 5.2
    -I updated and reloaded the new wordpress files (includes and admin)
    -I deleted and reuploaded wp-login.
    -I deactivated my plugins content-plugins
    -renamed theme to -old

    I feel like I really tried but to no avail…
    I’m a freelance designer so you can imagine how stressful this is as this is my job…

    If anyone could help me I would be so so greatfull! ??

    If you require assistance then, as per the Forum Welcome, please post your own topic instead of tagging onto someone else’s topic.

    I am now closing this 10 month old topic as it references very old version of WordPress.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘3.6 Missing functions’ is closed to new replies.