Skip to content

Commit

Permalink
Merge pull request #215 from barryceelen/patch-1
Browse files Browse the repository at this point in the history
Check if $terms is an array before using count()
  • Loading branch information
jeffpaul committed Apr 22, 2022
2 parents 168d377 + 44f1601 commit 23a26be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions includes/functions/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function( $taxonomy ) {
$taxonomy = apply_filters( 'sophi_hierarchial_taxonomy_for_breadcrumb', $taxonomies[0], $post );
$terms = get_the_terms( $post, $taxonomy );

if ( count( $terms ) > 0 ) {
if ( is_array( $terms ) && count( $terms ) > 0 ) {
return get_term_breadcrumb( $terms[0] );
}
} else { // Just return the current term if it's not hierarchical.
Expand Down Expand Up @@ -113,7 +113,7 @@ function( $taxonomy ) {
$taxonomy = apply_filters( 'sophi_non_hierarchial_taxonomy_for_breadcrumb', $non_hierarchial_taxonomies[0], $post );
$terms = get_the_terms( $post, $taxonomy );

if ( count( $terms ) > 0 ) {
if ( is_array( $terms ) && count( $terms ) > 0 ) {
return $terms[0]->slug;
}
}
Expand Down

0 comments on commit 23a26be

Please sign in to comment.