wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema



wp_get_post_revisions › WordPress Function

Desde2.6.0
Obsoleton/a
wp_get_post_revisions ( $post = 0, $args = null )
Parâmetros: (2)
  • (int|WP_Post) $post Optional. Post ID or WP_Post object. Default is global `$post`.
    Required: No
    Padrão:
  • (array|null) $args Optional. Arguments for retrieving post revisions. Default null.
    Required: No
    Padrão: null
Ver:
Retorna:
  • (WP_Post[]|int[]) Array of revision objects or IDs, or an empty array if none.
Definido em:
Codex:

Returns all revisions of specified post.



Fonte

function wp_get_post_revisions( $post = 0, $args = null ) {
	$post = get_post( $post );

	if ( ! $post || empty( $post->ID ) ) {
		return array();
	}

	$defaults = array(
		'order'         => 'DESC',
		'orderby'       => 'date ID',
		'check_enabled' => true,
	);
	$args     = wp_parse_args( $args, $defaults );

	if ( $args['check_enabled'] && ! wp_revisions_enabled( $post ) ) {
		return array();
	}

	$args = array_merge(
		$args,
		array(
			'post_parent' => $post->ID,
			'post_type'   => 'revision',
			'post_status' => 'inherit',
		)
	);

	$revisions = get_children( $args );

	if ( ! $revisions ) {
		return array();
	}

	return $revisions;
}