$excluded_terms =
apply_filters( "get_{
$adjacent}_post_excluded_terms",
$excluded_terms );
if ( $in_same_term || !
empty( $excluded_terms ) ) { if ( $in_same_term ) { $join .= " INNER JOIN
$wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN
$wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
$where .=
$wpdb->
prepare( 'AND tt.taxonomy = %s',
$taxonomy );
if ( !
is_object_in_taxonomy( $post->post_type,
$taxonomy ) ) { return '';
} $term_array =
wp_get_object_terms( $post->ID,
$taxonomy, array
( 'fields' => 'ids'
) );
// Remove any exclusions from the term array to include.
$term_array =
array_diff( $term_array,
(array) $excluded_terms );
$term_array =
array_map( 'intval',
$term_array );
if ( !
$term_array ||
is_wp_error( $term_array ) ) { return '';
} $where .= ' AND tt.term_id IN (' .
implode( ',',
$term_array ) . ')';
}