fix format_categories for empty term list
Some checks failed
PHP Code Checker / PHP Code Checker (pull_request) Successful in 50s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Failing after 1m8s
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Failing after 1m7s
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Failing after 1m9s

This commit is contained in:
André Menrath 2024-10-02 17:11:14 +02:00
parent f76fa57665
commit 3f7f996e10

View file

@ -226,8 +226,10 @@ abstract class Event extends Post {
// Add all category terms.
$terms = \get_the_terms( $this->wp_object, $this->wp_taxonomy );
foreach ( $terms as $term ) {
$categories[] = $term->name;
if ( $terms && ! is_wp_error( $terms ) ) {
foreach ( $terms as $term ) {
$categories[] = $term->name;
}
}
if ( ! empty( $categories ) ) {