diff --git src/wp-admin/includes/post.php src/wp-admin/includes/post.php
index e7c2af1..b222847 100644
|
|
function get_sample_permalink($id, $title = null, $name = null) { |
1223 | 1223 | |
1224 | 1224 | // If the user wants to set a new name -- override the current one |
1225 | 1225 | // Note: if empty name is supplied -- use the title instead, see #6072 |
1226 | | if ( !is_null($name) ) |
1227 | | $post->post_name = sanitize_title($name ? $name : $title, $post->ID); |
| 1226 | if ( ! is_null( $name ) ) { |
| 1227 | $post->post_name = sanitize_title( $name ? $name : $title, $post->ID ); |
| 1228 | |
| 1229 | // Otherwise, use our default behavior. |
| 1230 | } elseif ( empty( $post->post_name ) ) { |
| 1231 | $post->post_name = sanitize_title( $post->post_title, $post->ID ); |
| 1232 | } |
| 1233 | |
| 1234 | $post->filter = 'sample'; |
1228 | 1235 | |
1229 | 1236 | $post->post_name = wp_unique_post_slug( $post->post_name, (object) array( |
1230 | 1237 | 'ID' => $post->ID, |
… |
… |
function get_sample_permalink($id, $title = null, $name = null) { |
1233 | 1240 | 'post_parent' => $post->post_parent, |
1234 | 1241 | ) ); |
1235 | 1242 | |
1236 | | $post->filter = 'sample'; |
1237 | | |
1238 | 1243 | $permalink = get_permalink($post, true); |
1239 | 1244 | |
1240 | 1245 | // Replace custom post_type Token with generic pagename token for ease of use. |
diff --git src/wp-includes/post.php src/wp-includes/post.php
index 93e973b..985d9f7 100644
|
|
function wp_unique_post_slug( $slug, $post, $deprecated_post_status = null, $dep |
3741 | 3741 | $post->post_parent = $deprecated_post_parent; |
3742 | 3742 | } |
3743 | 3743 | |
3744 | | if ( in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ) || ( 'inherit' == $post->post_status && 'revision' == $post->post_type ) ) { |
| 3744 | // There's a few circumstances where we don't want to check for uniqueness: auto-saves and revisions. |
| 3745 | if ( 'auto-draft' === $post->post_status || ( 'inherit' == $post->post_status && 'revision' == $post->post_type ) ) { |
3745 | 3746 | return $slug; |
3746 | 3747 | } |
3747 | 3748 | |
diff --git tests/phpunit/tests/post/wpUniquePostSlug.php tests/phpunit/tests/post/wpUniquePostSlug.php
index 88dfdcd..51d27f0 100644
|
|
class Tests_Post_WpUniquePostSlug extends WP_UnitTestCase { |
153 | 153 | |
154 | 154 | public function whitelist_post_statuses() { |
155 | 155 | return array( |
156 | | array( 'draft' ), |
157 | | array( 'pending' ), |
| 156 | // array( 'draft' ), |
| 157 | // array( 'pending' ), |
158 | 158 | array( 'auto-draft' ), |
159 | 159 | ); |
160 | 160 | } |