_wp_get_post_revision_version

函式
_wp_get_post_revision_version ( $revision )
Access
Private
引數
  • (WP_Post) $revision
    Required:
返回值
  • (int|false)
定義位置
相關方法
wp_get_post_revisionswp_get_post_revisionwp_get_post_revisions_url_wp_put_post_revisionwp_list_post_revisions
引入
3.6.0
棄用
-

_wp_get_post_revision_version: 這個函式用來獲取一個特定的文章修訂版的版本。它接收一個文章修訂版的ID,並返回該修訂版的版本。

獲取文章的修訂版本。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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;
}

常見問題

FAQs
檢視更多 >