_wp_post_revision_fields

The timeline below displays how wordpress function _wp_post_revision_fields has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Post revision functions.
 *
 * @package WordPress
 * @subpackage Post_Revisions
 */
/**
 * Determines which fields of posts are to be saved in revisions.
 *
 * @since 2.6.0
 * @since 4.5.0 A `WP_Post` object can now be passed to the `$post` parameter.
 * @since 4.5.0 The optional `$autosave` parameter was deprecated and renamed to `$deprecated`.
 * @access private
 *
 * @param array|WP_Post $post       Optional. A post array or a WP_Post object being processed
 *                                  for insertion as a post revision. Default empty array.
 * @param bool          $deprecated Not used.
 * @return string[] Array of fields that can be versioned.
 */
function _wp_post_revision_fields($post = array(), $deprecated = false)
{
    static $fields = null;
    if (!is_array($post)) {
        $post = get_post($post, ARRAY_A);
    }
    if (is_null($fields)) {
        // Allow these to be versioned.
        $fields = array('post_title' => __('Title'), 'post_content' => __('Content'), 'post_excerpt' => __('Excerpt'));
    }
    /**
     * Filters the list of fields saved in post revisions.
     *
     * Included by default: 'post_title', 'post_content' and 'post_excerpt'.
     *
     * Disallowed fields: 'ID', 'post_name', 'post_parent', 'post_date',
     * 'post_date_gmt', 'post_status', 'post_type', 'comment_count',
     * and 'post_author'.
     *
     * @since 2.6.0
     * @since 4.5.0 The `$post` parameter was added.
     *
     * @param string[] $fields List of fields to revision. Contains 'post_title',
     *                         'post_content', and 'post_excerpt' by default.
     * @param array    $post   A post array being processed for insertion as a post revision.
     */
    $fields = apply_filters('_wp_post_revision_fields', $fields, $post);
    // WP uses these internally either in versioning or elsewhere - they cannot be versioned.
    foreach (array('ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author') as $protect) {
        unset($fields[$protect]);
    }
    return $fields;
}

WordPress Version: 5.5

/**
 * Post revision functions.
 *
 * @package WordPress
 * @subpackage Post_Revisions
 */
/**
 * Determines which fields of posts are to be saved in revisions.
 *
 * @since 2.6.0
 * @since 4.5.0 A `WP_Post` object can now be passed to the `$post` parameter.
 * @since 4.5.0 The optional `$autosave` parameter was deprecated and renamed to `$deprecated`.
 * @access private
 *
 * @param array|WP_Post $post       Optional. A post array or a WP_Post object being processed
 *                                  for insertion as a post revision. Default empty array.
 * @param bool          $deprecated Not used.
 * @return array Array of fields that can be versioned.
 */
function _wp_post_revision_fields($post = array(), $deprecated = false)
{
    static $fields = null;
    if (!is_array($post)) {
        $post = get_post($post, ARRAY_A);
    }
    if (is_null($fields)) {
        // Allow these to be versioned.
        $fields = array('post_title' => __('Title'), 'post_content' => __('Content'), 'post_excerpt' => __('Excerpt'));
    }
    /**
     * Filters the list of fields saved in post revisions.
     *
     * Included by default: 'post_title', 'post_content' and 'post_excerpt'.
     *
     * Disallowed fields: 'ID', 'post_name', 'post_parent', 'post_date',
     * 'post_date_gmt', 'post_status', 'post_type', 'comment_count',
     * and 'post_author'.
     *
     * @since 2.6.0
     * @since 4.5.0 The `$post` parameter was added.
     *
     * @param array $fields List of fields to revision. Contains 'post_title',
     *                      'post_content', and 'post_excerpt' by default.
     * @param array $post   A post array being processed for insertion as a post revision.
     */
    $fields = apply_filters('_wp_post_revision_fields', $fields, $post);
    // WP uses these internally either in versioning or elsewhere - they cannot be versioned.
    foreach (array('ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author') as $protect) {
        unset($fields[$protect]);
    }
    return $fields;
}

