[wp-trac] [WordPress Trac] #38766: Post type templates ignore the last post type if there is a trailing full stop.

WordPress Trac noreply at wordpress.org
Sun Nov 13 23:55:48 UTC 2016


#38766: Post type templates ignore the last post type if there is a trailing full
stop.
-------------------------------------------------+-------------------------
 Reporter:  peterwilsoncc                        |       Owner:
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  4.7
Component:  Posts, Post Types                    |     Version:  trunk
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-refresh needs-unit-  |     Focuses:  template
  tests                                          |
-------------------------------------------------+-------------------------
Changes (by pento):

 * keywords:  has-patch has-unit-tests 2nd-opinion => has-patch needs-
     refresh needs-unit-tests


Comment:

 Some things:

 * If we're going to change how this works, I think the correct way would
 be to use `sanitize_key()` on the post type, the same as
 `register_post_type()` does. So, instead of `$type = trim( $type );`, have
 `$type = sanitize_key( $type );`. That removes the need for changing the
 regex.
 * The tests don't test for trailing spaces. The tests could probably be
 expanded to test for other invalid characters.
 * The `U` modifier (invert greediness) is not the same as  the `u`
 modifier (UTF-8 compatibility). The former is incorrect, and we don't need
 to use the latter, as only a subset of ASCII characters are allowed in
 post types.

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


More information about the wp-trac mailing list