_wp_get_allowed_postdata

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

WordPress Version: 5.9

/**
 * Returns only allowed post data fields.
 *
 * @since 5.0.1
 *
 * @param array|WP_Error|null $post_data The array of post data to process, or an error object.
 *                                       Defaults to the `$_POST` superglobal.
 * @return array|WP_Error Array of post data on success, WP_Error on failure.
 */
function _wp_get_allowed_postdata($post_data = null)
{
    if (empty($post_data)) {
        $post_data = $_POST;
    }
    // Pass through errors.
    if (is_wp_error($post_data)) {
        return $post_data;
    }
    return array_diff_key($post_data, array_flip(array('meta_input', 'file', 'guid')));
}

WordPress Version: 5.4

/**
 * Returns only allowed post data fields
 *
 * @since 5.0.1
 *
 * @param array $post_data Array of post data. Defaults to the contents of $_POST.
 * @return array|WP_Error Array of post data on success, WP_Error on failure.
 */
function _wp_get_allowed_postdata($post_data = null)
{
    if (empty($post_data)) {
        $post_data = $_POST;
    }
    // Pass through errors.
    if (is_wp_error($post_data)) {
        return $post_data;
    }
    return array_diff_key($post_data, array_flip(array('meta_input', 'file', 'guid')));
}

WordPress Version: 5.1

/**
 * Returns only allowed post data fields
 *
 * @since 5.0.1
 *
 * @param array $post_data Array of post data. Defaults to the contents of $_POST.
 * @return object|bool WP_Error on failure, true on success.
 */
function _wp_get_allowed_postdata($post_data = null)
{
    if (empty($post_data)) {
        $post_data = $_POST;
    }
    // Pass through errors
    if (is_wp_error($post_data)) {
        return $post_data;
    }
    return array_diff_key($post_data, array_flip(array('meta_input', 'file', 'guid')));
}

WordPress Version: .28

/**
 * Returns only allowed post data fields
 *
 * @since 4.9.9
 *
 * @param array $post_data Array of post data. Defaults to the contents of $_POST.
 * @return object|bool WP_Error on failure, true on success.
 */
function _wp_get_allowed_postdata($post_data = null)
{
    if (empty($post_data)) {
        $post_data = $_POST;
    }
    // Pass through errors
    if (is_wp_error($post_data)) {
        return $post_data;
    }
    return array_diff_key($post_data, array_flip(array('meta_input', 'file', 'guid')));
}