Ticket #30287: 30287.diff
File 30287.diff, 1.9 KB (added by , 9 years ago) |
---|
-
src/wp-includes/link-template.php
1517 1517 } 1518 1518 } 1519 1519 1520 if ( is_user_logged_in() ) { 1521 $user_id = get_current_user_id(); 1522 1523 $post_type_object = get_post_type_object( $post->post_type ); 1524 if ( empty( $post_type_object ) ) { 1525 $post_type_cap = $post->post_type; 1526 $read_private_cap = 'read_private_' . $post_type_cap . 's'; 1527 } else { 1528 $read_private_cap = $post_type_object->cap->read_private_posts; 1529 } 1530 1531 // Add private states that are limited to viewing by the author of a post or someone who has caps to read private states. 1532 $private_states = get_post_stati( array( 'private' => true ) ); 1533 $where .= " AND ( p.post_status = 'publish'"; 1534 foreach ( (array) $private_states as $state ) { 1535 $where .= current_user_can( $read_private_cap ) ? " OR p.post_status = '$state'" : " OR (p.post_author = $user_id AND p.post_status = '$state')"; 1536 } 1537 $where .= " )"; 1538 } else { 1539 $where .= " AND p.post_status = 'publish'"; 1540 } 1541 1520 1542 $adjacent = $previous ? 'previous' : 'next'; 1521 1543 $op = $previous ? '<' : '>'; 1522 1544 $order = $previous ? 'DESC' : 'ASC'; … … 1547 1569 * @param bool $in_same_term Whether post should be in a same taxonomy term. 1548 1570 * @param array $excluded_terms Array of excluded term IDs. 1549 1571 */ 1550 $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'$where", $current_post_date, $post->post_type ), $in_same_term, $excluded_terms );1572 $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare( "WHERE p.post_date $op %s AND p.post_type = %s $where", $current_post_date, $post->post_type ), $in_same_term, $excluded_terms ); 1551 1573 1552 1574 /** 1553 1575 * Filter the ORDER BY clause in the SQL for an adjacent post query.