Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflect changes to the venue term, when a venue post gets deleted. #731

Merged
merged 2 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading