Automattic\WooCommerce\Internal\Caches
ProductVersionStringInvalidator::handle_delete_post
Handle the delete_post hook.
Метод класса: ProductVersionStringInvalidator{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
$ProductVersionStringInvalidator = new ProductVersionStringInvalidator(); $ProductVersionStringInvalidator->handle_delete_post( $post_id, $post ): void;
- $post_id(int) (обязательный)
- The post ID.
- $post(WP_Post|null)
- The post object, or null if not provided.
По умолчанию:null
Список изменений
| С версии 10.5.0 | Введена. |
Код ProductVersionStringInvalidator::handle_delete_post() ProductVersionStringInvalidator::handle delete post WC 11.2.2
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();
}
}