Changeset 34088
- Timestamp:
- 09/12/2015 08:33:07 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/link-template.php
r34042 r34088 1493 1493 1494 1494 if ( $in_same_term || ! empty( $excluded_terms ) ) { 1495 $join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";1496 $where = $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy );1497 1498 1495 if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) { 1499 1496 // back-compat, $excluded_terms used to be $excluded_terms with IDs separated by " and " … … 1509 1506 1510 1507 if ( $in_same_term ) { 1508 $join .= " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id"; 1509 $where .= $wpdb->prepare( "AND tt.taxonomy = %s", $taxonomy ); 1510 1511 1511 if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) ) 1512 1512 return ''; -
trunk/tests/phpunit/tests/link.php
r31622 r34088 258 258 } 259 259 260 /** 261 * @ticket 32833 262 */ 263 public function test_get_adjacent_post_excluded_terms() { 264 register_taxonomy( 'wptests_tax', 'post' ); 265 266 $t = $this->factory->term->create( array( 267 'taxonomy' => 'wptests_tax', 268 ) ); 269 270 $p1 = $this->factory->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) ); 271 $p2 = $this->factory->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) ); 272 $p3 = $this->factory->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) ); 273 274 wp_set_post_terms( $p2, array( $t ), 'wptests_tax' ); 275 276 // Fake current page. 277 $_post = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : null; 278 $GLOBALS['post'] = get_post( $p1 ); 279 280 $found = get_adjacent_post( false, array( $t ), true, 'wptests_tax' ); 281 282 if ( ! is_null( $_post ) ) { 283 $GLOBALS['post'] = $_post; 284 } else { 285 unset( $GLOBALS['post'] ); 286 } 287 288 // Should skip $p2, which belongs to $t. 289 $this->assertEquals( $p3, $found->ID ); 290 } 291 292 /** 293 * @ticket 32833 294 */ 295 public function test_get_adjacent_post_excluded_terms_should_not_require_posts_to_have_terms_in_any_taxonomy() { 296 register_taxonomy( 'wptests_tax', 'post' ); 297 298 $t = $this->factory->term->create( array( 299 'taxonomy' => 'wptests_tax', 300 ) ); 301 302 $p1 = $this->factory->post->create( array( 'post_date' => '2015-08-27 12:00:00' ) ); 303 $p2 = $this->factory->post->create( array( 'post_date' => '2015-08-26 12:00:00' ) ); 304 $p3 = $this->factory->post->create( array( 'post_date' => '2015-08-25 12:00:00' ) ); 305 306 wp_set_post_terms( $p2, array( $t ), 'wptests_tax' ); 307 308 // Make sure that $p3 doesn't have the 'Uncategorized' category. 309 wp_delete_object_term_relationships( $p3, 'category' ); 310 311 // Fake current page. 312 $_post = isset( $GLOBALS['post'] ) ? $GLOBALS['post'] : null; 313 $GLOBALS['post'] = get_post( $p1 ); 314 315 $found = get_adjacent_post( false, array( $t ), true, 'wptests_tax' ); 316 317 if ( ! is_null( $_post ) ) { 318 $GLOBALS['post'] = $_post; 319 } else { 320 unset( $GLOBALS['post'] ); 321 } 322 323 // Should skip $p2, which belongs to $t. 324 $this->assertEquals( $p3, $found->ID ); 325 } 326 260 327 public function test_wp_make_link_relative_with_http_scheme() { 261 328 $link = 'http://example.com/this-is-a-test-http-url/';
Note: See TracChangeset
for help on using the changeset viewer.