[wp-trac] [WordPress Trac] #49380: Introduce `is_post_status_viewable()` and `is_post_viewable()` functions.

WordPress Trac noreply at wordpress.org
Mon Feb 1 23:32:10 UTC 2021


#49380: Introduce `is_post_status_viewable()` and `is_post_viewable()` functions.
--------------------------------------+----------------------------
 Reporter:  peterwilsoncc             |       Owner:  peterwilsoncc
     Type:  enhancement               |      Status:  closed
 Priority:  normal                    |   Milestone:  5.7
Component:  Posts, Post Types         |     Version:
 Severity:  normal                    |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+----------------------------
Changes (by peterwilsoncc):

 * status:  reopened => closed
 * resolution:   => fixed


Comment:

 In [changeset:"50130" 50130]:
 {{{
 #!CommitTicketReference repository="" revision="50130"
 Posts, Post Types: Additional functions to check if a post is publicly
 viewable.

 Introduces `is_post_status_viewable()` as a sibling to
 `is_post_type_viewable()`. Internal and protected statuses are never
 considered viewable. For built in posts statuses the `public` attribute is
 checked, for custom statuses the `publicly_queryable` attribute is
 checked.

 Introduces `is_post_publicly_viewable()` for determining if an individual
 post can be viewed by logged out users. A post is considered viewable if
 both `is_post_status_viewable()` and `is_post_type_viewable()` return
 `true` for the post's attributes.

 Additionally modifies `is_post_type_viewable()` to return `false` if an
 unregistered post type is passed to the function to avoid attempting to
 access properties on a non-object.

 Props peterwilsoncc, SergeyBiryukov, whyisjake, TimothyBlynJacobs.
 Fixes #49380.
 }}}

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


More information about the wp-trac mailing list