Ticket #17670: 17670.5.diff
| File 17670.5.diff, 2.1 KB (added by , 15 years ago) |
|---|
-
wp-includes/post.php
3155 3155 $parts = array_map( 'esc_sql', $parts ); 3156 3156 $parts = array_map( 'sanitize_title', $parts ); 3157 3157 3158 if ( empty($parts) ) 3159 return null; 3160 3158 3161 $in_string = "'". implode( "','", $parts ) . "'"; 3159 3162 $pages = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name IN ({$in_string}) AND (post_type = %s OR post_type = 'attachment')", $post_type ), OBJECT_K ); 3160 3163 3164 if ( empty($pages) ) 3165 return null; 3166 3161 3167 $revparts = array_reverse( $parts ); 3168 $revparts_count = count($revparts); 3162 3169 3163 $foundid = 0; 3164 foreach ( (array) $pages as $page ) { 3165 if ( $page->post_name == $revparts[0] ) { 3170 if ( 1 == $revparts_count ) { 3171 foreach ( $pages as $page ) { 3172 if ( $page->post_name == $revparts[0] ) 3173 return get_page($page->ID, $output, $post_type); 3174 } 3175 return null; 3176 } 3177 3178 foreach ( $pages as $page ) { 3179 if ( $page->post_name == $revparts[0] && $page->post_parent != 0) { 3180 $cur_page = $page; 3166 3181 $count = 0; 3167 if ( $page->post_parent != 0 ) { 3168 if ( null === ( $parent_page = $pages[ $page->post_parent ] ) ) 3169 continue; 3182 while ( isset($pages[ $cur_page->post_parent ]) ) { 3183 if ( $cur_page->post_name != $revparts[ $count ] ) 3184 continue 2; // Continue next foreach() 3185 $count++; 3186 $cur_page = $pages[ $cur_page->post_parent ]; 3187 } 3170 3188 3171 while ( $parent_page->ID != 0 ) { 3172 $count++; 3173 if ( $parent_page->post_name != $revparts[ $count ] ) 3174 break; 3175 $parent_page = $pages[ $parent_page->post_parent ]; 3176 } 3177 3178 if ( $parent_page->ID == 0 && $count+1 == count($revparts) ) { 3179 $foundid = $page->ID; 3180 break; 3181 } 3182 } else if ( count($revparts) == 1 ) { 3183 $foundid = $page->ID; 3184 break; 3185 } 3189 if ( $count+1 == $revparts_count && $cur_page->post_name == $revparts[$count] ) 3190 return get_page($page->ID, $output, $post_type); 3186 3191 } 3187 3192 } 3188 3193 3189 if ( $foundid )3190 return get_page($foundid, $output, $post_type);3191 3192 3194 return null; 3193 3195 } 3194 3196
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)