From 753243a6f74c2491722ee886b3c6a2cf517132d3 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Wed, 23 Dec 2015 19:57:27 +0000 Subject: [PATCH] Move excluded_terms filter in `get_adjacent_post()`. The filter was added in 4.4 [34528] #9571, but in a place where it could not affect the adjacent post query. Fixes #35211. Built from https://develop.svn.wordpress.org/trunk@36078 git-svn-id: http://core.svn.wordpress.org/trunk@36043 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/link-template.php | 26 +++++++++++++------------- wp-includes/version.php | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index cfe6bc9e0d..5d88bd60c3 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -1568,6 +1568,7 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo $join = ''; $where = ''; + $adjacent = $previous ? 'previous' : 'next'; if ( $in_same_term || ! empty( $excluded_terms ) ) { if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) { @@ -1600,6 +1601,18 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo $where .= " AND tt.term_id IN (" . implode( ',', $term_array ) . ")"; } + /** + * Filter the IDs of terms excluded from adjacent post queries. + * + * The dynamic portion of the hook name, `$adjacent`, refers to the type + * of adjacency, 'next' or 'previous'. + * + * @since 4.4.0 + * + * @param string $excluded_terms Array of excluded term IDs. + */ + $excluded_terms = apply_filters( "get_{$adjacent}_post_excluded_terms", $excluded_terms ); + if ( ! empty( $excluded_terms ) ) { $where .= " AND p.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships tr LEFT JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tt.term_id IN (" . implode( $excluded_terms, ',' ) . ') )'; } @@ -1635,22 +1648,9 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo $where .= " AND p.post_status = 'publish'"; } - $adjacent = $previous ? 'previous' : 'next'; $op = $previous ? '<' : '>'; $order = $previous ? 'DESC' : 'ASC'; - /** - * Filter the excluded term ids - * - * The dynamic portion of the hook name, `$adjacent`, refers to the type - * of adjacency, 'next' or 'previous'. - * - * @since 4.4.0 - * - * @param string $excluded_terms Array of excluded term IDs. - */ - $excluded_terms = apply_filters( "get_{$adjacent}_post_excluded_terms", $excluded_terms ); - /** * Filter the JOIN clause in the SQL for an adjacent post query. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 7b7e73c049..d3f8708d7c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.5-alpha-36077'; +$wp_version = '4.5-alpha-36078'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.