wp_is_post_autosave

函式
wp_is_post_autosave ( $post )
引數
  • (int|WP_Post) $post Post ID or post object.
    Required:
返回值
  • (int|false) ID of autosave's parent on success, false if not a revision.
定義位置
相關方法
wp_get_post_autosavewp_create_post_autosavewp_set_post_catswp_autosavewp_list_authors
引入
2.6.0
棄用
-

wp_is_post_autosave: 該函式用於檢查當前請求是否是一個文章的自動儲存請求。它接收一個文章ID作為引數,如果當前請求是該文章的自動儲存請求,則返回true,否則返回false。

確定指定的文章是否是自動儲存。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_is_post_autosave( $post ) {
$post = wp_get_post_revision( $post );
if ( ! $post ) {
return false;
}
if ( false !== strpos( $post->post_name, "{$post->post_parent}-autosave" ) ) {
return (int) $post->post_parent;
}
return false;
}
function wp_is_post_autosave( $post ) { $post = wp_get_post_revision( $post ); if ( ! $post ) { return false; } if ( false !== strpos( $post->post_name, "{$post->post_parent}-autosave" ) ) { return (int) $post->post_parent; } return false; }
function wp_is_post_autosave( $post ) {
	$post = wp_get_post_revision( $post );

	if ( ! $post ) {
		return false;
	}

	if ( false !== strpos( $post->post_name, "{$post->post_parent}-autosave" ) ) {
		return (int) $post->post_parent;
	}

	return false;
}

常見問題

FAQs
檢視更多 >