Protect taxonomy term description and thumbnail

A user of Broadcast has several blogs with WooCommerce.

The blogs receiving the products usually have their own product category descriptions and images, and the user didn’t want the descriptions and images being overwritten by the one on the parent blog.

So I wrote this snippet that protects the description of all product categories from being overwritten, together with the chosen image.

// Prio 4 since Broadcast begins handling the action at prio 5, in order to allow for add-ons to just add the action handler without specifying prio (default 10).
add_action( 'threewp_broadcast_wp_update_term', 'my_threewp_broadcast_wp_update_term', 4 );
function my_threewp_broadcast_wp_update_term( $action )
{
	// We're looking for the WooCommerce product category taxonomy.
	if ( $action->old_term->taxonomy != 'product_cat' )
		return;

	// Prevent the description from being overwritten by assigning the old (child) value to the new (parent) value.
	$action->new_term->description = $action->old_term->description;

	// While we're here, remove the thumbnail ID for this term.
	// See broadcast / src / traits / terms_and_taxonomies.php for this code.
	$old_term_id = $action->old_term->term_id;
	$new_term_id = $action->new_term->term_id;

	$old_meta = $action->broadcasting_data->taxonomy_term_meta
		->collection( $action->broadcasting_data->parent_blog_id )		// Extract the data from the parent blog
		->collection( 'terms' )											// And extract the data from the terms subcollection
		->get( $old_term_id );											// And get the collection for this old term ID.

	// The thumbnail ID is the image ID of the taxonomy.
	$old_meta->forget( 'thumbnail_id' );
}