[wp-trac] [WordPress Trac] #36579: global $wp_rewrite not set when create_initial_post_types() first run

WordPress Trac noreply at wordpress.org
Mon Apr 18 17:59:20 UTC 2016


#36579: global $wp_rewrite not set when create_initial_post_types() first run
-------------------------------+-----------------------------
 Reporter:  bobbingwide        |      Owner:
     Type:  enhancement        |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  4.4
 Severity:  normal             |   Keywords:
  Focuses:                     |
-------------------------------+-----------------------------
 The global $wp_rewrite is set in wp-settings.php, after
 create_initial_post_types().

 If you want to hook into the 'register_post_type_args' filter, to set
 `$args->rewrite` then you currently have to jump through hoops to avoid an
 `Uncaught error Call to a member function add_rewrite_tag() on null`


 Could the call to set `$GLOBALS['wp_rewrite']` be moved to before
 `create_initial_post_types()`?
 Or perhaps some defensive programming in `rewrite.php` to test if
 $wp_rewrite is set.
 Functions `add_rewrite_tag` and `add_permastruct` are candidates for that
 change.

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


More information about the wp-trac mailing list