Changeset 42828
- Timestamp:
- 03/11/2018 05:31:04 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/link-template.php
r42736 r42828 1683 1683 $adjacent = $previous ? 'previous' : 'next'; 1684 1684 1685 /** 1686 * Filters the IDs of terms excluded from adjacent post queries. 1687 * 1688 * The dynamic portion of the hook name, `$adjacent`, refers to the type 1689 * of adjacency, 'next' or 'previous'. 1690 * 1691 * @since 4.4.0 1692 * 1693 * @param string $excluded_terms Array of excluded term IDs. 1694 */ 1695 $excluded_terms = apply_filters( "get_{$adjacent}_post_excluded_terms", $excluded_terms ); 1696 1685 1697 if ( $in_same_term || ! empty( $excluded_terms ) ) { 1686 1698 if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) { … … 1715 1727 $where .= ' AND tt.term_id IN (' . implode( ',', $term_array ) . ')'; 1716 1728 } 1717 1718 /**1719 * Filters the IDs of terms excluded from adjacent post queries.1720 *1721 * The dynamic portion of the hook name, `$adjacent`, refers to the type1722 * of adjacency, 'next' or 'previous'.1723 *1724 * @since 4.4.01725 *1726 * @param string $excluded_terms Array of excluded term IDs.1727 */1728 $excluded_terms = apply_filters( "get_{$adjacent}_post_excluded_terms", $excluded_terms );1729 1729 1730 1730 if ( ! empty( $excluded_terms ) ) { -
trunk/tests/phpunit/tests/link/getAdjacentPost.php
r42343 r42828 247 247 * @ticket 35211 248 248 */ 249 public function test_ excluded_terms_filter() {249 public function test_get_adjacent_post_excluded_terms_filter() { 250 250 register_taxonomy( 'wptests_tax', 'post' ); 251 251 … … 277 277 } 278 278 279 /** 280 * @ticket 43521 281 */ 282 public function test_get_adjacent_post_excluded_terms_filter_should_apply_to_empty_excluded_terms_parameter() { 283 register_taxonomy( 'wptests_tax', 'post' ); 284 285 $terms = self::factory()->term->create_many( 286 2, array( 287 'taxonomy' => 'wptests_tax', 288 ) 289 ); 290 291 $p1 = self::factory()->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) ); 292 $p2 = self::factory()->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) ); 293 $p3 = self::factory()->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) ); 294 295 wp_set_post_terms( $p1, array( $terms[0], $terms[1] ), 'wptests_tax' ); 296 wp_set_post_terms( $p2, array( $terms[1] ), 'wptests_tax' ); 297 wp_set_post_terms( $p3, array( $terms[0] ), 'wptests_tax' ); 298 299 $this->go_to( get_permalink( $p1 ) ); 300 301 $this->exclude_term = $terms[1]; 302 add_filter( 'get_previous_post_excluded_terms', array( $this, 'filter_excluded_terms' ) ); 303 304 $found = get_adjacent_post( false, array(), true, 'wptests_tax' ); 305 306 remove_filter( 'get_previous_post_excluded_terms', array( $this, 'filter_excluded_terms' ) ); 307 unset( $this->exclude_term ); 308 309 $this->assertSame( $p3, $found->ID ); 310 } 311 279 312 public function filter_excluded_terms( $excluded_terms ) { 280 313 $excluded_terms[] = $this->exclude_term;
Note: See TracChangeset
for help on using the changeset viewer.