Ticket #22400: 22400.media.php.diff
File 22400.media.php.diff, 5.0 KB (added by , 8 years ago) |
---|
-
wp-admin/includes/media.php
1064 1064 $default_args = array( 'errors' => null, 'send' => $current_post_id ? post_type_supports( get_post_type( $current_post_id ), 'editor' ) : true, 'delete' => true, 'toggle' => true, 'show_title' => true ); 1065 1065 $args = wp_parse_args( $args, $default_args ); 1066 1066 $args = apply_filters( 'get_media_item_args', $args ); 1067 extract( $args, EXTR_SKIP );1068 1067 1069 1068 $toggle_on = __( 'Show' ); 1070 1069 $toggle_off = __( 'Hide' ); … … 1083 1082 $type = array_shift( $keys ); 1084 1083 $type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />"; 1085 1084 1086 $form_fields = get_attachment_fields_to_edit( $post, $ errors);1085 $form_fields = get_attachment_fields_to_edit( $post, $args['errors'] ); 1087 1086 1088 if ( $ toggle) {1089 $class = empty( $ errors) ? 'startclosed' : 'startopen';1087 if ( $args['toggle'] ) { 1088 $class = empty( $args['errors'] ) ? 'startclosed' : 'startopen'; 1090 1089 $toggle_links = " 1091 1090 <a class='toggle describe-toggle-on' href='#'>$toggle_on</a> 1092 1091 <a class='toggle describe-toggle-off' href='#'>$toggle_off</a>"; … … 1096 1095 } 1097 1096 1098 1097 $display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case 1099 $display_title = $ show_title? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60 ) . "</span></div>" : '';1098 $display_title = $args['show_title'] ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60 ) . "</span></div>" : ''; 1100 1099 1101 1100 $gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) ); 1102 1101 $order = ''; … … 1161 1160 'extra_rows' => array(), 1162 1161 ); 1163 1162 1164 if ( $ send)1165 $ send= get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false );1166 if ( $ delete&& current_user_can( 'delete_post', $attachment_id ) ) {1163 if ( $args['send'] ) 1164 $args['send'] = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false ); 1165 if ( $args['delete'] && current_user_can( 'delete_post', $attachment_id ) ) { 1167 1166 if ( !EMPTY_TRASH_DAYS ) { 1168 $ delete= "<a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete-permanently'>" . __( 'Delete Permanently' ) . '</a>';1167 $args['delete'] = "<a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete-permanently'>" . __( 'Delete Permanently' ) . '</a>'; 1169 1168 } elseif ( !MEDIA_TRASH ) { 1170 $ delete= "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a>1169 $args['delete'] = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a> 1171 1170 <div id='del_attachment_$attachment_id' class='del-attachment' style='display:none;'><p>" . sprintf( __( 'You are about to delete <strong>%s</strong>.' ), $filename ) . "</p> 1172 1171 <a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='button'>" . __( 'Continue' ) . "</a> 1173 1172 <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a> 1174 1173 </div>"; 1175 1174 } else { 1176 $ delete= "<a href='" . wp_nonce_url( "post.php?action=trash&post=$attachment_id", 'trash-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Move to Trash' ) . "</a>1175 $args['delete'] = "<a href='" . wp_nonce_url( "post.php?action=trash&post=$attachment_id", 'trash-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Move to Trash' ) . "</a> 1177 1176 <a href='" . wp_nonce_url( "post.php?action=untrash&post=$attachment_id", 'untrash-post_' . $attachment_id ) . "' id='undo[$attachment_id]' class='undo hidden'>" . __( 'Undo' ) . "</a>"; 1178 1177 } 1179 1178 } else { 1180 $ delete= '';1179 $args['delete'] = ''; 1181 1180 } 1182 1181 1183 1182 $thumbnail = ''; … … 1192 1191 $thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" . $attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\", \"$ajax_nonce\");return false;'>" . esc_html__( "Use as featured image" ) . "</a>"; 1193 1192 } 1194 1193 1195 if ( ( $ send || $thumbnail || $delete) && !isset( $form_fields['buttons'] ) )1196 $form_fields['buttons'] = array( 'tr' => "\t\t<tr class='submit'><td></td><td class='savesend'> $send $thumbnail $delete</td></tr>\n" );1194 if ( ( $args['send'] || $thumbnail || $args['delete'] ) && !isset( $form_fields['buttons'] ) ) 1195 $form_fields['buttons'] = array( 'tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>". $args['send'] . $thumbnail . $args['delete'] ."</td></tr>\n" ); 1197 1196 1198 1197 $hidden_fields = array(); 1199 1198