WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/05/2016 07:38:16 PM (4 years ago)
Author:
westonruter
Message:

Customize: Defer populating post_name for auto-draft posts in customized state until posts are published.

The ultimate post_name is stored in postmeta until the post is published. The get_page_by_path() function does not exclude auto-draft posts. Revert changes to wp_unique_post_slug() from [39411] which excluded auto-draft posts.

Props westonruter, dlh for testing, helen for testing.
Merges [39506] onto 4.7 branch.
Fixes #39078 for 4.7.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-includes/class-wp-customize-manager.php

    r39500 r39507  
    10071007            ) );
    10081008            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, '_customize_draft_post_name', true );
     1012                }
     1013                $existing_starter_content_posts[ $existing_post->post_type . ':' . $post_name ] = $existing_post;
    10101014            }
    10111015        }
     
    10681072
    10691073                    $attachment_post_data = array_merge(
    1070                         wp_array_slice_assoc( $attachment, array( 'post_title', 'post_content', 'post_excerpt', 'post_name' ) ),
     1074                        wp_array_slice_assoc( $attachment, array( 'post_title', 'post_content', 'post_excerpt' ) ),
    10711075                        array(
    10721076                            'post_status' => 'auto-draft', // So attachment will be garbage collected in a week if changeset is never published.
     
    10861090                    }
    10871091                    update_post_meta( $attachment_id, '_starter_content_theme', $this->get_stylesheet() );
     1092                    update_post_meta( $attachment_id, '_customize_draft_post_name', $attachment['post_name'] );
    10881093                }
    10891094
Note: See TracChangeset for help on using the changeset viewer.