Warning: This method has been deprecated.
WC_REST_Legacy_Products_Controller::delete_post( int|WP_Post $id )
Delete post.
Description Description
Parameters Parameters
- $id
-
(Required) Post ID or WP_Post instance.
Source Source
File: includes/legacy/api/class-wc-rest-legacy-products-controller.php
protected function delete_post( $id ) {
if ( ! empty( $id->ID ) ) {
$id = $id->ID;
} elseif ( ! is_numeric( $id ) || 0 >= $id ) {
return;
}
// Delete product attachments.
$attachments = get_posts( array(
'post_parent' => $id,
'post_status' => 'any',
'post_type' => 'attachment',
) );
foreach ( (array) $attachments as $attachment ) {
wp_delete_attachment( $attachment->ID, true );
}
// Delete product.
$product = wc_get_product( $id );
$product->delete( true );
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |