Skip to content

Commit

Permalink
Merge pull request #731 from carstingaxion/fix/730
Browse files Browse the repository at this point in the history
Reflect changes to the venue term, when a venue post gets deleted.
  • Loading branch information
mauteri authored Jul 14, 2024
2 parents aa09301 + 6d2d831 commit 7957f7b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
11 changes: 9 additions & 2 deletions includes/core/classes/class-venue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
12 changes: 12 additions & 0 deletions test/unit/php/includes/core/classes/class-test-venue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 7957f7b

Please sign in to comment.