Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#54055 closed enhancement (fixed)

Add visibility field to Post type controller

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

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 (11)

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


5 years ago
#1

  • Keywords has-patch added

#2 @spacedmonkey
5 years ago

  • Keywords has-unit-tests added

There are now some basic unit tests that pass.

​TimothyBJacobs commented on ​PR #1650:


5 years ago
#3

We may want to look at is_post_type_viewable.

​TimothyBJacobs commented on ​PR #1650:


5 years ago
#5

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

​peterwilsoncc commented on ​PR #1650:


5 years ago
#6

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.

​spacedmonkey commented on ​PR #1650:


5 years ago
#7

@peterwilsoncc Good catch. I have removed it now.

​TimothyBJacobs commented on ​PR #1650:


5 years ago
#8

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

#9 @TimothyBlynJacobs
5 years ago

  • Milestone Awaiting Review → 5.9
  • Owner set to TimothyBlynJacobs
  • Status new → accepted
  • Type defect (bug) → enhancement
  • Version → 4.7

#10 @TimothyBlynJacobs
5 years ago

  • Resolution → fixed
  • Status accepted → closed

In 51959:

REST API: Add visibility information to the Post Types controller.

Props spacedmonkey, peterwilsoncc.
Fixes #54055.

Note: See TracTickets for help on using tickets.