Skip to content

Commit d23db34

Browse files
authored
Merge pull request #646 from ProgressPlanner/filip/v19/fix-remove-term
Fix point sometimes not awarded for completing "Remove term without posts" task.
2 parents 1c6c727 + ebe31d9 commit d23db34

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Enhancements:
77
Bugs we fixed:
88

99
* Fix missing content and streak badges after they are all completed.
10+
* Fix issue when point is sometimes not awarded for completing "Remove term without posts" task.
1011

1112

1213
= 1.8.0 =

classes/suggested-tasks/providers/class-remove-terms-without-posts.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,13 @@ public function maybe_remove_irrelevant_tasks( $object_id, $terms, $tt_ids, $tax
128128
if ( $task->target_term_id && $task->target_taxonomy ) {
129129
$term = \get_term( $task->target_term_id, $task->target_taxonomy );
130130

131-
if ( \is_wp_error( $term ) || ! $term || $term->count > self::MIN_POSTS ) {
131+
// If the term is NULL it means the term was deleted, but we want to keep the task (and award a point).
132+
if ( ! $term ) {
133+
continue;
134+
}
135+
136+
// If the taxonomy is not found the $term will be a WP_Error object.
137+
if ( \is_wp_error( $term ) || $term->count > self::MIN_POSTS ) {
132138
\progress_planner()->get_suggested_tasks_db()->delete_recommendation( $task->ID );
133139
}
134140
}

0 commit comments

Comments
 (0)