Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#21586 closed enhancement (fixed)

Telling register_post_type to not support anything

Reported by: sc0ttkclark Owned by: nacin
Priority: normal Milestone: 3.5
Component: Posts, Post Types Version:
Severity: minor Keywords: has-patch commit
Cc: Focuses:

Description

As the use of WP becomes more complex, post types are getting used in more interesting ways. This is evident by a use-case for passing an empty array to the 'supports' argument. Essentially, the Post Type becomes an object relatable to taxonomies and custom fields.

If an empty array() is sent (or any empty value), WordPress currently sets the defaults to 'title' and 'editor':

http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/post.php#L1020

I believe an alternate value should be able to passed such as false, where no defaults will get set. Currently, my work around is to pass an array, but place a faux value within it like '_placeholder'. This keeps the array from being empty and defaults set.

I'll have the patch ready by morning but feel free to provide any input positive/negative on this.

Attachments (2)

21520.patch (1.3 KB ) - added by markoheijnen 14 years ago.
21586.patch (586 bytes ) - added by sc0ttkclark 14 years ago.
Patch for the supports argument to be false, so as to not add support for the defaults

Download all attachments as: .zip

Change History (9)

#1 @sc0ttkclark
14 years ago

  • Cc lol@… added

My patch would basically contain a change to this line:

http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/post.php#L1023

} else {

to:

}
elseif ( false !== $args->supports ) {

#2 @markoheijnen
14 years ago

Had this once and inserted the string 'false' as a value what does work since it isn't existing.

Wouldn't it be better to have array('title', 'editor') in the defaults array. That will remove the if/else check.

@markoheijnen
14 years ago

#3 @sc0ttkclark
14 years ago

  • Keywords has-patch dev-feedback added

+1 on that Marko, I had over assumed based on existing code there was a reason not to accept an empty value. Hopefully there wasn't, your solution would be best IMO.

#4 @sc0ttkclark
14 years ago

  • Severity normalminor

Minor patch, changing to minor severity

#5 @nacin
14 years ago

  • Keywords commit added; dev-feedback removed
  • Milestone Awaiting Review3.5

I feel like the original purpose of a default was to use it only if no 'supports' arg was passed in at all. Setting array() should explicitly say "don't support anything."

That might break too much random code — so, false seems good for now.

@sc0ttkclark
14 years ago

Patch for the supports argument to be false, so as to not add support for the defaults

#7 @nacin
14 years ago

  • Owner set to nacin
  • Resolutionfixed
  • Status newclosed

In [21831]:

Allow supports => false to be passed to register_post_type() to disable the default title and editor.

An empty array may also disable all default features in the future.
Do not rely on this behavior: always specify title and editor if you want them.

props sc0ttkclark.
fixes #21586.

Note: See TracTickets for help on using tickets.