WordPress.org

Make WordPress Core

Ticket #18120: link-template.diff

File link-template.diff, 1.4 KB (added by javert03, 3 years ago)

SVN diff

  • wp-includes/link-template.php

     
    11301130        } 
    11311131 
    11321132        $adjacent = $previous ? 'previous' : 'next'; 
    1133         $op = $previous ? '<' : '>'; 
     1133        $dateCmp = 'BETWEEN ' . ($previous ? "%s AND '9999-12-31 00:00:00'" : "'1970-01-01 00:00:00' AND %s" ); 
    11341134        $order = $previous ? 'DESC' : 'ASC'; 
    11351135 
    11361136        $join  = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_cat, $excluded_categories ); 
    1137         $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare("WHERE p.post_date $op %s AND p.post_type = %s AND p.post_status = 'publish' $posts_in_ex_cats_sql", $current_post_date, $post->post_type), $in_same_cat, $excluded_categories ); 
     1137        $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare("WHERE p.post_date $dateCmp AND p.post_type = %s AND p.post_status = 'publish' $posts_in_ex_cats_sql", $current_post_date, $post->post_type), $in_same_cat, $excluded_categories ); 
    11381138        $sort  = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1" ); 
    11391139 
    1140         $query = "SELECT p.* FROM $wpdb->posts AS p $join $where $sort"; 
     1140        $query = "SELECT p.ID, p.post_title, p.post_status, p.post_date FROM $wpdb->posts AS p $join $where $sort"; 
    11411141        $query_key = 'adjacent_post_' . md5($query); 
    11421142        $result = wp_cache_get($query_key, 'counts'); 
    11431143        if ( false !== $result )