wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_get_post_revision › WordPress Function

Seit2.6.0
Veraltetn/v
wp_get_post_revision ( $post, $output = OBJECT, $filter = 'raw' )
Parameter: (3)
  • (int|WP_Post) $post Post ID or post object.
    Erforderlich: Ja
  • (string) $output Optional. 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.
    Erforderlich: Nein
    Standard: OBJECT
  • (string) $filter Optional sanitization filter. See sanitize_post(). Default 'raw'.
    Erforderlich: Nein
    Standard: 'raw'
Gibt zurück:
  • (WP_Post|array|null) WP_Post (or array) on success, or null on failure.
Definiert in:
Codex:

Gets a post revision.



Quellcode

function wp_get_post_revision( &$post, $output = OBJECT, $filter = 'raw' ) {
	$revision = get_post( $post, OBJECT, $filter );

	if ( ! $revision ) {
		return $revision;
	}

	if ( 'revision' !== $revision->post_type ) {
		return null;
	}

	if ( OBJECT === $output ) {
		return $revision;
	} elseif ( ARRAY_A === $output ) {
		$_revision = get_object_vars( $revision );
		return $_revision;
	} elseif ( ARRAY_N === $output ) {
		$_revision = array_values( get_object_vars( $revision ) );
		return $_revision;
	}

	return $revision;
}