From 2fa9643cf2512b83770650544cd13eec8d7a7ba1 Mon Sep 17 00:00:00 2001 From: Andrew 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: https://develop.svn.wordpress.org/trunk@14399 602fd350-edb4-49c9-b593-d223f7449a82 --- 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.