From aca357b327793ceac83815f89c945275088fdf49 Mon Sep 17 00:00:00 2001 From: nacin Date: Mon, 3 May 2010 20:10:26 +0000 Subject: [PATCH] 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 --- wp-admin/includes/post.php | 2 +- wp-includes/post.php | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index ba6d5bab60..be8e62e107 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -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); diff --git a/wp-includes/post.php b/wp-includes/post.php index 2926eca864..09693047c5 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -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.