diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php
index 8905721..2eb021e 100644
|
|
final class WP_Customize_Manager { |
1006 | 1006 | 'posts_per_page' => -1, |
1007 | 1007 | ) ); |
1008 | 1008 | foreach ( $existing_posts_query->posts as $existing_post ) { |
1009 | | $existing_starter_content_posts[ $existing_post->post_type . ':' . $existing_post->post_name ] = $existing_post; |
| 1009 | $post_name = $existing_post->post_name; |
| 1010 | if ( empty( $post_name ) ) { |
| 1011 | $post_name = get_post_meta( $existing_post->ID, '_starter_content_post_name', true ); |
| 1012 | } |
| 1013 | $existing_starter_content_posts[ $existing_post->post_type . ':' . $post_name ] = $existing_post; |
1010 | 1014 | } |
1011 | 1015 | } |
1012 | 1016 | |
diff --git src/wp-includes/class-wp-customize-nav-menus.php src/wp-includes/class-wp-customize-nav-menus.php
index 1305a14..89e73e1 100644
|
|
final class WP_Customize_Nav_Menus { |
803 | 803 | if ( empty( $postarr['post_name'] ) ) { |
804 | 804 | $postarr['post_name'] = sanitize_title( $postarr['post_title'] ); |
805 | 805 | } |
| 806 | if ( ! isset( $postarr['meta_input'] ) ) { |
| 807 | $postarr['meta_input'] = array(); |
| 808 | } |
| 809 | $postarr['meta_input']['_starter_content_post_name'] = $postarr['post_name']; |
| 810 | unset( $postarr['post_name'] ); |
806 | 811 | |
807 | 812 | add_filter( 'wp_insert_post_empty_content', '__return_false', 1000 ); |
808 | 813 | $r = wp_insert_post( wp_slash( $postarr ), true ); |
… |
… |
final class WP_Customize_Nav_Menus { |
1192 | 1197 | if ( ! empty( $post_ids ) ) { |
1193 | 1198 | foreach ( $post_ids as $post_id ) { |
1194 | 1199 | $target_status = 'attachment' === get_post_type( $post_id ) ? 'inherit' : 'publish'; |
| 1200 | $args = array( |
| 1201 | 'ID' => $post_id, |
| 1202 | 'post_status' => $target_status, |
| 1203 | ); |
| 1204 | $post_name = get_post_meta( $post_id, '_starter_content_post_name', true ); |
| 1205 | if ( $post_name ) { |
| 1206 | $args['post_name'] = $post_name; |
| 1207 | } |
1195 | 1208 | |
1196 | 1209 | // Note that wp_publish_post() cannot be used because unique slugs need to be assigned. |
1197 | | wp_update_post( array( 'ID' => $post_id, 'post_status' => $target_status ) ); |
| 1210 | wp_update_post( wp_slash( $args ) ); |
1198 | 1211 | } |
1199 | 1212 | } |
1200 | 1213 | } |
diff --git tests/phpunit/tests/customize/manager.php tests/phpunit/tests/customize/manager.php
index 345e666..c4403e0 100644
|
|
class Tests_WP_Customize_Manager extends WP_UnitTestCase { |
454 | 454 | } else { |
455 | 455 | $this->assertEquals( 'auto-draft', $post->post_status ); |
456 | 456 | } |
457 | | $posts_by_name[ $post->post_name ] = $post->ID; |
| 457 | $post_name = $post->post_name; |
| 458 | if ( empty( $post_name ) ) { |
| 459 | $post_name = get_post_meta( $post->ID, '_starter_content_post_name', true ); |
| 460 | } |
| 461 | $posts_by_name[ $post_name ] = $post->ID; |
458 | 462 | } |
459 | 463 | $this->assertEquals( array( 'waffles', 'canola', 'home', 'about', 'blog', 'custom' ), array_keys( $posts_by_name ) ); |
460 | 464 | $this->assertEquals( 'Custom', get_post( $posts_by_name['custom'] )->post_title ); |
diff --git tests/phpunit/tests/customize/nav-menus.php tests/phpunit/tests/customize/nav-menus.php
index f8b38a1..1feeced 100644
|
|
class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { |
549 | 549 | $r = $menus->insert_auto_draft_post( array( 'post_title' => 'Hello World', 'post_type' => 'post' ) ); |
550 | 550 | $this->assertInstanceOf( 'WP_Post', $r ); |
551 | 551 | $this->assertEquals( 'Hello World', $r->post_title ); |
552 | | $this->assertEquals( 'hello-world', $r->post_name ); |
| 552 | $this->assertEquals( '', $r->post_name ); |
| 553 | $this->assertEquals( 'hello-world', get_post_meta( $r->ID, '_starter_content_post_name', true ) ); |
553 | 554 | $this->assertEquals( 'post', $r->post_type ); |
554 | 555 | |
555 | 556 | $r = $menus->insert_auto_draft_post( array( 'post_title' => 'Hello World', 'post_type' => 'post', 'post_name' => 'greetings-world', 'post_content' => 'Hi World' ) ); |
556 | 557 | $this->assertInstanceOf( 'WP_Post', $r ); |
557 | 558 | $this->assertEquals( 'Hello World', $r->post_title ); |
558 | 559 | $this->assertEquals( 'post', $r->post_type ); |
559 | | $this->assertEquals( 'greetings-world', $r->post_name ); |
| 560 | $this->assertEquals( '', $r->post_name ); |
| 561 | $this->assertEquals( 'greetings-world', get_post_meta( $r->ID, '_starter_content_post_name', true ) ); |
560 | 562 | $this->assertEquals( 'Hi World', $r->post_content ); |
561 | 563 | } |
562 | 564 | |