WordPress Version: 5.4

/**
 * Post revision functions.
 *
 * @package WordPress
 * @subpackage Post_Revisions
 */
/**
 * Determines which fields of posts are to be saved in revisions.
 *
 * @since 2.6.0
 * @since 4.5.0 A `WP_Post` object can now be passed to the `$post` parameter.
 * @since 4.5.0 The optional `$autosave` parameter was deprecated and renamed to `$deprecated`.
 * @access private
 *
 * @staticvar array $fields
 *
 * @param array|WP_Post $post       Optional. A post array or a WP_Post object being processed
 *                                  for insertion as a post revision. Default empty array.
 * @param bool          $deprecated Not used.
 * @return array Array of fields that can be versioned.
 */
function _wp_post_revision_fields($post = array(), $deprecated = false)
{
    static $fields = null;
    if (!is_array($post)) {
        $post = get_post($post, ARRAY_A);
    }
    if (is_null($fields)) {
        // Allow these to be versioned.
        $fields = array('post_title' => __('Title'), 'post_content' => __('Content'), 'post_excerpt' => __('Excerpt'));
    }
    /**
     * Filters the list of fields saved in post revisions.
     *
     * Included by default: 'post_title', 'post_content' and 'post_excerpt'.
     *
     * Disallowed fields: 'ID', 'post_name', 'post_parent', 'post_date',
     * 'post_date_gmt', 'post_status', 'post_type', 'comment_count',
     * and 'post_author'.
     *
     * @since 2.6.0
     * @since 4.5.0 The `$post` parameter was added.
     *
     * @param array $fields List of fields to revision. Contains 'post_title',
     *                      'post_content', and 'post_excerpt' by default.
     * @param array $post   A post array being processed for insertion as a post revision.
     */
    $fields = apply_filters('_wp_post_revision_fields', $fields, $post);
    // WP uses these internally either in versioning or elsewhere - they cannot be versioned.
    foreach (array('ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author') as $protect) {
        unset($fields[$protect]);
    }
    return $fields;
}

WordPress Version: 4.6

/**
 * Post revision functions.
 *
 * @package WordPress
 * @subpackage Post_Revisions
 */
/**
 * Determines which fields of posts are to be saved in revisions.
 *
 * @since 2.6.0
 * @since 4.5.0 A `WP_Post` object can now be passed to the `$post` parameter.
 * @since 4.5.0 The optional `$autosave` parameter was deprecated and renamed to `$deprecated`.
 * @access private
 *
 * @staticvar array $fields
 *
 * @param array|WP_Post $post       Optional. A post array or a WP_Post object being processed
 *                                  for insertion as a post revision. Default empty array.
 * @param bool          $deprecated Not used.
 * @return array Array of fields that can be versioned.
 */
function _wp_post_revision_fields($post = array(), $deprecated = false)
{
    static $fields = null;
    if (!is_array($post)) {
        $post = get_post($post, ARRAY_A);
    }
    if (is_null($fields)) {
        // Allow these to be versioned
        $fields = array('post_title' => __('Title'), 'post_content' => __('Content'), 'post_excerpt' => __('Excerpt'));
    }
    /**
     * Filters the list of fields saved in post revisions.
     *
     * Included by default: 'post_title', 'post_content' and 'post_excerpt'.
     *
     * Disallowed fields: 'ID', 'post_name', 'post_parent', 'post_date',
     * 'post_date_gmt', 'post_status', 'post_type', 'comment_count',
     * and 'post_author'.
     *
     * @since 2.6.0
     * @since 4.5.0 The `$post` parameter was added.
     *
     * @param array $fields List of fields to revision. Contains 'post_title',
     *                      'post_content', and 'post_excerpt' by default.
     * @param array $post   A post array being processed for insertion as a post revision.
     */
    $fields = apply_filters('_wp_post_revision_fields', $fields, $post);
    // WP uses these internally either in versioning or elsewhere - they cannot be versioned
    foreach (array('ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author') as $protect) {
        unset($fields[$protect]);
    }
    return $fields;
}

