diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php
index fe22d87a06..1c7e53fa39 100644
|
|
final class WP_Customize_Manager { |
1392 | 1392 | |
1393 | 1393 | // Posts & pages. |
1394 | 1394 | if ( ! empty( $posts ) ) { |
1395 | | foreach ( array_keys( $posts ) as $post_symbol ) { |
| 1395 | $post_date = current_time( 'timestamp' ); |
| 1396 | |
| 1397 | foreach ( array_keys( $posts ) as $i => $post_symbol ) { |
1396 | 1398 | if ( empty( $posts[ $post_symbol ]['post_type'] ) || empty( $posts[ $post_symbol ]['post_name'] ) ) { |
1397 | 1399 | continue; |
1398 | 1400 | } |
… |
… |
final class WP_Customize_Manager { |
1408 | 1410 | // Use existing auto-draft post if one already exists with the same type and name. |
1409 | 1411 | if ( isset( $existing_starter_content_posts[ $post_type . ':' . $post_name ] ) ) { |
1410 | 1412 | $posts[ $post_symbol ]['ID'] = $existing_starter_content_posts[ $post_type . ':' . $post_name ]->ID; |
| 1413 | update_post_meta( $posts[ $post_symbol ]['ID'], '_starter_content_theme', $this->get_stylesheet() ); |
1411 | 1414 | continue; |
1412 | 1415 | } |
1413 | 1416 | |
… |
… |
final class WP_Customize_Manager { |
1422 | 1425 | $posts[ $post_symbol ]['meta_input']['_wp_page_template'] = $posts[ $post_symbol ]['template']; |
1423 | 1426 | } |
1424 | 1427 | |
| 1428 | // Keep "reverse-chronological" order given where the post appeared in the starter content. See #42612. |
| 1429 | $posts[ $post_symbol ]['post_date'] = gmdate( 'Y-m-d H:i:s', $post_date - $i ); |
| 1430 | |
| 1431 | // Allow this post to be identified as starter content. |
| 1432 | $posts[ $post_symbol ]['meta_input']['_starter_content_theme'] = $this->get_stylesheet(); |
| 1433 | |
1425 | 1434 | $r = $this->nav_menus->insert_auto_draft_post( $posts[ $post_symbol ] ); |
1426 | 1435 | if ( $r instanceof WP_Post ) { |
1427 | 1436 | $posts[ $post_symbol ]['ID'] = $r->ID; |
diff --git src/wp-includes/class-wp-customize-nav-menus.php src/wp-includes/class-wp-customize-nav-menus.php
index 9529ce78a3..43fa8973ce 100644
|
|
final class WP_Customize_Nav_Menus { |
1276 | 1276 | public function save_nav_menus_created_posts( $setting ) { |
1277 | 1277 | $post_ids = $setting->post_value(); |
1278 | 1278 | if ( ! empty( $post_ids ) ) { |
1279 | | foreach ( $post_ids as $post_id ) { |
| 1279 | $post_date = current_time( 'timestamp' ); |
1280 | 1280 | |
| 1281 | foreach ( $post_ids as $i => $post_id ) { |
1281 | 1282 | // Prevent overriding the status that a user may have prematurely updated the post to. |
1282 | 1283 | $current_status = get_post_status( $post_id ); |
1283 | 1284 | if ( 'auto-draft' !== $current_status && 'draft' !== $current_status ) { |
… |
… |
final class WP_Customize_Nav_Menus { |
1294 | 1295 | $args['post_name'] = $post_name; |
1295 | 1296 | } |
1296 | 1297 | |
| 1298 | // Publish starter content "reverse-chronologically" based on where it appeared in the theme definition. See #42612. |
| 1299 | if ( get_post_meta( $post_id, '_starter_content_theme', true ) ) { |
| 1300 | $args['edit_date'] = true; |
| 1301 | $args['post_date'] = gmdate( 'Y-m-d H:i:s', $post_date - $i ); |
| 1302 | } |
| 1303 | |
1297 | 1304 | // Note that wp_publish_post() cannot be used because unique slugs need to be assigned. |
1298 | 1305 | wp_update_post( wp_slash( $args ) ); |
1299 | 1306 | |
diff --git src/wp-includes/theme.php src/wp-includes/theme.php
index 406fa4a310..90e2d62e99 100644
|
|
function is_customize_preview() { |
3191 | 3191 | * |
3192 | 3192 | * When a changeset is updated but remains an auto-draft, ensure the post_date |
3193 | 3193 | * for the auto-draft posts remains the same so that it will be |
3194 | | * garbage-collected at the same time by `wp_delete_auto_drafts()`. Otherwise, |
3195 | | * if the changeset is updated to be a draft then update the posts |
3196 | | * to have a far-future post_date so that they will never be garbage collected |
3197 | | * unless the changeset post itself is deleted. |
| 3194 | * garbage-collected at the same time by `wp_delete_auto_drafts()`. |
3198 | 3195 | * |
3199 | 3196 | * When a changeset is updated to be a persistent draft or to be scheduled for |
3200 | 3197 | * publishing, then transition any dependent auto-drafts to a draft status so |
… |
… |
function _wp_keep_alive_customize_changeset_dependent_auto_drafts( $new_status, |
3264 | 3261 | $post_args['post_status'] = 'draft'; |
3265 | 3262 | } |
3266 | 3263 | |
3267 | | foreach ( $data['nav_menus_created_posts']['value'] as $post_id ) { |
| 3264 | foreach ( $data['nav_menus_created_posts']['value'] as $i => $post_id ) { |
3268 | 3265 | if ( empty( $post_id ) || 'auto-draft' !== get_post_status( $post_id ) ) { |
3269 | 3266 | continue; |
3270 | 3267 | } |
| 3268 | |
| 3269 | // Keep starter content "reverse-chronological" based on where it appeared in the theme definition. See #42612. |
| 3270 | if ( isset( $post_args['post_date'] ) && get_post_meta( $post_id, '_starter_content_theme', true ) ) { |
| 3271 | $post_args['post_date'] = gmdate( 'Y-m-d H:i:s', strtotime( $post_args['post_date'] ) - $i ); |
| 3272 | } |
| 3273 | |
3271 | 3274 | $wpdb->update( |
3272 | 3275 | $wpdb->posts, |
3273 | 3276 | $post_args, |