#49380 closed enhancement (fixed)
Introduce `is_post_status_viewable()` and `is_post_viewable()` functions.
Reported by: | peterwilsoncc | Owned by: | peterwilsoncc |
---|---|---|---|
Milestone: | 5.7 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | has-patch has-unit-tests has-dev-note |
Focuses: | Cc: |
Description (last modified by )
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_type_viewable()
and is_post_status_viewable()
.
Defaults to current post in loop, ie result of get_post()
.
Attachments (1)
Change History (19)
This ticket was mentioned in PR #217 on WordPress/wordpress-develop by peterwilsoncc.
5 years ago
#1
whyisjake commented on PR #217:
5 years ago
#3
Words.
#4
@
5 years ago
- Keywords has-unit-tests has-patch added; needs-patch needs-unit-tests removed
- Milestone changed from Awaiting Review to 5.5
- Owner set to whyisjake
- Status changed from new to accepted
I like the direction here!
#7
@
4 years ago
Need to review this further, as "viewable" actually refers to publicly queryable, as opposed to public, I just need to double check is_post_viewable()
makes sense.
I think is_*_public()
functions would also make sense but that can be another ticket for another day.
#8
@
4 years ago
- Keywords close added; has-unit-tests has-patch commit removed
- Milestone changed from 5.5 to Future Release
- Owner changed from whyisjake to peterwilsoncc
- Status changed from accepted to assigned
Reviewing WP::parse_query
, it doesn't look like the post status object's publicly_queryable
property is used anywhere.
Removing from milestone and the commit keyword as a result. I'll close it once I've got clarification.
#9
@
4 years ago
- Keywords close removed
- Milestone Future Release deleted
@SergeyBiryukov @whyisjake
Closing this off as post_status
is not publicly queryable (it's in WP::$private_query_vars
rather than $public_query_vars
).
This can probably be dealt with if Post Statuses move beyond the simple standard class.
#11
@
4 years ago
- Milestone set to 5.7
- Resolution wontfix deleted
- Status changed from closed to reopened
I realised this was necessary while working on #5272, reopening.
This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.
4 years ago
This ticket was mentioned in Slack in #core by peterwilsoncc. View the logs.
4 years ago
This ticket was mentioned in PR #971 on WordPress/wordpress-develop by peterwilsoncc.
4 years ago
#14
- Keywords has-patch has-unit-tests added
https://core.trac.wordpress.org/ticket/49380
Separates this out from PR #863.
#18
@
4 years ago
Since taxonomies behave much like posts and have a similarly named function, is_taxonomy_viewable()
, will those receive changes akin to this ticket, or has this ticket/patch left an accidental discrepancy?
Edit: I reckon it a bit too late that terms don't have statuses. Ignore me :)
https://core.trac.wordpress.org/ticket/49380