WordPress.org

Make WordPress Core

Ticket #43521: 43521.2.diff

File 43521.2.diff, 2.0 KB (added by soulseekah, 3 years ago)

Move excluded_terms sanitization to before the filter

  • src/wp-includes/link-template.php

    diff --git src/wp-includes/link-template.php src/wp-includes/link-template.php
    index 365b14b..13619d2 100644
    function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo 
    16821682        $where    = '';
    16831683        $adjacent = $previous ? 'previous' : 'next';
    16841684
     1685        if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) {
     1686                // back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and "
     1687                if ( false !== strpos( $excluded_terms, ' and ' ) ) {
     1688                        _deprecated_argument( __FUNCTION__, '3.3.0', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) );
     1689                        $excluded_terms = explode( ' and ', $excluded_terms );
     1690                } else {
     1691                        $excluded_terms = explode( ',', $excluded_terms );
     1692                }
     1693
     1694                $excluded_terms = array_map( 'intval', $excluded_terms );
     1695        }
     1696
    16851697        /**
    16861698         * Filters the IDs of terms excluded from adjacent post queries.
    16871699         *
    function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo 
    16951707        $excluded_terms = apply_filters( "get_{$adjacent}_post_excluded_terms", $excluded_terms );
    16961708
    16971709        if ( $in_same_term || ! empty( $excluded_terms ) ) {
    1698                 if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) {
    1699                         // back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and "
    1700                         if ( false !== strpos( $excluded_terms, ' and ' ) ) {
    1701                                 _deprecated_argument( __FUNCTION__, '3.3.0', sprintf( __( 'Use commas instead of %s to separate excluded terms.' ), "'and'" ) );
    1702                                 $excluded_terms = explode( ' and ', $excluded_terms );
    1703                         } else {
    1704                                 $excluded_terms = explode( ',', $excluded_terms );
    1705                         }
    1706 
    1707                         $excluded_terms = array_map( 'intval', $excluded_terms );
    1708                 }
    1709 
    17101710                if ( $in_same_term ) {
    17111711                        $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";
    17121712                        $where .= $wpdb->prepare( 'AND tt.taxonomy = %s', $taxonomy );