wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes



wp_is_post_autosave › WordPress Function

Depuis2.6.0
Dépréciéen/a
wp_is_post_autosave ( $post )
Paramètres:
  • (int|WP_Post) $post Post ID or post object.
    Requis: Oui
Retourne:
  • (int|false) ID of autosave's parent on success, false if not a revision.
Défini(e) dans:
Codex:

Determines if the specified post is an autosave.



Source

function wp_is_post_autosave( $post ) {
	$post = wp_get_post_revision( $post );

	if ( ! $post ) {
		return false;
	}

	if ( str_contains( $post->post_name, "{$post->post_parent}-autosave" ) ) {
		return (int) $post->post_parent;
	}

	return false;
}