[wp-trac] [WordPress Trac] #38276: "Is thing public" API

WordPress Trac noreply at wordpress.org
Mon Oct 10 22:08:31 UTC 2016


#38276: "Is thing public" API
-----------------------------+------------------------------
 Reporter:  jdgrimes         |       Owner:
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Role/Capability  |     Version:  trunk
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:
-----------------------------+------------------------------

Comment (by jdgrimes):

 One way to prevent duplication between query classes (`WP_Query`, for
 example), and this API, would be to break each visibility restriction rule
 out into its own class. This class would have one method that could modify
 the query, and another one that could analyze a given object and tell
 whether it was publicly accessible (for the `is_thing_accessible()`
 function/API).

 Well, OK, I guess that doesn't necessarily reduce duplication, but it does
 centralize that duplication of logic that has to be applied differently in
 different circumstances. So when updating the logic for one of the
 circumstances (like a query), we'd be hard-pressed to forget to update the
 logic for the other scenario (object check) accordingly.

 There are then other cool possibilities, like having each rule provide a
 human-readable description of itself (another method on the rule object).
 Then we could tell a user why they couldn't view a particular post using
 this information. (If a plugin added an additional rule, that would
 automatically be incorporated.) Another use-case would be telling an admin
 that even though they can view a particular object, not everybody can,
 only users who this, this, and this. Though with that example, I guess I'm
 talking about this not being a user-agnostic boolean check again.

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


More information about the wp-trac mailing list