[wp-trac] [WordPress Trac] #48166: Cannot create a new CPT when passing NULL to taxonomies

WordPress Trac noreply at wordpress.org
Thu Oct 3 00:49:57 UTC 2019


#48166: Cannot create a new CPT when passing NULL to taxonomies
-------------------------------+----------------------
 Reporter:  scarr              |       Owner:  (none)
     Type:  defect (bug)       |      Status:  closed
 Priority:  normal             |   Milestone:
Component:  Posts, Post Types  |     Version:  5.2.3
 Severity:  normal             |  Resolution:  invalid
 Keywords:  has-patch          |     Focuses:
-------------------------------+----------------------

Comment (by jrf):

 Replying to [comment:7 scarr]:
 > Hey, thanks for the encouraging feedback. I'll be sure to jump in to
 help again!
 >
 > Perhaps, if the code was a bit better from a best practices perspective,
 you wouldn't have your time wasted by people like me who "should just read
 the documentation."
 >

 Sorry you feel that way.

 Just to clarify though: Trac is for bugs and feature requests, not for
 user (as you state: developers for WP are also users) support questions.

 Your point is a perfectly valid support question for the forums, but it's
 not a valid bug report.

 So based on where you post, you will get a different response.

 > Your code...

 Let me stop you right here: this is not "my" code. This is the WP Core
 code which is created and maintained by hundreds of people.

 The code has historically evolved and carries part of that history with
 it.

 Please do not ''attack'' individual developers over the state of the WP
 code base as it is offensive when you do.

 P.S.: believe me, if it was ''my'' code, it would look very different...


 >  If I don’t want to declare taxonomies inside a cpt declaration, why
 should I have to memorize the fact that the parameter still needs to be
 set?

 You don't.

 You don't need to remember it and it doesn't need to be set.

 The `$args` parameter in `register_post_type()` is optional and ''every
 single array index'' within this optional array is, again, optional.

 See:
 https://developer.wordpress.org/reference/functions/register_post_type/


 > Doesn’t it make equal sense to have your customer (the developer) simply
 ignore setting the parameter all together in that case? You know, make it
 optional, like you do so many other parameters in WordPress.

 It already is and will default to an empty array.

 See: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-
 wp-post-type.php#L409


 > Your “public function”, register_taxonomies, ...

 I'd guess that the only reason that function is `public` is because it
 came from PHP4 which didn't have visibility indicators, though I have to
 admit I've not traced back the history of the class.
 If my guess is right, changing the visibility on previously published
 classes like that is a backward-compatibility break which is something WP
 strenuously tries to avoid...

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48166#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list