Changeset 34690
- Timestamp:
- 09/29/2015 09:41:14 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/post.php
r34670 r34690 1297 1297 $preview_target = " target='wp-preview-{$post->ID}'"; 1298 1298 } else { 1299 if ( 'publish' === $post->post_status ) {1299 if ( 'publish' === $post->post_status || 'attachment' === $post->post_type ) { 1300 1300 $view_link = get_permalink( $post ); 1301 1301 } else { … … 1311 1311 1312 1312 if ( false !== $view_link ) { 1313 $return .= '<a id="sample-permalink" href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $ permalink . "</a>\n";1313 $return .= '<a id="sample-permalink" href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $view_link . "</a>\n"; 1314 1314 } else { 1315 1315 $return .= '<span id="sample-permalink">' . $permalink . "</span>\n"; -
trunk/src/wp-includes/link-template.php
r34561 r34690 387 387 $post = get_post( $post ); 388 388 $parent = ( $post->post_parent > 0 && $post->post_parent != $post->ID ) ? get_post( $post->post_parent ) : false; 389 if ( $parent && ! in_array( $parent->post_type, get_post_types() ) ) { 390 $parent = false; 391 } 389 392 390 393 if ( $wp_rewrite->using_permalinks() && $parent ) { … … 404 407 if ( ! $leavename ) 405 408 $link = str_replace( '%postname%', $name, $link ); 409 } elseif ( $wp_rewrite->using_permalinks() && ! $leavename ) { 410 $link = home_url( user_trailingslashit( $post->post_name ) ); 406 411 } 407 412 -
trunk/src/wp-includes/query.php
r34685 r34690 3581 3581 if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) { 3582 3582 $status = get_post_status($this->posts[0]); 3583 if ( 'attachment' === $this->posts[0]->post_type && 0 === (int) $this->posts[0]->post_parent ) { 3584 $this->is_page = false; 3585 $this->is_single = true; 3586 $this->is_attachment = true; 3587 } 3583 3588 $post_status_obj = get_post_status_object($status); 3584 3589 //$type = get_post_type($this->posts[0]); -
trunk/tests/phpunit/tests/link.php
r34088 r34690 396 396 $this->assertEquals( $non_pretty_permalink, get_permalink( $p ) ); 397 397 } 398 399 /** 400 * @ticket 1914 401 */ 402 public function test_unattached_attachment_has_a_pretty_permalink() { 403 global $wp_rewrite; 404 $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/'); 405 $wp_rewrite->flush_rules(); 406 407 $attachment_id = $this->factory->attachment->create_object( 'image.jpg', 0, array( 408 'post_mime_type' => 'image/jpeg', 409 'post_type' => 'attachment', 410 'post_title' => 'An Attachment!', 411 'post_status' => 'inherit', 412 ) ); 413 414 $attachment = get_post( $attachment_id ); 415 416 $this->assertSame( home_url( user_trailingslashit( $attachment->post_name ) ), get_permalink( $attachment_id ) ); 417 } 418 419 /** 420 * @ticket 1914 421 */ 422 public function test_attachment_attached_to_non_existent_post_type_has_a_pretty_permalink() { 423 global $wp_rewrite, $wp_post_types; 424 $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/'); 425 426 register_post_type( 'not_a_post_type', array( 'public' => true ) ); 427 428 $wp_rewrite->flush_rules(); 429 430 $post_id = $this->factory->post->create( array( 'post_type' => 'not_a_post_type' ) ); 431 432 $attachment_id = $this->factory->attachment->create_object( 'image.jpg', $post_id, array( 433 'post_mime_type' => 'image/jpeg', 434 'post_type' => 'attachment', 435 'post_title' => 'An Attachment!', 436 'post_status' => 'inherit', 437 ) ); 438 439 $attachment = get_post( $attachment_id ); 440 441 $this->assertSame( get_permalink( $post_id ) . user_trailingslashit( $attachment->post_name ), get_permalink( $attachment_id ) ); 442 443 foreach( $wp_post_types as $id => $pt ) { 444 if ( 'not_a_post_type' === $pt->name ) { 445 unset( $wp_post_types[ $id ] ); 446 break; 447 } 448 } 449 450 $this->assertSame( home_url( user_trailingslashit( $attachment->post_name ) ), get_permalink( $attachment_id ) ); 451 } 398 452 }
Note: See TracChangeset
for help on using the changeset viewer.