Ticket #22642: 22642.3.diff

File 22642.3.diff, 2.1 KB (added by nacin, 6 months ago)
Line 
1Index: wp-includes/media.php
2===================================================================
3--- wp-includes/media.php       (revision 22925)
4+++ wp-includes/media.php       (working copy)
5@@ -1388,7 +1388,7 @@
6        }
7 
8        if ( function_exists('get_compat_media_markup') )
9-               $response['compat'] = get_compat_media_markup( $attachment->ID, array( 'taxonomies' => true ) );
10+               $response['compat'] = get_compat_media_markup( $attachment->ID, array( 'taxonomies' => true, 'description' => true ) );
11 
12        return apply_filters( 'wp_prepare_attachment_for_js', $response, $attachment, $meta );
13 }
14Index: wp-admin/includes/ajax-actions.php
15===================================================================
16--- wp-admin/includes/ajax-actions.php  (revision 22925)
17+++ wp-admin/includes/ajax-actions.php  (working copy)
18@@ -1899,6 +1899,10 @@
19        if ( 'attachment' != $post['post_type'] )
20                wp_send_json_error();
21 
22+       // Handle the description field automatically, if a plugin adds it back.
23+       if ( isset( $attachment_data['post_content'] ) )
24+               $post['post_content'] = $attachment_data['post_content'];
25+
26        $post = apply_filters( 'attachment_fields_to_save', $post, $attachment_data );
27 
28        if ( isset( $post['errors'] ) ) {
29Index: wp-admin/includes/media.php
30===================================================================
31--- wp-admin/includes/media.php (revision 22925)
32+++ wp-admin/includes/media.php (working copy)
33@@ -1287,6 +1287,7 @@
34        $default_args = array(
35                'errors' => null,
36                'taxonomies' => false,
37+               'description' => false,
38        );
39 
40        $args = wp_parse_args( $args, $default_args );
41@@ -1325,9 +1326,12 @@
42        $form_fields = apply_filters( 'attachment_fields_to_edit', $form_fields, $post );
43 
44        unset( $form_fields['image-size'], $form_fields['align'], $form_fields['image_alt'],
45-               $form_fields['post_title'], $form_fields['post_excerpt'], $form_fields['post_content'],
46+               $form_fields['post_title'], $form_fields['post_excerpt'],
47                $form_fields['url'], $form_fields['menu_order'], $form_fields['image_url'] );
48 
49+       if ( ! $args['description'] )
50+               unset( $form_fields['post_content'] );
51+
52        $media_meta = apply_filters( 'media_meta', '', $post );
53 
54        $defaults = array(