From 99bd388ef308e08c45580923e5d3db2ffe0338d0 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Sun, 19 Dec 2010 14:42:17 +0000 Subject: [PATCH] Fix guid generation for page auto drafts. Props shawnparker. fixes #15041 git-svn-id: https://develop.svn.wordpress.org/trunk@17061 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/link-template.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 85254a1dc2..9edb1bb13e 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -271,11 +271,15 @@ function _get_page_link( $id = false, $leavename = false, $sample = false ) { else $post = &get_post($id); - $link = $wp_rewrite->get_page_permastruct(); + $draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ); - if ( '' != $link && ( ( isset($post->post_status) && 'draft' != $post->post_status && 'pending' != $post->post_status ) || $sample ) ) { - if ( ! $leavename ) + $link = $wp_rewrite->get_page_permastruct(); + + if ( !empty($link) && ( ( isset($post->post_status) && !$draft_or_pending ) || $sample ) ) { + if ( ! $leavename ) { $link = str_replace('%pagename%', get_page_uri($id), $link); + } + $link = home_url($link); $link = user_trailingslashit($link, 'page'); } else {