Changeset 30158
- Timestamp:
- 11/01/2014 08:36:23 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/post.php
r30155 r30158 3674 3674 $feeds = array(); 3675 3675 3676 $hierarchical_post_types = get_post_types( array('hierarchical' => true) );3677 3676 if ( 'attachment' == $post_type ) { 3678 3677 // Attachment slugs must be unique across all types. … … 3697 3696 $slug = $alt_post_name; 3698 3697 } 3699 } elseif ( i n_array( $post_type, $hierarchical_post_types) ) {3698 } elseif ( is_post_type_hierarchical( $post_type ) ) { 3700 3699 if ( 'nav_menu_item' == $post_type ) 3701 3700 return $slug; … … 3705 3704 * namespace than posts so page slugs are allowed to overlap post slugs. 3706 3705 */ 3707 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( '" . implode( "', '", esc_sql( $hierarchical_post_types ) ) . "' )AND ID != %d AND post_parent = %d LIMIT 1";3708 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_ ID, $post_parent ) );3706 $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type = %s AND ID != %d AND post_parent = %d LIMIT 1"; 3707 $post_name_check = $wpdb->get_var( $wpdb->prepare( $check_sql, $slug, $post_type, $post_ID, $post_parent ) ); 3709 3708 3710 3709 /** -
trunk/tests/phpunit/tests/post.php
r29789 r30158 992 992 } 993 993 994 /** 995 * @ticket 18962 996 */ 997 function test_wp_unique_post_slug_with_multiple_hierarchies() { 998 register_post_type( 'post-type-1', array( 'hierarchical' => true ) ); 999 register_post_type( 'post-type-2', array( 'hierarchical' => true ) ); 1000 1001 $args = array( 1002 'post_type' => 'post-type-1', 1003 'post_name' => 'some-slug', 1004 'post_status' => 'publish', 1005 ); 1006 $one = $this->factory->post->create( $args ); 1007 $args['post_type'] = 'post-type-2'; 1008 $two = $this->factory->post->create( $args ); 1009 1010 $this->assertEquals( 'some-slug', get_post( $one )->post_name ); 1011 $this->assertEquals( 'some-slug', get_post( $two )->post_name ); 1012 1013 $this->assertEquals( 'some-other-slug', wp_unique_post_slug( 'some-other-slug', $one, 'publish', 'post-type-1', 0 ) ); 1014 $this->assertEquals( 'some-other-slug', wp_unique_post_slug( 'some-other-slug', $one, 'publish', 'post-type-2', 0 ) ); 1015 1016 _unregister_post_type( 'post-type-1' ); 1017 _unregister_post_type( 'post-type-2' ); 1018 } 994 1019 }
Note: See TracChangeset
for help on using the changeset viewer.