WordPress.org

Make WordPress Core

Ticket #35761: get_adjacent_post_filters.patch

File get_adjacent_post_filters.patch, 1.4 KB (added by briandichiara, 2 years ago)

patch to link-template.php to add 2 new filters

  • wp-includes/link-template.php

    From 0a0c6e2c1e4a0d20e282c3766635f1c749419edc Mon Sep 17 00:00:00 2001
    From: Brian DiChiara <briandichiara@gmail.com>
    Date: Fri, 5 Feb 2016 21:53:11 -0600
    Subject: [PATCH] adds new filters inside get_adjacent_post() to override the
     entire query or override the the result
    
    ---
     wp-includes/link-template.php | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php
    index ee02cd7..a26a4c6 100644
    a b function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo 
    17121712         */
    17131713        $sort  = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1", $post );
    17141714
    1715         $query = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort";
     1715        $query = apply_filters( "get_{$adjacent}_post_query", "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort", $post );
    17161716        $query_key = 'adjacent_post_' . md5( $query );
    17171717        $result = wp_cache_get( $query_key, 'counts' );
    17181718        if ( false !== $result ) {
    function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo 
    17211721                return $result;
    17221722        }
    17231723
    1724         $result = $wpdb->get_var( $query );
     1724        $result = apply_filters( "get_{$adjacent}_post_result", $wpdb->get_var( $query ), $post );
    17251725        if ( null === $result )
    17261726                $result = '';
    17271727