diff --git a/includes/core/classes/class-venue.php b/includes/core/classes/class-venue.php index 146b76439..b0d6bcd7d 100644 --- a/includes/core/classes/class-venue.php +++ b/includes/core/classes/class-venue.php @@ -261,8 +261,15 @@ public function maybe_update_term_slug( int $post_id, WP_Post $post_after, WP_Po return; } - // Only proceed if the venue post is being published. - if ( 'publish' !== $post_after->post_status ) { + // Only proceed if the venue post is being published or trashed. + if ( ! in_array( + $post_after->post_status, + array( + 'publish', + 'trash', + ), + true + ) ) { return; } diff --git a/test/unit/php/includes/core/classes/class-test-venue.php b/test/unit/php/includes/core/classes/class-test-venue.php index 4f8e1f308..f2af3a07d 100644 --- a/test/unit/php/includes/core/classes/class-test-venue.php +++ b/test/unit/php/includes/core/classes/class-test-venue.php @@ -267,6 +267,18 @@ public function test_maybe_update_term_slug(): void { 'Failed to assert that slugs do not match.' ); + // Setting back to trash should update the term. + $venue_after->post_status = 'trash'; + $instance->maybe_update_term_slug( $venue_before->ID, $venue_after, $venue_before ); + + $term_object = get_term( $term['term_id'] ); + + $this->assertSame( + $term_object->slug, + $instance->get_venue_term_slug( $venue_after->post_name ), + 'Failed to assert that slugs match.' + ); + // Setting back to publish should update the term. $venue_after->post_status = 'publish'; $instance->maybe_update_term_slug( $venue_before->ID, $venue_after, $venue_before );