WordPress Version: 4.5

/**
 * Post revision functions.
 *
 * @package WordPress
 * @subpackage Post_Revisions
 */
/**
 * Determines which fields of posts are to be saved in revisions.
 *
 * @since 2.6.0
 * @since 4.5.0 A `WP_Post` object can now be passed to the `$post` parameter.
 * @since 4.5.0 The optional `$autosave` parameter was deprecated and renamed to `$deprecated`.
 * @access private
 *
 * @staticvar array $fields
 *
 * @param array|WP_Post $post       Optional. A post array or a WP_Post object being processed
 *                                  for insertion as a post revision. Default empty array.
 * @param bool          $deprecated Not used.
 * @return array Array of fields that can be versioned.
 */
function _wp_post_revision_fields($post = array(), $deprecated = false)
{
    static $fields = null;
    if (!is_array($post)) {
        $post = get_post($post, ARRAY_A);
    }
    if (is_null($fields)) {
        // Allow these to be versioned
        $fields = array('post_title' => __('Title'), 'post_content' => __('Content'), 'post_excerpt' => __('Excerpt'));
    }
    /**
     * Filter the list of fields saved in post revisions.
     *
     * Included by default: 'post_title', 'post_content' and 'post_excerpt'.
     *
     * Disallowed fields: 'ID', 'post_name', 'post_parent', 'post_date',
     * 'post_date_gmt', 'post_status', 'post_type', 'comment_count',
     * and 'post_author'.
     *
     * @since 2.6.0
     * @since 4.5.0 The `$post` parameter was added.
     *
     * @param array $fields List of fields to revision. Contains 'post_title',
     *                      'post_content', and 'post_excerpt' by default.
     * @param array $post   A post array being processed for insertion as a post revision.
     */
    $fields = apply_filters('_wp_post_revision_fields', $fields, $post);
    // WP uses these internally either in versioning or elsewhere - they cannot be versioned
    foreach (array('ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author') as $protect) {
        unset($fields[$protect]);
    }
    return $fields;
}

WordPress Version: 4.4

/**
 * Post revision functions.
 *
 * @package WordPress
 * @subpackage Post_Revisions
 */
/**
 * Determines which fields of posts are to be saved in revisions.
 *
 * Does two things. If passed a post *array*, it will return a post array ready
 * to be inserted into the posts table as a post revision. Otherwise, returns
 * an array whose keys are the post fields to be saved for post revisions.
 *
 * @since 2.6.0
 * @access private
 *
 * @staticvar array $fields
 *
 * @param array|null $post     Optional. A post array to be processed for insertion as a post revision. Default null.
 * @param bool       $autosave Optional. Is the revision an autosave? Default false.
 * @return array Post array ready to be inserted as a post revision or array of fields that can be versioned.
 */
function _wp_post_revision_fields($post = null, $autosave = false)
{
    static $fields = null;
    if (is_null($fields)) {
        // Allow these to be versioned
        $fields = array('post_title' => __('Title'), 'post_content' => __('Content'), 'post_excerpt' => __('Excerpt'));
        /**
         * Filter the list of fields saved in post revisions.
         *
         * Included by default: 'post_title', 'post_content' and 'post_excerpt'.
         *
         * Disallowed fields: 'ID', 'post_name', 'post_parent', 'post_date',
         * 'post_date_gmt', 'post_status', 'post_type', 'comment_count',
         * and 'post_author'.
         *
         * @since 2.6.0
         *
         * @param array $fields List of fields to revision. Contains 'post_title',
         *                      'post_content', and 'post_excerpt' by default.
         */
        $fields = apply_filters('_wp_post_revision_fields', $fields);
        // WP uses these internally either in versioning or elsewhere - they cannot be versioned
        foreach (array('ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author') as $protect) {
            unset($fields[$protect]);
        }
    }
    if (!is_array($post)) {
        return $fields;
    }
    $return = array();
    foreach (array_intersect(array_keys($post), array_keys($fields)) as $field) {
        $return[$field] = $post[$field];
    }
    $return['post_parent'] = $post['ID'];
    $return['post_status'] = 'inherit';
    $return['post_type'] = 'revision';
    $return['post_name'] = $autosave ? "{$post['ID']}-autosave-v1" : "{$post['ID']}-revision-v1";
    // "1" is the revisioning system version
    $return['post_date'] = isset($post['post_modified']) ? $post['post_modified'] : '';
    $return['post_date_gmt'] = isset($post['post_modified_gmt']) ? $post['post_modified_gmt'] : '';
    return $return;
}

