[wp-trac] [WordPress Trac] #21943: register_post_type() expect array but should object as well

WordPress Trac wp-trac at lists.automattic.com
Thu Sep 20 18:49:03 UTC 2012


#21943: register_post_type() expect array but should object as well
-------------------------+-----------------------
 Reporter:  thomask      |       Owner:
     Type:  enhancement  |      Status:  reopened
 Priority:  normal       |   Milestone:
Component:  Post Types   |     Version:  trunk
 Severity:  normal       |  Resolution:
 Keywords:               |
-------------------------+-----------------------
Changes (by thomask):

 * status:  closed => reopened
 * resolution:  wontfix =>


Comment:

 register_post_type does not passing anything by reference.

 I will explain, why i think it is necessary, but maybe you will tell me
 there is an easier way:

 I wanted to change some arguments of buid-in post_types.
 There is no update_post_type etc. function, the only way i know is to take
 the existing post type, change what you want and then reregister it. Only
 this way it is registered properly, i cannot change only the
 $wp_post_type.

 here is my code:

 {{{
       global $wp_post_types;
       $wp_post_types['post']->has_archive = true;
       $wp_post_types['post']->rewrite     = array (
                                               'enabled' => '1',
                                               'feeds' => true,
                                               'pages' => true,
                                               'with_front' => false,
                                               'slug' => 'clanky',
                                               'ep_mask' => 1,
                                             );
       $post_type = $wp_post_types['post'];
       foreach ($post_type as &$arg) {
               if (is_object($arg)) $arg = array($arg);
       }
       register_post_type( 'post', (array) $post_type );
 }}}

 I think, that someone may need it in the future and this obstruction is
 realy pointless. If there would be e.g. easy (array) casting for the
 labels and cap, it would not harm anyone.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21943#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list