Changeset 12543
- Timestamp:
- 12/25/2009 11:04:48 PM (16 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 2 edited
-
includes/media.php (modified) (14 diffs)
-
media.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/media.php
r12542 r12543 1019 1019 1020 1020 $edit_post = sanitize_post($post, 'edit'); 1021 1022 1021 1023 1022 1024 $form_fields = array( … … 1132 1134 global $redir_tab; 1133 1135 1134 if ( ( $attachment_id = intval( $attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) )1136 if ( ( $attachment_id = intval( $attachment_id ) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) ) 1135 1137 $thumb_url = $thumb_url[0]; 1136 1138 else … … 1141 1143 extract( $args, EXTR_SKIP ); 1142 1144 1143 $toggle_on = __('Show');1144 $toggle_off = __( 'Hide');1145 1146 $post = get_post( $attachment_id);1147 1148 $filename = basename( $post->guid);1149 $title = esc_attr( $post->post_title);1150 1151 if ( $_tags = get_the_tags( $attachment_id) ) {1145 $toggle_on = __( 'Show' ); 1146 $toggle_off = __( 'Hide' ); 1147 1148 $post = get_post( $attachment_id ); 1149 1150 $filename = basename( $post->guid ); 1151 $title = esc_attr( $post->post_title ); 1152 1153 if ( $_tags = get_the_tags( $attachment_id ) ) { 1152 1154 foreach ( $_tags as $tag ) 1153 1155 $tags[] = $tag->name; 1154 $tags = esc_attr( join(', ', $tags));1156 $tags = esc_attr( join( ', ', $tags ) ); 1155 1157 } 1156 1158 1157 1159 $post_mime_types = get_post_mime_types(); 1158 $keys = array_keys( wp_match_mime_types(array_keys($post_mime_types), $post->post_mime_type));1159 $type = array_shift( $keys);1160 $keys = array_keys( wp_match_mime_types( array_keys( $post_mime_types ), $post->post_mime_type ) ); 1161 $type = array_shift( $keys ); 1160 1162 $type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />"; 1161 1163 1162 $form_fields = get_attachment_fields_to_edit( $post, $errors);1164 $form_fields = get_attachment_fields_to_edit( $post, $errors ); 1163 1165 1164 1166 if ( $toggle ) { 1165 $class = empty( $errors) ? 'startclosed' : 'startopen';1167 $class = empty( $errors ) ? 'startclosed' : 'startopen'; 1166 1168 $toggle_links = " 1167 1169 <a class='toggle describe-toggle-on' href='#'>$toggle_on</a> … … 1173 1175 1174 1176 $display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case 1175 $display_title = $show_title ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60) . "</span></div>" : '';1176 1177 $gallery = ( ( isset($_REQUEST['tab']) && 'gallery' == $_REQUEST['tab']) || (isset($redir_tab) && 'gallery' == $redir_tab) ) ? true : false;1177 $display_title = $show_title ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60 ) . "</span></div>" : ''; 1178 1179 $gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) ) ? true : false; 1178 1180 $order = ''; 1179 1181 … … 1181 1183 if ( 'menu_order' == $key ) { 1182 1184 if ( $gallery ) 1183 $order = '<div class="menu_order"> <input class="menu_order_input" type="text" id="attachments['.$attachment_id.'][menu_order]" name="attachments['.$attachment_id.'][menu_order]" value="'.$val['value'].'" /></div>';1185 $order = "<div class='menu_order'> <input class='menu_order_input' type='text' id='attachments[$attachment_id][menu_order]' name='attachments[$attachment_id][menu_order]' value='" . esc_attr( $val['value'] ). "' /></div>"; 1184 1186 else 1185 $order = '<input type="hidden" name="attachments['.$attachment_id.'][menu_order]" value="'.$val['value'].'" />';1186 1187 unset( $form_fields['menu_order']);1187 $order = "<input type='hidden' name='attachments[$attachment_id][menu_order]' value='" . esc_attr( $val['value'] ) . "' />"; 1188 1189 unset( $form_fields['menu_order'] ); 1188 1190 break; 1189 1191 } … … 1191 1193 1192 1194 $media_dims = ''; 1193 $meta = wp_get_attachment_metadata( $post->ID);1194 if ( is_array( $meta) && array_key_exists('width', $meta) && array_key_exists('height', $meta) )1195 $media_dims .= "<span id='media-dims- {$post->ID}'>{$meta['width']} × {$meta['height']}</span> ";1196 $media_dims = apply_filters( 'media_meta', $media_dims, $post);1195 $meta = wp_get_attachment_metadata( $post->ID ); 1196 if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) ) 1197 $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> "; 1198 $media_dims = apply_filters( 'media_meta', $media_dims, $post ); 1197 1199 1198 1200 $image_edit_button = ''; 1199 if ( gd_edit_image_support( $post->post_mime_type) ) {1200 $nonce = wp_create_nonce( "image_editor-$post->ID");1201 $image_edit_button = "<input type='button' id='imgedit-open-btn- {$post->ID}' onclick='imageEdit.open($post->ID, \"$nonce\")' class='button' value='" . esc_attr__( 'Edit image' ) . "' /> <img src='images/wpspin_light.gif' class='imgedit-wait-spin' alt='' />";1201 if ( gd_edit_image_support( $post->post_mime_type ) ) { 1202 $nonce = wp_create_nonce( "image_editor-$post->ID" ); 1203 $image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit image' ) . "' /> <img src='images/wpspin_light.gif' class='imgedit-wait-spin' alt='' />"; 1202 1204 } 1203 1205 … … 1211 1213 <table class='slidetoggle describe $class'> 1212 1214 <thead class='media-item-info' id='media-head-$post->ID'> 1213 <tr> 1214 <td class='A1B1' id='thumbnail-head-$post->ID' rowspan='5'> 1215 <a href='$attachment_url' target='_blank'><img class='thumbnail' src='$thumb_url' alt='' /></a> 1215 <tr valign='top'> 1216 <td class='A1B1' id='thumbnail-head-$post->ID'> 1217 <p><a href='$attachment_url' target='_blank'><img class='thumbnail' src='$thumb_url' alt='' style='margin-top: 3px' /></a></p> 1218 <p>$image_edit_button</p> 1216 1219 </td> 1217 <td><strong>" . __('File name:') . "</strong> $filename</td> 1218 </tr> 1219 <tr><td><strong>" . __('File type:') . "</strong> $post->post_mime_type</td></tr> 1220 <tr><td><strong>" . __('Upload date:') . "</strong> " . mysql2date( get_option('date_format'), $post->post_date ) . "</td></tr>\n"; 1221 1222 if ( !empty($media_dims) ) 1223 $item .= "<tr><td><strong>" . __('Dimensions:') . "</strong> $media_dims</td></tr>\n"; 1220 <td> 1221 <p><strong>" . __('File name:') . "</strong> $filename</p> 1222 <p><strong>" . __('File type:') . "</strong> $post->post_mime_type</p> 1223 <p><strong>" . __('Upload date:') . "</strong> " . mysql2date( get_option('date_format'), $post->post_date ). '</p>'; 1224 if ( !empty( $media_dims ) ) 1225 $item .= "<p><strong>" . __('Dimensions:') . "</strong> $media_dims</p>\n"; 1226 1227 echo "</td></tr>\n"; 1228 1229 1224 1230 1225 1231 $item .= " 1226 <tr><td class='A1B1'>$image_edit_button</td></tr>1227 1232 </thead> 1228 1233 <tbody> … … 1239 1244 if ( $send ) 1240 1245 $send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . esc_attr__( 'Insert into Post' ) . "' />"; 1241 if ( $delete && current_user_can( 'delete_post', $attachment_id) ) {1246 if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) { 1242 1247 if ( !EMPTY_TRASH_DAYS ) { 1243 $delete = "<a href= \"" . wp_nonce_url("post.php?action=delete&post=$attachment_id", 'delete-post_' . $attachment_id) . "\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Delete Permanently') . "</a>";1248 $delete = "<a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Delete Permanently' ) . '</a>'; 1244 1249 } elseif ( !MEDIA_TRASH ) { 1245 $delete = "<a href=\"#\" class=\"del-link\" onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __('Delete') . "</a> <div id=\"del_attachment_$attachment_id\" class=\"del-attachment\" style=\"display:none;\">" . sprintf(__("You are about to delete <strong>%s</strong>."), $filename) . " <a href=\"" . wp_nonce_url("post.php?action=delete&post=$attachment_id", 'delete-post_' . $attachment_id) . "\" id=\"del[$attachment_id]\" class=\"button\">" . __('Continue') . "</a> <a href=\"#\" class=\"button\" onclick=\"this.parentNode.style.display='none';return false;\">" . __('Cancel') . "</a></div>"; 1250 $delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a> 1251 <div id='del_attachment_$attachment_id' class='del-attachment' style='display:none;'>" . sprintf( __( 'You are about to delete <strong>%s</strong>.' ), $filename ) . " 1252 <a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='button'>" . __( 'Continue' ) . "</a> 1253 <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a> 1254 </div>"; 1246 1255 } else { 1247 $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> <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>"; 1256 $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> 1257 <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>"; 1248 1258 } 1249 1259 } else { … … 1260 1270 $thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" . $attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\");return false;'>" . esc_html__( "Use as thumbnail" ) . "</a>"; 1261 1271 1262 if ( ( $send || $thumbnail || $delete ) && !isset( $form_fields['buttons']) )1263 $form_fields['buttons'] = array( 'tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $thumbnail $delete</td></tr>\n");1272 if ( ( $send || $thumbnail || $delete ) && !isset( $form_fields['buttons'] ) ) 1273 $form_fields['buttons'] = array( 'tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $thumbnail $delete</td></tr>\n" ); 1264 1274 1265 1275 $hidden_fields = array(); … … 1269 1279 continue; 1270 1280 1271 if ( !empty( $field['tr']) ) {1281 if ( !empty( $field['tr'] ) ) { 1272 1282 $item .= $field['tr']; 1273 1283 continue; 1274 1284 } 1275 1285 1276 $field = array_merge( $defaults, $field);1286 $field = array_merge( $defaults, $field ); 1277 1287 $name = "attachments[$attachment_id][$id]"; 1278 1288 … … 1282 1292 } 1283 1293 1284 $required = $field['required'] ? '<abbr title="required" class="required">*</abbr>' : '';1294 $required = $field['required'] ? '<abbr title="required" class="required">*</abbr>' : ''; 1285 1295 $aria_required = $field['required'] ? " aria-required='true' " : ''; 1286 1296 $class = $id; … … 1288 1298 1289 1299 $item .= "\t\t<tr class='$class'>\n\t\t\t<th valign='top' scope='row' class='label'><label for='$name'><span class='alignleft'>{$field['label']}</span><span class='alignright'>$required</span><br class='clear' /></label></th>\n\t\t\t<td class='field'>"; 1290 if ( !empty( $field[$field['input']]) )1291 $item .= $field[ $field['input']];1300 if ( !empty( $field[ $field['input'] ] ) ) 1301 $item .= $field[ $field['input'] ]; 1292 1302 elseif ( $field['input'] == 'textarea' ) { 1293 $item .= "<textarea type='text' id='$name' name='$name' " . $aria_required . ">" . esc_html( $field['value'] ) . "</textarea>";1303 $item .= "<textarea type='text' id='$name' name='$name' $aria_required>" . esc_html( $field['value'] ) . '</textarea>'; 1294 1304 } else { 1295 $item .= "<input type='text' class='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "' " . $aria_required . "/>";1305 $item .= "<input type='text' class='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "' $aria_required />"; 1296 1306 } 1297 if ( !empty( $field['helps']) )1298 $item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique( (array) $field['helps']) ) . '</p>';1307 if ( !empty( $field['helps'] ) ) 1308 $item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique( (array) $field['helps'] ) ) . '</p>'; 1299 1309 $item .= "</td>\n\t\t</tr>\n"; 1300 1310 1301 1311 $extra_rows = array(); 1302 1312 1303 if ( !empty( $field['errors']) )1304 foreach ( array_unique( (array) $field['errors']) as $error )1313 if ( !empty( $field['errors'] ) ) 1314 foreach ( array_unique( (array) $field['errors'] ) as $error ) 1305 1315 $extra_rows['error'][] = $error; 1306 1316 1307 if ( !empty( $field['extra_rows']) )1317 if ( !empty( $field['extra_rows'] ) ) 1308 1318 foreach ( $field['extra_rows'] as $class => $rows ) 1309 1319 foreach ( (array) $rows as $html ) … … 1315 1325 } 1316 1326 1317 if ( !empty( $form_fields['_final']) )1327 if ( !empty( $form_fields['_final'] ) ) 1318 1328 $item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n"; 1319 1329 $item .= "\t</tbody>\n"; … … 1323 1333 $item .= "\t<input type='hidden' name='$name' id='$name' value='" . esc_attr( $value ) . "' />\n"; 1324 1334 1325 if ( $post->post_parent < 1 && isset( $_REQUEST['post_id']) ) {1335 if ( $post->post_parent < 1 && isset( $_REQUEST['post_id'] ) ) { 1326 1336 $parent = (int) $_REQUEST['post_id']; 1327 1337 $parent_name = "attachments[$attachment_id][post_parent]"; 1328 1329 $item .= "\t<input type='hidden' name='$parent_name' id='$parent_name' value='" . $parent . "' />\n"; 1338 $item .= "\t<input type='hidden' name='$parent_name' id='$parent_name' value='$parent' />\n"; 1330 1339 } 1331 1340 -
trunk/wp-admin/media.php
r12542 r12543 91 91 92 92 <form method="post" action="<?php echo esc_url( remove_query_arg( 'message' ) ); ?>" class="media-upload-form" id="media-single-form"> 93 <p class="submit" >93 <p class="submit" style="padding-bottom: 0;"> 94 94 <input type="submit" class="button-primary" name="save" value="<?php esc_attr_e('Update Media'); ?>" /> 95 95 </p>
Note: See TracChangeset
for help on using the changeset viewer.