Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#54055 closed enhancement (fixed)

Add visibility field to Post type controller

Reported by: spacedmonkey's profile spacedmonkey Owned by: timothyblynjacobs's profile TimothyBlynJacobs
Milestone: 5.9 Priority: normal
Severity: normal Version: 4.7
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 (11)

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


3 years ago
#1

  • Keywords has-patch added

#2 @spacedmonkey
3 years ago

  • Keywords has-unit-tests added

There are now some basic unit tests that pass.

TimothyBJacobs commented on PR #1650:


3 years ago
#3

We may want to look at is_post_type_viewable.

TimothyBJacobs commented on PR #1650:


3 years ago
#5

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

peterwilsoncc commented on PR #1650:


3 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:


3 years ago
#7

@peterwilsoncc Good catch. I have removed it now.

TimothyBJacobs commented on PR #1650:


3 years ago
#8

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

#9 @TimothyBlynJacobs
3 years ago

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

#10 @TimothyBlynJacobs
3 years ago

  • Resolution set to fixed
  • Status changed from accepted to 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.