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
This commit is contained in:
Ryan Boren 2012-11-29 23:52:30 +00:00
parent 626778aaf0
commit 27d943786b
3 changed files with 10 additions and 2 deletions

View File

@ -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'] ) ) {

View File

@ -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(

View File

@ -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 );
}