Inventory_Presser_Admin_Customize_Dashboard::delete_all_post_attachments()

delete_all_post_attachments


Description Description

Deletes all a post's attachments. The callback behind the Delete All Media button.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/admin/class-admin-customize-dashboard.php

	function delete_all_post_attachments() {
		if ( empty( $_POST['_ajax_nonce'] ) || ! wp_verify_nonce( $_POST['_ajax_nonce'], self::NONCE_DELETE_ALL_MEDIA ) ) {
			return;
		}

		$post_id = isset( $_POST['post_ID'] ) ? $_POST['post_ID'] : 0;

		if ( ! isset( $post_id ) ) {
			return; // Will die in case you run a function like this: delete_post_media($post_id); if you will remove this line - ALL ATTACHMENTS WHO HAS A PARENT WILL BE DELETED PERMANENTLY!
		} elseif ( 0 == $post_id ) {
			return; // Will die in case you have 0 set. there's no page id called 0 :)
		} elseif ( is_array( $post_id ) ) {
			return; // Will die in case you place there an array of pages.
		} else {
			INVP::delete_attachments( $post_id );
		}
	}