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

WordPress Trac noreply at wordpress.org
Fri Feb 7 00:00:02 UTC 2020


#49380: Introduce `is_post_status_viewable()` and `is_post_viewable()` functions.
-------------------------------+------------------------------------------
 Reporter:  peterwilsoncc      |      Owner:  (none)
     Type:  enhancement        |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:
 Severity:  normal             |   Keywords:  needs-patch needs-unit-tests
  Focuses:                     |
-------------------------------+------------------------------------------
 WordPress currently has the function `is_post_type_viewable()` to
 determine if a post type is visible to anonymous users via the
 `publicly_queryable` setting when registering the post type.

 To enable easily determining when a post should be publicly viewable, I
 propose the following functions be introduced.

 {{{
 is_post_status_viewable( array|string $post_status ) : bool
 }}}

 Determines if post status is publicly viewable based on
 public/protected/publicly_queryable settings when registered.

 {{{
 is_post_viewable( int|WP_Post $post = null ) : bool
 }}}

 Determines if a post is viewable based on the outcome of
 `is_post_status_viewable()` and `is_post_status_viewable()`.

 Defaults to current post in loop, ie result of `get_post()`.

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


More information about the wp-trac mailing list