WordPress.org

Make WordPress Core

Opened 7 weeks ago

Last modified 5 weeks ago

#54055 new defect (bug)

Add visibility field to Post type controller

Reported by: spacedmonkey Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: REST API Keywords: has-patch has-unit-tests
Focuses: rest-api Cc:

Description

Original ticket from gutenberg repo 34443.

Add a new field to the Post types REST API controller called visibility. This field would be work similarly to the visibility field found in the taxonomy REST API controller.

Change History (8)

This ticket was mentioned in PR #1650 on WordPress/wordpress-develop by spacedmonkey.


7 weeks ago

  • Keywords has-patch added

#2 @spacedmonkey
7 weeks ago

  • Keywords has-unit-tests added

There are now some basic unit tests that pass.

#3 @prbot
7 weeks ago

TimothyBJacobs commented on PR #1650:

We may want to look at is_post_type_viewable.

#5 @prbot
6 weeks ago

TimothyBJacobs commented on PR #1650:

Ah, my mistake. So should we still be exposing public and publicly_queryable then?

#6 @prbot
6 weeks ago

peterwilsoncc commented on PR #1650:

So should we still be exposing public and publicly_queryable then?

public should probably not be exposed, it's pretty meaningless. A post type can be public without being viewable by registering a CPT with these arguments:

{{{php
[

'public' => true,
'exclude_from_search' => true,
'publicly_queryable' => false,
'show_in_nav_menus' => false,
'show_ui' => false,
'show_in_rest' => false,

]
}}}

publicly_queryable is of more use as it's what determines if a post type is viewable for CPTs but going via the helper function is_post_type_viewable() is the safest result.

#7 @prbot
5 weeks ago

spacedmonkey commented on PR #1650:

@peterwilsoncc Good catch. I have removed it now.

#8 @prbot
5 weeks ago

TimothyBJacobs commented on PR #1650:

We should be ditching publicly_queryable as well then, right? Since we are already exposing the correct computed value?

Note: See TracTickets for help on using tickets.