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

WordPress Trac wp-trac at lists.automattic.com
Fri Dec 17 11:42:03 UTC 2010


#15847: Add filter in wp_insert_attachment for $data
----------------------------+-----------------------------
 Reporter:  pampfelimetten  |       Owner:
     Type:  enhancement     |      Status:  new
 Priority:  normal          |   Milestone:  Future Release
Component:  Plugins         |     Version:  3.0.3
 Severity:  normal          |  Resolution:
 Keywords:                  |
----------------------------+-----------------------------
Changes (by westi):

 * milestone:  Awaiting Review => Future Release


Comment:

 Replying to [comment:3 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.

 Ok.

 So a filter here would work for you.

 But maybe a more generic filter on all post_names would be better and
 easier for you to use?

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


More information about the wp-trac mailing list