diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index d13a11e65581c..6b6798f84a9e4 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -5068,6 +5068,9 @@ function is_object_in_term( $object_id, $taxonomy, $terms = null ) { $strs =& $terms; } + // Only check numeric strings against term_id, to avoid false matches due to type juggling. + $numeric_strs = array_map( 'intval', array_filter( $strs, 'is_numeric' ) ); + foreach ( $object_terms as $object_term ) { // If term is an int, check against term_ids only. if ( $ints && in_array( $object_term->term_id, $ints, true ) ) { @@ -5075,8 +5078,6 @@ function is_object_in_term( $object_id, $taxonomy, $terms = null ) { } if ( $strs ) { - // Only check numeric strings against term_id, to avoid false matches due to type juggling. - $numeric_strs = array_map( 'intval', array_filter( $strs, 'is_numeric' ) ); if ( in_array( $object_term->term_id, $numeric_strs, true ) ) { return true; }