From 87bd780ca961b58e5ab5333ef5d392042de7797e Mon Sep 17 00:00:00 2001 From: dd32 Date: Sun, 18 Apr 2010 01:46:28 +0000 Subject: [PATCH] Display the correct Slug in the permalink preview. Props duck_. Fixes #12870 git-svn-id: http://svn.automattic.com/wordpress/trunk@14124 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-ajax.php | 2 +- wp-admin/includes/post.php | 4 ++-- wp-includes/link-template.php | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 038f0048a..9418f6db6 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -1058,7 +1058,7 @@ case 'sample-permalink': check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' ); $post_id = isset($_POST['post_id'])? intval($_POST['post_id']) : 0; $title = isset($_POST['new_title'])? $_POST['new_title'] : ''; - $slug = isset($_POST['new_slug'])? $_POST['new_slug'] : ''; + $slug = isset($_POST['new_slug'])? $_POST['new_slug'] : null; die(get_sample_permalink_html($post_id, $title, $slug)); break; case 'inline-save': diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 844e8991e..bba57eb8b 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -1027,13 +1027,13 @@ function get_sample_permalink($id, $title = null, $name = null) { $post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID); } - $post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent); - // If the user wants to set a new name -- override the current one // Note: if empty name is supplied -- use the title instead, see #6072 if ( !is_null($name) ) $post->post_name = sanitize_title($name ? $name : $title, $post->ID); + $post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent); + $post->filter = 'sample'; $permalink = get_permalink($post, true); diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index c26dafb80..d26e455b3 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -271,11 +271,11 @@ function _get_page_link( $id = false, $leavename = false, $sample = false ) { else $post = &get_post($id); - $pagestruct = $wp_rewrite->get_page_permastruct(); + $link = $wp_rewrite->get_page_permastruct(); - if ( '' != $pagestruct && ( ( isset($post->post_status) && 'draft' != $post->post_status && 'pending' != $post->post_status ) || $sample ) ) { - $link = get_page_uri($id); - $link = ( $leavename ) ? $pagestruct : str_replace('%pagename%', $link, $pagestruct); + if ( '' != $link && ( ( isset($post->post_status) && 'draft' != $post->post_status && 'pending' != $post->post_status ) || $sample ) ) { + if ( ! $leavename ) + $link = str_replace('%pagename%', get_page_uri($id), $link); $link = home_url($link); $link = user_trailingslashit($link, 'page'); } else {