| 1 | Index: wp-includes/post.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/post.php (revision 18596) |
|---|
| 4 | +++ wp-includes/post.php (working copy) |
|---|
| 5 | @@ -3162,23 +3162,22 @@ |
|---|
| 6 | $foundid = 0; |
|---|
| 7 | foreach ( $pages as $page ) { |
|---|
| 8 | if ( $page->post_name == $revparts[0] ) { |
|---|
| 9 | - $count = 0; |
|---|
| 10 | - if ( $page->post_parent != 0 ) { |
|---|
| 11 | - if ( null === ( $parent_page = $pages[ $page->post_parent ] ) ) |
|---|
| 12 | - continue; |
|---|
| 13 | - |
|---|
| 14 | - while ( $parent_page->ID != 0 ) { |
|---|
| 15 | - $count++; |
|---|
| 16 | - if ( $parent_page->post_name != $revparts[ $count ] ) |
|---|
| 17 | - break; |
|---|
| 18 | - $parent_page = $pages[ $parent_page->post_parent ]; |
|---|
| 19 | - } |
|---|
| 20 | + if ( 1 == count( $revparts ) ) { |
|---|
| 21 | + $foundid = $page->ID; |
|---|
| 22 | + break; |
|---|
| 23 | + } |
|---|
| 24 | |
|---|
| 25 | - if ( $parent_page->ID == 0 && $count+1 == count($revparts) ) { |
|---|
| 26 | - $foundid = $page->ID; |
|---|
| 27 | + $cur_page = $page; |
|---|
| 28 | + $count = 0; |
|---|
| 29 | + while ( ! empty( $cur_page->post_parent ) && isset( $pages[ $cur_page->post_parent ] ) ) { |
|---|
| 30 | + if ( $cur_page->post_name != $revparts[ $count ] ) |
|---|
| 31 | break; |
|---|
| 32 | - } |
|---|
| 33 | - } else if ( count($revparts) == 1 ) { |
|---|
| 34 | + |
|---|
| 35 | + $cur_page = $pages[ $cur_page->post_parent ]; |
|---|
| 36 | + $count++; |
|---|
| 37 | + } |
|---|
| 38 | + |
|---|
| 39 | + if ( empty( $cur_page->post_parent ) && $count+1 == count($revparts) ) { |
|---|
| 40 | $foundid = $page->ID; |
|---|
| 41 | break; |
|---|
| 42 | } |
|---|