[wp-trac] [WordPress Trac] #22759: attachment_fields_to_edit should have flags for when to show the field

WordPress Trac noreply at wordpress.org
Wed Dec 5 18:58:33 UTC 2012


#22759: attachment_fields_to_edit should have flags for when to show the field
--------------------------+------------------------------
 Reporter:  helenyhou     |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Media         |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+------------------------------

Comment (by helenyhou):

 [attachment:22759.diff] is a pass at defining some flags. These work with
 compat only, as in all the magic happens in `get_compat_media_markup()`,
 so effective only for new media.

 Example code to check the magic:

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

 add_filter( 'attachment_fields_to_edit', 'hhs_attachment_fields_to_edit',
 10, 2 );
 function hhs_attachment_fields_to_edit( $fields, $post ) {
         if ( isset( $fields['category'] ) )
                 $fields['category']['show_in_modal'] = false;

         $fields['test-media-item'] = array(
                 'label' => 'More Media Management',
                 'input' => 'html',
                 'html' => '<a href="#">Link One</a><br /><a href="#">Link
 Two</a>',
                 'show_in_edit' => false,
         );

         return $fields;
 }
 }}}

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


More information about the wp-trac mailing list