[wp-trac] [WordPress Trac] #39254: When in Customizer Preview, starter content posts are not displayed in the loop

WordPress Trac noreply at wordpress.org
Sat Mar 18 05:39:54 UTC 2017


#39254: When in Customizer Preview, starter content posts are not displayed in the
loop
-------------------------------------+-------------------------------------
 Reporter:  tiagonoronha             |       Owner:
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  4.7.4
Component:  Customize                |     Version:  4.7
 Severity:  normal                   |  Resolution:
 Keywords:  needs-patch needs-unit-  |     Focuses:  administration,
  tests                              |  template
-------------------------------------+-------------------------------------
Changes (by westonruter):

 * keywords:  needs-patch => needs-patch needs-unit-tests


Comment:

 I'm not confident that the approach in comment [comment:2] will fully work
 as expected. The approach is prone to starter content posts leaking into
 queries unexpectedly. I think a better approach to explore may be:

 * Modify queries for `publish` posts to also ask for `auto-draft` posts.
 This could be done at the `pre_get_posts` action; or, if no `post_status`
 was specified, make sure that `auto-draft` post status is marked as
 `protected` and `private` so it will be allowed (this should be handled
 already via
 `\WP_Customize_Nav_Menus::make_auto_draft_status_previewable()`).
 * Add a `posts_where` clause which does `AND ( post_status != 'auto-draft'
 OR ID IN ( " . join( ',',
 $wp_customize->get_setting('nav_menus_created_posts')->value() ) . " ))`.
 * Then, as noted in the comment, add a `posts_results` filter which loops
 over all posts and forces the post objects to have: `if ( 'auto-draft' ===
 $post->post_status ) { $post->post_status = 'publish'; }` and to also do
 the same for the `get_post_status` filter.

 I'm not sure this ticket is particularly important so I'm not sure I can
 prioritize for 4.7.4.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39254#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list