W3cubDocs

/WordPress

_wp_get_post_revision_version( WP_Post $revision ): int|false

Gets the post revision version.

Parameters

$revisionWP_Postrequired

Return

int|false

Source

function _wp_get_post_revision_version( $revision ) {
	if ( is_object( $revision ) ) {
		$revision = get_object_vars( $revision );
	} elseif ( ! is_array( $revision ) ) {
		return false;
	}

	if ( preg_match( '/^\d+-(?:autosave|revision)-v(\d+)$/', $revision['post_name'], $matches ) ) {
		return (int) $matches[1];
	}

	return 0;
}

Changelog

Version Description
3.6.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/_wp_get_post_revision_version