Automattic\WooCommerce\Internal\Caches
ProductVersionStringInvalidator::handle_delete_post
Handle the delete_post hook.
Method of the class: ProductVersionStringInvalidator{}
No Hooks.
Returns
null. Nothing (null).
Usage
$ProductVersionStringInvalidator = new ProductVersionStringInvalidator(); $ProductVersionStringInvalidator->handle_delete_post( $post_id, $post ): void;
- $post_id(int) (required)
- The post ID.
- $post(WP_Post|null)
- The post object, or null if not provided.
Default:null
Changelog
| Since 10.5.0 | Introduced. |
ProductVersionStringInvalidator::handle_delete_post() ProductVersionStringInvalidator::handle delete post code WC 10.8.1
public function handle_delete_post( $post_id, $post = null ): void {
$post_id = (int) $post_id;
if ( ! $post instanceof \WP_Post ) {
$post = get_post( $post_id );
}
if ( ! $post ) {
return;
}
if ( 'product_variation' === $post->post_type ) {
$parent_id = (int) $post->post_parent;
$this->invalidate_variation_and_parent( $post_id, $parent_id );
$this->invalidate_variations_list( $parent_id );
$this->invalidate_variation_parent_cache( $post_id );
} elseif ( 'product' === $post->post_type ) {
$this->invalidate( $post_id );
$this->invalidate_products_list();
}
}