[wp-trac] [WordPress Trac] #15847: Add filter in wp_insert_attachment for $data

WordPress Trac wp-trac at lists.automattic.com
Fri Dec 17 09:26:24 UTC 2010


#15847: Add filter in wp_insert_attachment for $data
----------------------------+------------------------------
 Reporter:  pampfelimetten  |       Owner:
     Type:  enhancement     |      Status:  new
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  Plugins         |     Version:  3.0.3
 Severity:  normal          |  Resolution:
 Keywords:                  |
----------------------------+------------------------------

Comment (by pampfelimetten):

 @scribu: I basically looked at wp_insert_post, where it uses the same
 order:
 {{{
         $data = compact( array(...);
         $data = apply_filters('wp_insert_post_data', $data, $postarr);
         $data = stripslashes_deep( $data );
 }}}

 @westi: On the one hand, there's a similar filter in wp_insert_post, but
 not in wp_insert_attachment. That's odd, I can't see a reason for that.
 Particularly, I want to check the post_name field of the attachment before
 it get's entered in the db. The reason is, I want to avoid numeric-only
 post_names, as it interferes with my non-standard permalinks (%post_id%
 only). I've been looking into all the functions, and there are no hooks at
 all to do that, so I figured it would be easiest to just copy the
 behaviour of wp_insert_post and modifiy the data there before it gets
 handed to the sanitize functions.

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


More information about the wp-trac mailing list