diff --git a/php/datasource/class-fieldmanager-datasource-term.php b/php/datasource/class-fieldmanager-datasource-term.php index 7006937de..e2b77006b 100644 --- a/php/datasource/class-fieldmanager-datasource-term.php +++ b/php/datasource/class-fieldmanager-datasource-term.php @@ -382,6 +382,11 @@ protected function build_hierarchical_term_data( $parent_terms, $tax_args, $dept $prefix .= '--'; } + // This is to avoid PHP warnings when the term is not a term object. + if ( ! $term instanceof \WP_Term || ! $term->term_taxonomy_id || ! $term->term_id || ! $term->name ) { + continue; + } + $key = $this->store_term_taxonomy_id ? $term->term_taxonomy_id : $term->term_id; $stack[ $key ] = $prefix . ' ' . $term->name;