wpseek.com
WordPress开发者和主题制作者的搜索引擎



_wp_delete_edit_root_attachment_id › WordPress Function

Since7.2.0
已弃用n/a
› _wp_delete_edit_root_attachment_id ( $post_id )
访问:
  • private
参数:
  • (int) $post_id Attachment ID being deleted.
    Required: Yes
定义在:
文档:

Clears the recorded edit root ID from any attachment pointing at a deleted one.

Without this, attachments created by editing the deleted image would keep pointing at an ID that no longer exists, and could later point at an unrelated attachment if WordPress reuses that ID. This only runs when an attachment is deleted for good. On sites where media goes to the trash first, attachments keep pointing at the trashed edit root until the trash is emptied.


源码

function _wp_delete_edit_root_attachment_id( $post_id ) {
	$post_id = (int) $post_id;

	if ( $post_id <= 0 ) {
		return;
	}

	/*
	 * Deletes the meta from every attachment recording this ID as its edit root. The meta key
	 * is indexed, so this only scans the rows for attachments created by editing an image,
	 * and it avoids searching the serialized attachment metadata for the ID.
	 */
	delete_metadata( 'post', 0, '_wp_attachment_edit_root_id', $post_id, true );
}