WordPress at a glance

wp_get_post_revision() WP 1.0

Gets a post revision.

Works based on: get_post()
✈ 1 time = 0.000602s = slow | 50000 times = 1.12s = fast

No Hooks.

Return

WP_Post/Array/null. WP_Post (or array) on success, or null on failure.

Usage

wp_get_post_revision( &$post, $output, $filter );
$post(int/WP_Post) (required)
The post ID or object.
$output(string)
The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which correspond to a WP_Post object, an associative array, or a numeric array, respectively.
Default: OBJECT
$filter(string)
Optional sanitation filter. See sanitize_post().
Default: 'raw'

Code of wp_get_post_revision: wp-includes/revision.php VER 4.9.8

<?php
function wp_get_post_revision(&$post, $output = OBJECT, $filter = 'raw') {
	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;
}

Related Functions

From tag: post revisions

No comments
    Hello, !     Log In . Register