From 27d943786b0f62f98bb1144eb832b56475eb994d Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Thu, 29 Nov 2012 23:52:30 +0000 Subject: [PATCH] Introduce API to add back the description field in the new media popup. Props nacin fixes #22642 git-svn-id: http://core.svn.wordpress.org/trunk@22929 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/ajax-actions.php | 4 ++++ wp-admin/includes/media.php | 6 +++++- wp-includes/media.php | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php index 082888df07..6be0c86550 100644 --- a/wp-admin/includes/ajax-actions.php +++ b/wp-admin/includes/ajax-actions.php @@ -1899,6 +1899,10 @@ function wp_ajax_save_attachment_compat() { if ( 'attachment' != $post['post_type'] ) wp_send_json_error(); + // Handle the description field automatically, if a plugin adds it back. + if ( isset( $attachment_data['post_content'] ) ) + $post['post_content'] = $attachment_data['post_content']; + $post = apply_filters( 'attachment_fields_to_save', $post, $attachment_data ); if ( isset( $post['errors'] ) ) { diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index 2f7f318931..fac17f0f1c 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -1287,6 +1287,7 @@ function get_compat_media_markup( $attachment_id, $args = null ) { $default_args = array( 'errors' => null, 'taxonomies' => false, + 'description' => false, ); $args = wp_parse_args( $args, $default_args ); @@ -1325,9 +1326,12 @@ function get_compat_media_markup( $attachment_id, $args = null ) { $form_fields = apply_filters( 'attachment_fields_to_edit', $form_fields, $post ); unset( $form_fields['image-size'], $form_fields['align'], $form_fields['image_alt'], - $form_fields['post_title'], $form_fields['post_excerpt'], $form_fields['post_content'], + $form_fields['post_title'], $form_fields['post_excerpt'], $form_fields['url'], $form_fields['menu_order'], $form_fields['image_url'] ); + if ( ! $args['description'] ) + unset( $form_fields['post_content'] ); + $media_meta = apply_filters( 'media_meta', '', $post ); $defaults = array( diff --git a/wp-includes/media.php b/wp-includes/media.php index d203fd2429..57b4d845fd 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -1388,7 +1388,7 @@ function wp_prepare_attachment_for_js( $attachment ) { } if ( function_exists('get_compat_media_markup') ) - $response['compat'] = get_compat_media_markup( $attachment->ID, array( 'taxonomies' => true ) ); + $response['compat'] = get_compat_media_markup( $attachment->ID, array( 'taxonomies' => true, 'description' => true ) ); return apply_filters( 'wp_prepare_attachment_for_js', $response, $attachment, $meta ); }