Fix notices and logic errors in get_page_by_path(). Props duck_. see #17670
git-svn-id: http://svn.automattic.com/wordpress/trunk@19075 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
31e3ff3fb1
commit
c3c6a3721f
|
@ -3164,22 +3164,16 @@ function get_page_by_path($page_path, $output = OBJECT, $post_type = 'page') {
|
||||||
foreach ( (array) $pages as $page ) {
|
foreach ( (array) $pages as $page ) {
|
||||||
if ( $page->post_name == $revparts[0] ) {
|
if ( $page->post_name == $revparts[0] ) {
|
||||||
$count = 0;
|
$count = 0;
|
||||||
if ( $page->post_parent != 0 ) {
|
$p = $page;
|
||||||
if ( null === ( $parent_page = $pages[ $page->post_parent ] ) )
|
while ( $p->post_parent != 0 && isset( $pages[ $p->post_parent ] ) ) {
|
||||||
continue;
|
$count++;
|
||||||
|
$parent = $pages[ $p->post_parent ];
|
||||||
while ( $parent_page->ID != 0 ) {
|
if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] )
|
||||||
$count++;
|
|
||||||
if ( $parent_page->post_name != $revparts[ $count ] )
|
|
||||||
break;
|
|
||||||
$parent_page = $pages[ $parent_page->post_parent ];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $parent_page->ID == 0 && $count+1 == count($revparts) ) {
|
|
||||||
$foundid = $page->ID;
|
|
||||||
break;
|
break;
|
||||||
}
|
$p = $parent;
|
||||||
} else if ( count($revparts) == 1 ) {
|
}
|
||||||
|
|
||||||
|
if ( $p->post_parent == 0 && $count+1 == count( $revparts ) && $p->post_name == $revparts[ $count ] ) {
|
||||||
$foundid = $page->ID;
|
$foundid = $page->ID;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue