@@ -1964,6 +1964,9 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo
19641964 */
19651965 $ join = apply_filters ( "get_ {$ adjacent }_post_join " , $ join , $ in_same_term , $ excluded_terms , $ taxonomy , $ post );
19661966
1967+ // Prepare the where clause for the adjacent post query.
1968+ $ where_prepared = $ wpdb ->prepare ( "WHERE (p.post_date $ op %s OR (p.post_date = %s AND p.ID $ op %d)) AND p.post_type = %s $ where " , $ current_post_date , $ current_post_date , $ post ->ID , $ post ->post_type ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $op is a string literal, either '<' or '>'.
1969+
19671970 /**
19681971 * Filters the WHERE clause in the SQL for an adjacent post query.
19691972 *
@@ -1977,15 +1980,15 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo
19771980 *
19781981 * @since 2.5.0
19791982 * @since 4.4.0 Added the `$taxonomy` and `$post` parameters.
1980- * @since n.e.x.t Adds ID-based fallback for posts with identical dates in adjacent post queries.
1983+ * @since 6.9.0 Adds ID-based fallback for posts with identical dates in adjacent post queries.
19811984 *
19821985 * @param string $where The `WHERE` clause in the SQL.
19831986 * @param bool $in_same_term Whether post should be in the same taxonomy term.
19841987 * @param int[]|string $excluded_terms Array of excluded term IDs. Empty string if none were provided.
19851988 * @param string $taxonomy Taxonomy. Used to identify the term used when `$in_same_term` is true.
19861989 * @param WP_Post $post WP_Post object.
19871990 */
1988- $ where = apply_filters ( "get_ {$ adjacent }_post_where " , $ wpdb -> prepare ( " WHERE (p.post_date $ op %s OR (p.post_date = %s AND p.ID $ op %d)) AND p.post_type = %s $ where " , $ current_post_date , $ current_post_date , $ post -> ID , $ post -> post_type ) , $ in_same_term , $ excluded_terms , $ taxonomy , $ post );
1991+ $ where = apply_filters ( "get_ {$ adjacent }_post_where " , $ where_prepared , $ in_same_term , $ excluded_terms , $ taxonomy , $ post );
19891992
19901993 /**
19911994 * Filters the ORDER BY clause in the SQL for an adjacent post query.
@@ -2001,7 +2004,7 @@ function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previo
20012004 * @since 2.5.0
20022005 * @since 4.4.0 Added the `$post` parameter.
20032006 * @since 4.9.0 Added the `$order` parameter.
2004- * @since n.e.x.t Adds ID sort to ensure deterministic ordering for posts with identical dates.
2007+ * @since 6.9.0 Adds ID sort to ensure deterministic ordering for posts with identical dates.
20052008 *
20062009 * @param string $order_by The `ORDER BY` clause in the SQL.
20072010 * @param WP_Post $post WP_Post object.
0 commit comments