[wp-trac] [WordPress Trac] #22186: Backwards compatibility for admin/includes/media.php hooks

WordPress Trac noreply at wordpress.org
Sat Nov 10 20:33:01 UTC 2012


#22186: Backwards compatibility for admin/includes/media.php hooks
--------------------------+------------------
 Reporter:  nacin         |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  high          |   Milestone:  3.5
Component:  Media         |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+------------------

Comment (by nacin):

 [attachment:22186.diff] is an attempt at providing a framework for making
 attachment_fields_to_edit and _save backwards compatible in some way.
 Here's some random testing code. Fire this up in 3.4 to see it in action
 when editing a media item from the Library.

 {{{

 add_filter( 'attachment_fields_to_edit', function( $fields, $post ) {
         $fields['nacin_menu_order']['label'] = 'Nacin Order (cannot be
 42)';
         $fields['nacin_menu_order']['value'] = $post->menu_order;
         return $fields;
 }, 10, 2 );

 add_filter( 'attachment_fields_to_save', function( $post, $attachment ) {
         if ( isset( $attachment['nacin_menu_order'] ) ) {
                 if ( $attachment['nacin_menu_order'] == '42' )
                         $post['errors']['nacin_menu_order']['errors'][] =
 'Nacin order cannot be 42.';
                 else
                         $post['menu_order'] =
 $attachment['nacin_menu_order'];
         }
         return $post;
 }, 10, 2 );
 }}}

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


More information about the wp-trac mailing list