[wp-trac] [WordPress Trac] #28683: Notify developers when register_post_type() fails because $post_type exceeds 20 characters

WordPress Trac noreply at wordpress.org
Sun Jun 29 20:59:15 UTC 2014


#28683: Notify developers when register_post_type() fails because $post_type
exceeds 20 characters
---------------------------------+-----------------------------
 Reporter:  mattheweppelsheimer  |      Owner:
     Type:  enhancement          |     Status:  new
 Priority:  normal               |  Milestone:  Awaiting Review
Component:  Posts, Post Types    |    Version:  3.1
 Severity:  normal               |   Keywords:
  Focuses:                       |
---------------------------------+-----------------------------
 `register_post_type()` parameter `$post_type` can't exceed 20 characters.
 The function returns a WP_Error if the limit is exceeded. Both the limit
 and the error are fairly well documented.

 This error is silent unless you think to check for it, which (anecdotally)
 seems uncommon in practice (for instance, example code on the Codex
 doesn't check the return result). This caused me a few hours of
 frustration before I figured it out, and seems to be a common pain point
 even amongst more experienced WP devs. There's definitely opportunity to
 further improve the PHPDoc for `register_post_type()`… but I don't think
 that will really resolve this pain point.

 When developers stumble into this silent failure, I'd like to us to notify
 them proactively, in a way that's harder to miss.

 Thoughts?

 FYI the WP_Error return result was introduced in 3.1. Hence the Version
 tag.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/28683>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list