From 6d7aeeac03b69a67402a2b9bc098f83461c9d949 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Thu, 27 Aug 2015 20:57:22 +0000 Subject: [PATCH] Don't change the View Post button permalink in the sample permalink HTML when updating the slug on a published or future post. Fixes #32954 Props boonebgorges, johnbillion Built from https://develop.svn.wordpress.org/trunk@33773 git-svn-id: http://core.svn.wordpress.org/trunk@33741 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/post.php | 9 ++++++--- wp-includes/version.php | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index ff60783ae5..909c1f8082 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -1308,7 +1308,6 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { $post_name_html = '' . $post_name_abridged . ''; $display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, urldecode( $permalink ) ); - $pretty_permalink = str_replace( array( '%pagename%', '%postname%' ), $post_name, urldecode( $permalink ) ); $return = '' . __( 'Permalink:' ) . "\n"; $return .= '' . $display_link . "\n"; @@ -1324,8 +1323,12 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post ); $return .= "$view_post\n"; } else { - if ( empty( $pretty_permalink ) ) { - $pretty_permalink = $permalink; + if ( 'publish' === $post->post_status ) { + // View Post button should always go to the saved permalink. + $pretty_permalink = get_permalink( $post ); + } else { + // Allow non-published (private, future) to be viewed at a pretty permalink. + $pretty_permalink = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, urldecode( $permalink ) ); } $return .= "$view_post\n"; diff --git a/wp-includes/version.php b/wp-includes/version.php index ae6d3c06b3..20ce50c6a4 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-33772'; +$wp_version = '4.4-alpha-33773'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.