WordPress Version: 4.3

/**
 * Post revision functions.
 *
 * @package WordPress
 * @subpackage Post_Revisions
 */
/**
 * Determines which fields of posts are to be saved in revisions.
 *
 * Does two things. If passed a post *array*, it will return a post array ready
 * to be inserted into the posts table as a post revision. Otherwise, returns
 * an array whose keys are the post fields to be saved for post revisions.
 *
 * @since 2.6.0
 * @access private
 *
 * @staticvar array $fields
 *
 * @param array $post     Optional. A post array to be processed for insertion as a post revision.
 * @param bool  $autosave Optional. Is the revision an autosave?
 * @return array Post array ready to be inserted as a post revision or array of fields that can be versioned.
 */
function _wp_post_revision_fields($post = null, $autosave = false)
{
    static $fields = null;
    if (is_null($fields)) {
        // Allow these to be versioned
        $fields = array('post_title' => __('Title'), 'post_content' => __('Content'), 'post_excerpt' => __('Excerpt'));
        /**
         * Filter the list of fields saved in post revisions.
         *
         * Included by default: 'post_title', 'post_content' and 'post_excerpt'.
         *
         * Disallowed fields: 'ID', 'post_name', 'post_parent', 'post_date',
         * 'post_date_gmt', 'post_status', 'post_type', 'comment_count',
         * and 'post_author'.
         *
         * @since 2.6.0
         *
         * @param array $fields List of fields to revision. Contains 'post_title',
         *                      'post_content', and 'post_excerpt' by default.
         */
        $fields = apply_filters('_wp_post_revision_fields', $fields);
        // WP uses these internally either in versioning or elsewhere - they cannot be versioned
        foreach (array('ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author') as $protect) {
            unset($fields[$protect]);
        }
    }
    if (!is_array($post)) {
        return $fields;
    }
    $return = array();
    foreach (array_intersect(array_keys($post), array_keys($fields)) as $field) {
        $return[$field] = $post[$field];
    }
    $return['post_parent'] = $post['ID'];
    $return['post_status'] = 'inherit';
    $return['post_type'] = 'revision';
    $return['post_name'] = $autosave ? "{$post['ID']}-autosave-v1" : "{$post['ID']}-revision-v1";
    // "1" is the revisioning system version
    $return['post_date'] = isset($post['post_modified']) ? $post['post_modified'] : '';
    $return['post_date_gmt'] = isset($post['post_modified_gmt']) ? $post['post_modified_gmt'] : '';
    return $return;
}

WordPress Version: 3.9

/**
 * Post revision functions.
 *
 * @package WordPress
 * @subpackage Post_Revisions
 */
/**
 * Determines which fields of posts are to be saved in revisions.
 *
 * Does two things. If passed a post *array*, it will return a post array ready
 * to be inserted into the posts table as a post revision. Otherwise, returns
 * an array whose keys are the post fields to be saved for post revisions.
 *
 * @since 2.6.0
 * @access private
 *
 * @param array $post Optional a post array to be processed for insertion as a post revision.
 * @param bool $autosave optional Is the revision an autosave?
 * @return array Post array ready to be inserted as a post revision or array of fields that can be versioned.
 */
