WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#13843 closed enhancement (wontfix)

post_type_supports() returns true when $_wp_post_type_features['post_type']['feature'] is set but false

Reported by: linguasite Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: 2nd-opinion
Focuses: Cc:

Description

Wouldn't it be safer to ask for a true value before returning true?

I had to change a capability manually and did this by directly changing the relevant value to false (without using remove_post_type_support for some reason).
post_type_supports() still returned true then.

wp-includes/post.php line 1031

Change History (4)

comment:1 kevinB4 years ago

  • Cc kevinB added

comment:2 follow-up: nacin3 years ago

  • Keywords 2nd-opinion added

You should use remove_post_type_support(). Modifying the internal array is not supported. Via add_post_type_support(), it will always equal either true, or an array. We could check for === false there, but I don't think we should need to. It's set, that's what matters. The "true" is just to have a value there (as with pluggable arg checking, it could be more than just "true").

comment:3 in reply to: ↑ 2 linguasite3 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

Thanks nacin, you are absolutely right.
I did some experiments and stumbled upon this phenomenon.

comment:4 nacin3 years ago

  • Milestone Awaiting Review deleted

Cheers.

Note: See TracTickets for help on using tickets.