[wp-trac] [WordPress Trac] #15779: Can't add featured images to custom post types

WordPress Trac wp-trac at lists.automattic.com
Sun Dec 12 20:53:53 UTC 2010


#15779: Can't add featured images to custom post types
-----------------------------+----------------------------------------------
 Reporter:  somatic          |       Owner:  nacin            
     Type:  defect (bug)     |      Status:  reviewing        
 Priority:  normal           |   Milestone:  3.1              
Component:  Post Thumbnails  |     Version:  3.1              
 Severity:  critical         |    Keywords:  reporter-feedback
-----------------------------+----------------------------------------------
Changes (by somatic):

 * cc: israel@… (added)


Comment:

 So I went digging for what's different about custom post type capabilities
 in 3.1, and discovered that I can solve the featured image "-1" error
 problem without changing wp-admin/admin-ajax.php.

 I got rid of this code:

 {{{
         'capabilities' => array(
                 'publish_posts' => 'publish_videos',
                 'edit_posts' => 'edit_videos',
                 'edit_others_posts' => 'edit_others_videos',
                 'delete_posts' => 'delete_videos',
                 'delete_others_posts' => 'delete_others_videos',
                 'read_private_posts' => 'read_private_videos',
                 'edit_post' => 'edit_video',
                 'delete_post' => 'delete_video',
                 'read_post' => 'read_video',
         ),
 }}}

 and added the new

 {{{
 'map_meta_cap' => true,
 }}}

  to my args for register_post_type(), which the new docs say controls
 "Whether to use the internal default meta capability handling". This made
 me wonder if I needed justin tadlocks custom map_meta_cap filter anymore,
 so I disabled that as well.

 So basically, it would seem that the 3.0 behavior for CPT required a lot
 more specificity, both in the capabilities array and the map_meta_cap.
 Though I don't know where exactly, 3.1 appears to take care of all that
 automatically, so I can simply declare in the CPT args:

 {{{
 'capability_type' => 'video',
 'map_meta_cap' => true,
 'has_archive' => 'videos',
 }}}

 I'm not sure how, but there should be a notice somewhere about how the
 code needed to make CPT's capabilities work properly in 3.0 actually
 *breaks* functionality in 3.1.

 I'm also not 100% sure that these using these new args (and deleting the
 old 3.0 ones) isn't going to break something else... got to test some
 more...

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


More information about the wp-trac mailing list