function _wp_post_revision_fields($post = null, $autosave = false)
{
    static $fields = false;
    if (!$fields) {
        // Allow these to be versioned
        $fields = array('post_title' => __('Title'), 'post_content' => __('Content'), 'post_excerpt' => __('Excerpt'));
        /**
         * Filter the list of fields saved in post revisions.
         *
         * Included by default: 'post_title', 'post_content' and 'post_excerpt'.
         *
         * Disallowed fields: 'ID', 'post_name', 'post_parent', 'post_date',
         * 'post_date_gmt', 'post_status', 'post_type', 'comment_count',
         * and 'post_author'.
         *
         * @since 2.6.0
         *
         * @param array $fields List of fields to revision. Contains 'post_title',
         *                      'post_content', and 'post_excerpt' by default.
         */
        $fields = apply_filters('_wp_post_revision_fields', $fields);
        // WP uses these internally either in versioning or elsewhere - they cannot be versioned
        foreach (array('ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author') as $protect) {
            unset($fields[$protect]);
        }
    }
    if (!is_array($post)) {
        return $fields;
    }
    $return = array();
    foreach (array_intersect(array_keys($post), array_keys($fields)) as $field) {
        $return[$field] = $post[$field];
    }
    $return['post_parent'] = $post['ID'];
    $return['post_status'] = 'inherit';
    $return['post_type'] = 'revision';
    $return['post_name'] = $autosave ? "{$post['ID']}-autosave-v1" : "{$post['ID']}-revision-v1";
    // "1" is the revisioning system version
    $return['post_date'] = isset($post['post_modified']) ? $post['post_modified'] : '';
    $return['post_date_gmt'] = isset($post['post_modified_gmt']) ? $post['post_modified_gmt'] : '';
    return $return;
}

WordPress Version: 3.7

/**
 * Post revision functions.
 *
 * @package WordPress
 * @subpackage Post_Revisions
 */
/**
 * Determines which fields of posts are to be saved in revisions.
 *
 * Does two things. If passed a post *array*, it will return a post array ready
 * to be inserted into the posts table as a post revision. Otherwise, returns
 * an array whose keys are the post fields to be saved for post revisions.
 *
 * @since 2.6.0
 * @access private
 *
 * @uses apply_filters() Calls '_wp_post_revision_fields' on 'title', 'content' and 'excerpt' fields.
 *
 * @param array $post Optional a post array to be processed for insertion as a post revision.
 * @param bool $autosave optional Is the revision an autosave?
 * @return array Post array ready to be inserted as a post revision or array of fields that can be versioned.
 */
function _wp_post_revision_fields($post = null, $autosave = false)
{
    static $fields = false;
    if (!$fields) {
        // Allow these to be versioned
        $fields = array('post_title' => __('Title'), 'post_content' => __('Content'), 'post_excerpt' => __('Excerpt'));
        // Runs only once
        $fields = apply_filters('_wp_post_revision_fields', $fields);
        // WP uses these internally either in versioning or elsewhere - they cannot be versioned
        foreach (array('ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author') as $protect) {
            unset($fields[$protect]);
        }
    }
    if (!is_array($post)) {
        return $fields;
    }
    $return = array();
    foreach (array_intersect(array_keys($post), array_keys($fields)) as $field) {
        $return[$field] = $post[$field];
    }
    $return['post_parent'] = $post['ID'];
    $return['post_status'] = 'inherit';
    $return['post_type'] = 'revision';
    $return['post_name'] = $autosave ? "{$post['ID']}-autosave-v1" : "{$post['ID']}-revision-v1";
    // "1" is the revisioning system version
    $return['post_date'] = isset($post['post_modified']) ? $post['post_modified'] : '';
    $return['post_date_gmt'] = isset($post['post_modified_gmt']) ? $post['post_modified_gmt'] : '';
    return $return;
}