Skip to content

Commit d9d9d54

Browse files
authored
Merge pull request #689 from ProgressPlanner/filip/v19/fix-checking-irellevant-task
Fix "check irrelevant tasks" for "Delete term without posts" and "Update term description" tasks
2 parents 9a9fb65 + 959b6e0 commit d9d9d54

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ public function init() {
115115
* @return void
116116
*/
117117
public function maybe_remove_irrelevant_tasks( $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) {
118+
119+
$taxonomy_object = \get_taxonomy( $taxonomy );
120+
121+
// Check if the taxonomy is public, we are not interested in non-public taxonomies (also our data collector doesn't track non-public taxonomies).
122+
if ( ! $taxonomy_object || ! $taxonomy_object->public ) {
123+
return;
124+
}
125+
118126
foreach ( \progress_planner()->get_suggested_tasks_db()->get_tasks_by( [ 'provider_id' => $this->get_provider_id() ] ) as $task ) {
119127
/**
120128
* The task post object.

classes/suggested-tasks/providers/class-update-term-description.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ public function init() {
107107
* @return void
108108
*/
109109
public function maybe_remove_irrelevant_tasks( $term, $tt_id, $taxonomy, $deleted_term, $object_ids ) {
110+
111+
$taxonomy_object = \get_taxonomy( $taxonomy );
112+
113+
// Check if the taxonomy is public, we are not interested in non-public taxonomies (also our data collector doesn't track non-public taxonomies).
114+
if ( ! $taxonomy_object || ! $taxonomy_object->public ) {
115+
return;
116+
}
117+
110118
$pending_tasks = \progress_planner()->get_suggested_tasks_db()->get_tasks_by( [ 'provider_id' => $this->get_provider_id() ] );
111119

112120
if ( ! $pending_tasks ) {

0 commit comments

Comments
 (0)