From bf43978730bfecff8473ec568b3e15211bf67476 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 15 Jan 2019 01:54:49 +0000 Subject: [PATCH] Link Template: In `get_adjacent_post()`, move the sanitisation of `$excluded_terms` earlier. This is a followup to [42828], ensuring that the `get_{$adjacent}_post_excluded_terms` filter is always passed an array, as expected. Props soulseekah, zottto. Fixes #43521. Built from https://develop.svn.wordpress.org/trunk@44591 git-svn-id: http://core.svn.wordpress.org/trunk@44422 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 0e746becb0..be39e36279 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -1687,6 +1687,18 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo $where = ''; $adjacent = $previous ? 'previous' : 'next'; + if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) { + // back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and " + if ( false !== strpos( $excluded_terms, ' and ' ) ) { + _deprecated_argument( __FUNCTION__, '3.3.0', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) ); + $excluded_terms = explode( ' and ', $excluded_terms ); + } else { + $excluded_terms = explode( ',', $excluded_terms ); + } + + $excluded_terms = array_map( 'intval', $excluded_terms ); + } + /** * Filters the IDs of terms excluded from adjacent post queries. * @@ -1695,23 +1707,11 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo * * @since 4.4.0 * - * @param string $excluded_terms Array of excluded term IDs. + * @param array $excluded_terms Array of excluded term IDs. */ $excluded_terms = apply_filters( "get_{$adjacent}_post_excluded_terms", $excluded_terms ); if ( $in_same_term || ! empty( $excluded_terms ) ) { - if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) { - // back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and " - if ( false !== strpos( $excluded_terms, ' and ' ) ) { - _deprecated_argument( __FUNCTION__, '3.3.0', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) ); - $excluded_terms = explode( ' and ', $excluded_terms ); - } else { - $excluded_terms = explode( ',', $excluded_terms ); - } - - $excluded_terms = array_map( 'intval', $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 tt ON tr.term_taxonomy_id = tt.term_taxonomy_id"; $where .= $wpdb->prepare( 'AND tt.taxonomy = %s', $taxonomy ); diff --git a/wp-includes/version.php b/wp-includes/version.php index a64a5ab56e..a0aca0a34c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.1-beta1-44590'; +$wp_version = '5.1-beta1-44591'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.