[wp-trac] [WordPress Trac] #20046: Unnecessary default category code remains in wp_insert_attachment

WordPress Trac noreply at wordpress.org
Thu May 22 20:35:34 UTC 2014


#20046: Unnecessary default category code remains in wp_insert_attachment
-----------------------------------------+------------------------------
 Reporter:  jeremyfelt                   |       Owner:
     Type:  enhancement                  |      Status:  new
 Priority:  normal                       |   Milestone:  Awaiting Review
Component:  Media                        |     Version:  2.0
 Severity:  trivial                      |  Resolution:
 Keywords:  has-patch reporter-feedback  |     Focuses:
-----------------------------------------+------------------------------
Changes (by ericlewis):

 * keywords:  has-patch => has-patch reporter-feedback
 * version:   => 2.0


Comment:

 Consider the following.

 I for some reason want categories to apply to attachments. So, I add this
 code somewhere (functions.php, mu-plugin, plugin, pick your poison):

 {{{
 #!php
 add_action( 'init', function() {
         register_taxonomy_for_object_type( 'category', 'attachment' );
 });
 }}}

 I then set the category while creating an attachment somewhere else:

 {{{
 #!php
 wp_insert_attachment(
         array( 'post_status' => 'publish',
                 'post_title' => 'Robin Williams dancing to Thriller with
 Jim Carrey',
                 'post_category' => array( 3, 5 ) ) );
 }}}

 The code that's on the chopping block here will be needed to cover this
 edge case. Suggest a close here as wontfix. @jeremyfelt, thoughts?

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


More information about the wp-trac mailing list