Handle page hierarchy when showing the sample permalink. props duck_, fixes #12327.

git-svn-id: http://svn.automattic.com/wordpress/trunk@14399 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-05-03 20:10:26 +00:00
parent c5ff2b4ae9
commit aca357b327
2 changed files with 5 additions and 4 deletions

View File

@ -1036,7 +1036,7 @@ function get_sample_permalink($id, $title = null, $name = null) {
// Handle page hierarchy
if ( $ptype->hierarchical ) {
$uri = get_page_uri($post->ID);
$uri = get_page_uri($post);
$uri = untrailingslashit($uri);
$uri = strrev( stristr( strrev( $uri ), '/' ) );
$uri = untrailingslashit($uri);

View File

@ -2908,11 +2908,12 @@ function _page_traverse_name( $page_id, &$children, &$result ){
*
* @since 1.5.0
*
* @param int $page_id Page ID.
* @param mixed $page Page object or page ID.
* @return string Page URI.
*/
function get_page_uri($page_id) {
$page = get_page($page_id);
function get_page_uri($page) {
if ( ! is_object($page) )
$page = get_page($page);
$uri = $page->post_name;
// A page cannot be it's own parent.