Changeset 22541 for trunk/wp-admin/includes/media.php
- Timestamp:
- 11/11/2012 01:26:42 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/media.php
r22523 r22541 1270 1270 } 1271 1271 1272 function get_compat_media_markup( $attachment_id, $args = null ) { 1273 $post = get_post( $attachment_id ); 1274 1275 $default_args = array( 1276 'errors' => null, 1277 ); 1278 1279 $args = wp_parse_args( $args, $default_args ); 1280 $args = apply_filters( 'get_media_item_args', $args ); 1281 1282 $errors = $args['errors']; 1283 1284 $form_fields = get_attachment_fields_to_edit( $post, $errors ); 1285 1286 $media_meta = apply_filters( 'media_meta', '', $post ); 1287 1288 $defaults = array( 1289 'input' => 'text', 1290 'required' => false, 1291 'value' => '', 1292 'extra_rows' => array(), 1293 ); 1294 1295 $hidden_fields = array(); 1296 1297 unset( $form_fields['image-size'], $form_fields['align'], $form_fields['image_alt'], 1298 $form_fields['post_title'], $form_fields['post_excerpt'], $form_fields['post_content'], 1299 $form_fields['url'], $form_fields['menu_order'], $form_fields['image_url'] ); 1300 1301 $item = ''; 1302 foreach ( $form_fields as $id => $field ) { 1303 if ( $id[0] == '_' ) 1304 continue; 1305 1306 $name = "attachments[$attachment_id][$id]"; 1307 1308 if ( !empty( $field['tr'] ) ) { 1309 $item .= $field['tr']; 1310 continue; 1311 } 1312 1313 $field = array_merge( $defaults, $field ); 1314 1315 if ( $field['input'] == 'hidden' ) { 1316 $hidden_fields[$id] = $field['value']; 1317 continue; 1318 } 1319 1320 $required = $field['required'] ? '<span class="alignright"><abbr title="required" class="required">*</abbr></span>' : ''; 1321 $aria_required = $field['required'] ? " aria-required='true' " : ''; 1322 $class = 'compat-item-' . $name; 1323 $class .= $field['required'] ? ' form-required' : ''; 1324 1325 $item .= "\t\t<tr class='$class'>"; 1326 $item .= "\t\t\t<th valign='top' scope='row' class='label'><label for='$name'><span class='alignleft'>{$field['label']}</span>$required<br class='clear' /></label>"; 1327 $item .= "</th>\n\t\t\t<td class='field'>"; 1328 1329 if ( !empty( $field[ $field['input'] ] ) ) 1330 $item .= $field[ $field['input'] ]; 1331 elseif ( $field['input'] == 'textarea' ) { 1332 if ( 'post_content' == $id && user_can_richedit() ) { 1333 // sanitize_post() skips the post_content when user_can_richedit 1334 $field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES ); 1335 } 1336 $item .= "<textarea id='$name' name='$name' $aria_required>" . $field['value'] . '</textarea>'; 1337 } else { 1338 $item .= "<input type='text' class='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "' $aria_required />"; 1339 } 1340 if ( !empty( $field['helps'] ) ) 1341 $item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique( (array) $field['helps'] ) ) . '</p>'; 1342 $item .= "</td>\n\t\t</tr>\n"; 1343 1344 $extra_rows = array(); 1345 1346 if ( !empty( $field['errors'] ) ) 1347 foreach ( array_unique( (array) $field['errors'] ) as $error ) 1348 $extra_rows['error'][] = $error; 1349 1350 if ( !empty( $field['extra_rows'] ) ) 1351 foreach ( $field['extra_rows'] as $class => $rows ) 1352 foreach ( (array) $rows as $html ) 1353 $extra_rows[$class][] = $html; 1354 1355 foreach ( $extra_rows as $class => $rows ) 1356 foreach ( $rows as $html ) 1357 $item .= "\t\t<tr><td></td><td class='$class'>$html</td></tr>\n"; 1358 } 1359 1360 if ( !empty( $form_fields['_final'] ) ) 1361 $item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n"; 1362 if ( $item ) 1363 $item = '<table>' . $item . '</table>'; 1364 1365 return array( 1366 'item' => $item, 1367 'hidden' => $hidden_fields, 1368 'meta' => $media_meta, 1369 ); 1370 } 1371 1272 1372 /** 1273 1373 * {@internal Missing Short Description}}
Note: See TracChangeset
for help on using the changeset viewer.