Attachment editing from mdawaffe. fixes #6181
git-svn-id: http://svn.automattic.com/wordpress/trunk@7262 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
143d94c1c4
commit
3d0435bb58
|
@ -533,7 +533,7 @@ input.readonly {
|
|||
color: #cfebf6;
|
||||
}
|
||||
|
||||
div#media-upload-error, .file-error, .required abbr, .widget-control-remove:hover, .delete:hover {
|
||||
div#media-upload-error, .file-error, abbr.required, .widget-control-remove:hover, .delete:hover {
|
||||
color: #f00;
|
||||
}
|
||||
|
||||
|
|
|
@ -510,7 +510,7 @@ input.readonly {
|
|||
color: #555;
|
||||
}
|
||||
|
||||
div#media-upload-error, .file-error, .required abbr, .widget-control-remove:hover, .delete:hover {
|
||||
div#media-upload-error, .file-error, abbr.required, .widget-control-remove:hover, .delete:hover {
|
||||
color: #f00;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,13 +36,16 @@ form {
|
|||
margin: 0 0 0.5em 0;
|
||||
}
|
||||
|
||||
th { position: relative; }
|
||||
|
||||
.media-upload-form label.form-help, td.help {
|
||||
font-style: italic;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.media-upload-form p {
|
||||
margin: 0 1em 1em 0;
|
||||
.media-upload-form p.help {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.media-upload-form fieldset {
|
||||
|
@ -57,12 +60,8 @@ form {
|
|||
.align .field label {
|
||||
display: inline;
|
||||
padding: 0 0 0 28px;
|
||||
margin: 0 0;
|
||||
margin: 0 1em 0 0;
|
||||
}
|
||||
.align .field input {
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
.image-align-none-label {
|
||||
background: url(../images/align-none.png) no-repeat center left;
|
||||
}
|
||||
|
@ -87,31 +86,13 @@ tr.image-size label {
|
|||
display: inline;
|
||||
margin: 0 1em 0 0;
|
||||
}
|
||||
tr.image-size td.field {
|
||||
text-align: center;
|
||||
}
|
||||
.pinkynail {
|
||||
max-width: 40px;
|
||||
max-height: 40px;
|
||||
}
|
||||
|
||||
#media-items {
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-bottom: none;
|
||||
width: 623px;
|
||||
}
|
||||
.media-item {
|
||||
border-bottom-width: 1px;
|
||||
border-bottom-style: solid;
|
||||
width: 623px;
|
||||
position: relative;
|
||||
min-height: 36px;
|
||||
}
|
||||
.filename {
|
||||
line-height: 36px;
|
||||
margin-left: 50px;
|
||||
z-index: 2;
|
||||
display: none;
|
||||
}
|
||||
button.dismiss {
|
||||
position: absolute;
|
||||
|
@ -148,21 +129,26 @@ button.dismiss {
|
|||
height: 32px;
|
||||
max-width: 40px;
|
||||
}
|
||||
.describe {
|
||||
border-top-width: 1px;
|
||||
border-top-style: solid;
|
||||
padding: 5px;
|
||||
width: 100%;
|
||||
clear: both;
|
||||
|
||||
tbody.media-item-info tr {
|
||||
background-color: transparent;
|
||||
}
|
||||
tbody.media-item-info th, tbody.media-item-info td {
|
||||
border: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.form-table tbody.media-item-info {
|
||||
border: 8px solid #fff;
|
||||
}
|
||||
|
||||
.describe.startopen, .describe.startclosed {
|
||||
display: none;
|
||||
}
|
||||
.required abbr {
|
||||
abbr.required {
|
||||
text-decoration: none;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.describe label {
|
||||
display: inline;
|
||||
}
|
||||
|
@ -196,9 +182,6 @@ button.dismiss {
|
|||
z-index: 3;
|
||||
height: 36px;
|
||||
}
|
||||
tr.align td.field {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
height: 0px;
|
||||
|
@ -206,3 +189,50 @@ tr.align td.field {
|
|||
overflow: hidden;
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* Specific to Uploader */
|
||||
|
||||
#media-upload .media-upload-form p {
|
||||
margin: 0 1em 1em 0;
|
||||
}
|
||||
#media-upload p.help {
|
||||
font-style: italic;
|
||||
font-weight: normal;
|
||||
}
|
||||
#media-upload tr.image-size td.field {
|
||||
text-align: center;
|
||||
}
|
||||
#media-upload #media-items {
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-bottom: none;
|
||||
width: 623px;
|
||||
}
|
||||
|
||||
#media-upload .media-item {
|
||||
border-bottom-width: 1px;
|
||||
border-bottom-style: solid;
|
||||
width: 623px;
|
||||
position: relative;
|
||||
min-height: 36px;
|
||||
}
|
||||
#media-upload .filename {
|
||||
display: block;
|
||||
line-height: 36px;
|
||||
margin-left: 50px;
|
||||
z-index: 2;
|
||||
}
|
||||
#media-upload .describe {
|
||||
border-top-width: 1px;
|
||||
border-top-style: solid;
|
||||
padding: 5px;
|
||||
width: 100%;
|
||||
clear: both;
|
||||
}
|
||||
#media-upload .describe th.label {
|
||||
padding-top: .5em;
|
||||
text-align: left;
|
||||
}
|
||||
#media-upload tr.align td.field {
|
||||
text-align: center;
|
||||
}
|
|
@ -46,7 +46,7 @@ foreach($posts_columns as $column_name=>$column_display_name) {
|
|||
|
||||
case 'media':
|
||||
?>
|
||||
<td><strong><!-- TODO <a href="upload.php?action=edit&post=<?php the_ID(); ?>"> --><?php the_title(); ?><!-- </a> --></strong><br />
|
||||
<td><strong><a href="media.php?action=edit&attachment_id=<?php the_ID(); ?>"><?php the_title(); ?></a></strong><br />
|
||||
<?php echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', get_attached_file($post->ID))); ?>
|
||||
<?php do_action('manage_media_media_column', $post->ID); ?>
|
||||
</td>
|
||||
|
|
|
@ -484,6 +484,11 @@ function image_attachment_fields_to_edit($form_fields, $post) {
|
|||
|
||||
add_filter('attachment_fields_to_edit', 'image_attachment_fields_to_edit', 10, 2);
|
||||
|
||||
function media_single_attachment_fields_to_edit( $form_fields, $post ) {
|
||||
unset($form_fields['url'], $form_fields['align'], $form_fields['image-size']);
|
||||
return $form_fields;
|
||||
}
|
||||
|
||||
function image_attachment_fields_to_save($post, $attachment) {
|
||||
if ( substr($post['post_mime_type'], 0, 5) == 'image' ) {
|
||||
if ( strlen(trim($post['post_title'])) == 0 ) {
|
||||
|
@ -548,7 +553,7 @@ function get_attachment_fields_to_edit($post, $errors = null) {
|
|||
'label' => __('Link URL'),
|
||||
'input' => 'html',
|
||||
'html' => "
|
||||
<input type='text' name='attachments[$post->ID][url]' value='" . attribute_escape($file) . "' />
|
||||
<input type='text' name='attachments[$post->ID][url]' value='" . attribute_escape($file) . "' /><br />
|
||||
<button type='button' class='button url-$post->ID' value=''>" . __('None') . "</button>
|
||||
<button type='button' class='button url-$post->ID' value='" . attribute_escape($file) . "'>" . __('File URL') . "</button>
|
||||
<button type='button' class='button url-$post->ID' value='" . attribute_escape($link) . "'>" . __('Post URL') . "</button>
|
||||
|
@ -604,13 +609,17 @@ function get_media_items( $post_id, $errors ) {
|
|||
return '';
|
||||
|
||||
foreach ( $attachments as $id => $attachment )
|
||||
if ( $item = get_media_item($id, isset($errors[$id]) ? $errors[$id] : null) )
|
||||
if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) )
|
||||
$output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div id='media-upload-error-$id'></div><div class='filename'></div><div class='progress'><div class='bar'></div></div>$item<div class='progress clickmask'></div>\n</div>";
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function get_media_item( $attachment_id, $errors = null, $send = true, $delete = true ) {
|
||||
function get_media_item( $attachment_id, $args = null ) {
|
||||
$default_args = array( 'errors' => null, 'send' => true, 'delete' => true, 'toggle' => true );
|
||||
$args = wp_parse_args( $args, $default_args );
|
||||
extract( $args, EXTR_SKIP );
|
||||
|
||||
global $post_mime_types;
|
||||
if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) )
|
||||
$thumb_url = $thumb_url[0];
|
||||
|
@ -643,20 +652,31 @@ function get_media_item( $attachment_id, $errors = null, $send = true, $delete =
|
|||
|
||||
$form_fields = get_attachment_fields_to_edit($post, $errors);
|
||||
|
||||
$class = empty($errors) ? 'startclosed' : 'startopen';
|
||||
if ( $toggle ) {
|
||||
$class = empty($errors) ? 'startclosed' : 'startopen';
|
||||
$toggle_links = "
|
||||
<a class='toggle describe-toggle-on' href='#'>$toggle_on</a>
|
||||
<a class='toggle describe-toggle-off' href='#'>$toggle_off</a>";
|
||||
} else {
|
||||
$class = 'form-table';
|
||||
$toggle_links = '';
|
||||
}
|
||||
|
||||
$item = "
|
||||
$type
|
||||
<a class='toggle describe-toggle-on' href='#'>$toggle_on</a>
|
||||
<a class='toggle describe-toggle-off' href='#'>$toggle_off</a>
|
||||
$toggle_links
|
||||
<div class='filename new'>$filename</div>
|
||||
<table class='slidetoggle describe $class'><tbody>
|
||||
<table class='slidetoggle describe $class'>
|
||||
<tbody class='media-item-info'>
|
||||
<tr>
|
||||
<td class='A1B1' rowspan='4' colspan='2'><img class='thumbnail' src='$thumb_url' alt='' /></td>
|
||||
<td class='A1B1' rowspan='4'><img class='thumbnail' src='$thumb_url' alt='' /></td>
|
||||
<td>$filename</td>
|
||||
</tr>
|
||||
<tr><td>$post->post_mime_type</td></tr>
|
||||
<td>$post->post_mime_type</td></tr>
|
||||
<tr><td>" . mysql2date($post->post_date, get_option('time_format')) . "</td></tr>
|
||||
<tr><td>" . apply_filters('media_meta', '', $post) . "</tr></td>\n";
|
||||
<tr><td>" . apply_filters('media_meta', '', $post) . "</tr></td>
|
||||
</tbody>
|
||||
<tbody>\n";
|
||||
|
||||
$defaults = array(
|
||||
'input' => 'text',
|
||||
|
@ -671,7 +691,7 @@ function get_media_item( $attachment_id, $errors = null, $send = true, $delete =
|
|||
if ( $delete )
|
||||
$delete = "<a href='$delete_href' id='del[$attachment_id]' disabled='disabled' class='delete'>" . __('Delete') . "</button>";
|
||||
if ( ( $send || $delete ) && !isset($form_fields['buttons']) )
|
||||
$form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td colspan='2'></td><td class='savesend'>$send $delete</td></tr>\n");
|
||||
$form_fields['buttons'] = array('tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $delete</td></tr>\n");
|
||||
|
||||
$hidden_fields = array();
|
||||
|
||||
|
@ -692,8 +712,11 @@ function get_media_item( $attachment_id, $errors = null, $send = true, $delete =
|
|||
continue;
|
||||
}
|
||||
|
||||
$required = $field['required'] ? '<abbr title="required">*</abbr>' : '';
|
||||
$item .= "\t\t<tr class='$id'>\n\t\t\t<td class='label'><label for='$name'>{$field['label']}</label></td>\n\t\t\t<td class='required'>$required</td>\n\t\t\t<td class='field'>";
|
||||
$required = $field['required'] ? '<abbr title="required" class="required">*</abbr>' : '';
|
||||
$class = $id;
|
||||
$class .= $field['required'] ? ' form-required' : '';
|
||||
|
||||
$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'>";
|
||||
if ( !empty($field[$field['input']]) )
|
||||
$item .= $field[$field['input']];
|
||||
elseif ( $field['input'] == 'textarea' ) {
|
||||
|
@ -701,6 +724,8 @@ function get_media_item( $attachment_id, $errors = null, $send = true, $delete =
|
|||
} else {
|
||||
$item .= "<input type='text' id='$name' name='$name' value='" . wp_specialchars($field['value'], 1) . "' />";
|
||||
}
|
||||
if ( !empty($field['helps']) )
|
||||
$item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique((array) $field['helps']) ) . '</p>';
|
||||
$item .= "</td>\n\t\t</tr>\n";
|
||||
|
||||
$extra_rows = array();
|
||||
|
@ -709,10 +734,6 @@ function get_media_item( $attachment_id, $errors = null, $send = true, $delete =
|
|||
foreach ( array_unique((array) $field['errors']) as $error )
|
||||
$extra_rows['error'][] = $error;
|
||||
|
||||
if ( !empty($field['helps']) )
|
||||
foreach ( array_unique((array) $field['helps']) as $help )
|
||||
$extra_rows['help'][] = $help;
|
||||
|
||||
if ( !empty($field['extra_rows']) )
|
||||
foreach ( $field['extra_rows'] as $class => $rows )
|
||||
foreach ( (array) $rows as $html )
|
||||
|
@ -720,11 +741,11 @@ function get_media_item( $attachment_id, $errors = null, $send = true, $delete =
|
|||
|
||||
foreach ( $extra_rows as $class => $rows )
|
||||
foreach ( $rows as $html )
|
||||
$item .= "\t\t<tr><td colspan='2'></td><td class='$class'>$html</td></tr>\n";
|
||||
$item .= "\t\t<tr><td></td><td class='$class'>$html</td></tr>\n";
|
||||
}
|
||||
|
||||
if ( !empty($form_fields['_final']) )
|
||||
$item .= "\t\t<tr class='final'><td colspan='3'>{$form_fields['_final']}</td></tr>\n";
|
||||
$item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n";
|
||||
$item .= "\t</table>\n";
|
||||
|
||||
foreach ( $hidden_fields as $name => $value )
|
||||
|
@ -1037,19 +1058,22 @@ function type_form_image() {
|
|||
return '
|
||||
<table class="describe"><tbody>
|
||||
<tr>
|
||||
<td class="label"><label for="insertonly[src]">' . __('Image URL') . '</label></td>
|
||||
<td class="required"><abbr title="required">*</abbr></td>
|
||||
<th valign="top" scope="row" class="label">
|
||||
<span class="alignleft"><label for="insertonly[src]">' . __('Image URL') . '</label></span>
|
||||
<span class="alignright"><abbr title="required" class="required">*</abbr></span>
|
||||
</th>
|
||||
<td class="field"><input id="insertonly[src]" name="insertonly[src]" value="" type="text"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label"><label for="insertonly[alt]">' . __('Description') . '</label></td>
|
||||
<td class="required"><abbr title="required">*</abbr></td>
|
||||
<th valign="top" scope="row" class="label">
|
||||
<span class="alignleft"><label for="insertonly[alt]">' . __('Description') . '</label></span>
|
||||
<span class="alignright"><abbr title="required">*</abbr></span>
|
||||
</th>
|
||||
<td class="field"><input id="insertonly[alt]" name="insertonly[alt]" value="" type="text"></td>
|
||||
</tr>
|
||||
<tr><td colspan="2"></td><td class="help">' . __('Alternate text, e.g. "The Mona Lisa"') . '</td></tr>
|
||||
<tr><td></td><td class="help">' . __('Alternate text, e.g. "The Mona Lisa"') . '</td></tr>
|
||||
<tr class="align">
|
||||
<td class="label"><label for="insertonly[align]">' . __('Alignment') . '</label></td>
|
||||
<td class="required"></td>
|
||||
<th valign="top" scope="row" class="label"><label for="insertonly[align]">' . __('Alignment') . '</label></th>
|
||||
<td class="field">
|
||||
<input name="insertonly[align]" id="image-align-none-0" value="none" type="radio">
|
||||
<label for="image-align-none-0" class="align image-align-none-label">' . __('None') . '</label>
|
||||
|
@ -1062,7 +1086,7 @@ function type_form_image() {
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"></td>
|
||||
<td></td>
|
||||
<td>
|
||||
<input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" />
|
||||
</td>
|
||||
|
@ -1075,18 +1099,22 @@ function type_form_audio() {
|
|||
return '
|
||||
<table class="describe"><tbody>
|
||||
<tr>
|
||||
<td class="label"><label for="insertonly[href]">' . __('Audio File URL') . '</label></td>
|
||||
<td class="required"><abbr title="required">*</abbr></td>
|
||||
<th valign="top" scope="row" class="label">
|
||||
<span class="alignleft"><label for="insertonly[href]">' . __('Audio File URL') . '</label></span>
|
||||
<span class="alignright"><abbr title="required" class="required">*</abbr></span>
|
||||
</th>
|
||||
<td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label"><label for="insertonly[title]">' . __('Title') . '</label></td>
|
||||
<td class="required"><abbr title="required">*</abbr></td>
|
||||
<th valign="top" scope="row" class="label">
|
||||
<span class="alignleft"><label for="insertonly[title]">' . __('Title') . '</label></span>
|
||||
<span class="alignright"><abbr title="required" class="required">*</abbr></span>
|
||||
</th>
|
||||
<td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text"></td>
|
||||
</tr>
|
||||
<tr><td colspan="2"></td><td class="help">' . __('Link text, e.g. "Still Alive by Jonathan Coulton"') . '</td></tr>
|
||||
<tr><td></td><td class="help">' . __('Link text, e.g. "Still Alive by Jonathan Coulton"') . '</td></tr>
|
||||
<tr>
|
||||
<td colspan="2"></td>
|
||||
<td></td>
|
||||
<td>
|
||||
<input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" />
|
||||
</td>
|
||||
|
@ -1099,18 +1127,22 @@ function type_form_video() {
|
|||
return '
|
||||
<table class="describe"><tbody>
|
||||
<tr>
|
||||
<td class="label"><label for="insertonly[href]">' . __('Video URL') . '</label></td>
|
||||
<td class="required"><abbr title="required">*</abbr></td>
|
||||
<th valign="top" scope="row" class="label">
|
||||
<span class="alignleft"><label for="insertonly[href]">' . __('Video URL') . '</label></span>
|
||||
<span class="alignright"><abbr title="required" class="required">*</abbr></span>
|
||||
</th>
|
||||
<td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label"><label for="insertonly[title]">' . __('Title') . '</label></td>
|
||||
<td class="required"><abbr title="required">*</abbr></td>
|
||||
<th valign="top" scope="row" class="label">
|
||||
<span class="alignleft"><label for="insertonly[title]">' . __('Title') . '</label></span>
|
||||
<span class="alignright"><abbr title="required" class="required">*</abbr></span>
|
||||
</th>
|
||||
<td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text"></td>
|
||||
</tr>
|
||||
<tr><td colspan="2"></td><td class="help">' . __('Link text, e.g. "Lucy on YouTube"') . '</td></tr>
|
||||
<tr><td></td><td class="help">' . __('Link text, e.g. "Lucy on YouTube"') . '</td></tr>
|
||||
<tr>
|
||||
<td colspan="2"></td>
|
||||
<td></td>
|
||||
<td>
|
||||
<input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" />
|
||||
</td>
|
||||
|
@ -1123,18 +1155,22 @@ function type_form_file() {
|
|||
return '
|
||||
<table class="describe"><tbody>
|
||||
<tr>
|
||||
<td class="label"><label for="insertonly[href]">' . __('URL') . '</label></td>
|
||||
<td class="required"><abbr title="required">*</abbr></td>
|
||||
<th valign="top" scope="row" class="label">
|
||||
<span class="alignleft"><label for="insertonly[href]">' . __('URL') . '</label></span>
|
||||
<span class="alignright"><abbr title="required" class="required">*</abbr></span>
|
||||
</th>
|
||||
<td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label"><label for="insertonly[title]">' . __('Title') . '</label></td>
|
||||
<td class="required"><abbr title="required">*</abbr></td>
|
||||
<th valign="top" scope="row" class="label">
|
||||
<span class="alignleft"><label for="insertonly[title]">' . __('Title') . '</label></span>
|
||||
<span class="alignright"><abbr title="required" class="required">*</abbr></span>
|
||||
</th>
|
||||
<td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text"></td>
|
||||
</tr>
|
||||
<tr><td colspan="2"></td><td class="help">' . __('Link text, e.g. "Ransom Demands (PDF)"') . '</td></tr>
|
||||
<tr><td></td><td class="help">' . __('Link text, e.g. "Ransom Demands (PDF)"') . '</td></tr>
|
||||
<tr>
|
||||
<td colspan="2"></td>
|
||||
<td></td>
|
||||
<td>
|
||||
<input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" />
|
||||
</td>
|
||||
|
|
|
@ -4,4 +4,9 @@ addLoadEvent( function() {
|
|||
|
||||
// Reveal
|
||||
jQuery('.wp-no-js-hidden').removeClass( 'wp-no-js-hidden' );
|
||||
|
||||
// Basic form validation
|
||||
if ( ( 'undefined' != typeof wpAjax ) && jQuery.isFunction( wpAjax.validateForm ) ) {
|
||||
jQuery('form').submit( function() { return wpAjax.validateForm( jQuery(this) ); } );
|
||||
}
|
||||
});
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
require_once('admin.php');
|
||||
|
||||
$parent_file = 'edit.php';
|
||||
$submenu_file = 'upload.php';
|
||||
|
||||
wp_reset_vars(array('action'));
|
||||
|
||||
switch( $action ) :
|
||||
case 'upload' :
|
||||
case 'delete' : break; // stubs
|
||||
case 'editattachment' :
|
||||
$errors = media_upload_form_handler();
|
||||
if ( empty($errors) ) {
|
||||
wp_redirect( add_query_arg( 'message', 'updated' ) );
|
||||
exit;
|
||||
break;
|
||||
}
|
||||
// no break
|
||||
case 'edit' :
|
||||
$title = __('Edit Media');
|
||||
|
||||
if ( empty($errors) )
|
||||
$errors = null;
|
||||
|
||||
if ( empty( $_GET['attachment_id'] ) ) {
|
||||
wp_redirect('upload.php');
|
||||
exit();
|
||||
}
|
||||
$att_id = (int) $_GET['attachment_id'];
|
||||
$att = get_post($att_id);
|
||||
|
||||
add_filter('attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2);
|
||||
|
||||
wp_enqueue_script( 'wp-ajax-response' );
|
||||
add_action('admin_head', 'media_admin_css');
|
||||
|
||||
require( 'admin-header.php' );
|
||||
|
||||
$message = '';
|
||||
$class = '';
|
||||
if ( isset($_GET['message']) ) {
|
||||
switch ( $_GET['message'] ) :
|
||||
case 'updated' :
|
||||
$message = __('Media attachment updated.');
|
||||
$class = 'updated fade';
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
if ( $message )
|
||||
echo "<div id='message' class='$class'><p>$message</p></div>\n";
|
||||
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
|
||||
<h2><?php _e( 'Edit Media' ); ?></h2>
|
||||
|
||||
<form method="post" action="<?php echo clean_url( remove_query_arg( 'message' ) ); ?>" class="media-upload-form" id="media-single-form">
|
||||
<div id="media-items" class="media-single">
|
||||
<div id='media-item-<?php echo $att_id; ?>' class='media-item'>
|
||||
<?php echo get_media_item( $att_id, array( 'toggle' => false, 'send' => false, 'delete' => false, 'errors' => $errors ) ); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="submit">
|
||||
<input type="submit" class="button" name="save" value="<?php _e('Save Changes'); ?>" />
|
||||
<input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" />
|
||||
<input type="hidden" name="action" value="editattachment" />
|
||||
<?php wp_nonce_field('media-form'); ?>
|
||||
</p>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
require( 'admin-footer.php' );
|
||||
|
||||
break;
|
||||
endswitch;
|
||||
|
||||
wp_redirect( 'upload.php' );
|
||||
exit;
|
||||
|
||||
?>
|
|
@ -50,7 +50,8 @@ wpAjax = jQuery.extend( {
|
|||
else if ( 0 === x ) { return !re.html('<div class="error"><p>' + this.broken + '</p></div>'); }
|
||||
return true;
|
||||
},
|
||||
invalidateForm: function( jQ ) {
|
||||
jQ.addClass( 'form-invalid' ).change( function() { jQuery(this).removeClass( 'form-invalid' ); } );
|
||||
validateForm: function( selector ) {
|
||||
selector = jQuery( selector );
|
||||
return !selector.find('.form-required').andSelf().filter('.form-required:has(:input[value=""]), .form-required:input[value=""]').addClass( 'form-invalid' ).change( function() { jQuery(this).removeClass( 'form-invalid' ); } ).size();
|
||||
}
|
||||
}, wpAjax || { noPerm: 'You do not have permission to do that.', broken: 'AJAX is teh b0rked.' } );
|
||||
|
|
|
@ -70,11 +70,8 @@ var wpList = {
|
|||
s.nonce = wpList.nonce(e,s);
|
||||
|
||||
var es = $('#' + s.element + ' :input').not('[name=_ajax_nonce], [name=_wpnonce], [name=action]');
|
||||
var required = $('#' + s.element + ' .form-required:has(:input[value=""]), #' + s.element + ' .form-required:input[value=""]');
|
||||
if ( required.size() ) {
|
||||
wpAjax.invalidateForm( required );
|
||||
return false;
|
||||
}
|
||||
var valid = wpAjax.validateForm( '#' + s.element );
|
||||
if ( !valid ) { return false; }
|
||||
|
||||
s.data = $.param( $.extend( { _ajax_nonce: s.nonce, action: s.action }, wpAjax.unserialize( cls[4] || '' ) ) );
|
||||
var formData = $.isFunction(es.fieldSerialize) ? es.fieldSerialize() : es.serialize();
|
||||
|
|
|
@ -439,21 +439,31 @@ function get_search_comments_feed_link($search_query = '', $feed = '') {
|
|||
}
|
||||
|
||||
function get_edit_post_link( $id = 0 ) {
|
||||
$post = &get_post( $id );
|
||||
if ( !$post = &get_post( $id ) )
|
||||
return;
|
||||
|
||||
if ( $post->post_type == 'page' ) {
|
||||
switch ( $post->post_type ) :
|
||||
case 'page' :
|
||||
if ( !current_user_can( 'edit_page', $post->ID ) )
|
||||
return;
|
||||
|
||||
$file = 'page';
|
||||
} else {
|
||||
$var = 'post';
|
||||
break;
|
||||
case 'attachment' :
|
||||
if ( !current_user_can( 'edit_post', $post->ID ) )
|
||||
return;
|
||||
$file = 'media';
|
||||
$var = 'attachment_id';
|
||||
break;
|
||||
default :
|
||||
if ( !current_user_can( 'edit_post', $post->ID ) )
|
||||
return;
|
||||
|
||||
$file = 'post';
|
||||
}
|
||||
$var = 'post';
|
||||
break;
|
||||
endswitch;
|
||||
|
||||
return apply_filters( 'get_edit_post_link', get_bloginfo( 'wpurl' ) . '/wp-admin/' . $file . '.php?action=edit&post=' . $post->ID, $post->ID );
|
||||
return apply_filters( 'get_edit_post_link', get_bloginfo( 'wpurl' ) . "/wp-admin/$file.php?action=edit&$var=$post->ID", $post->ID );
|
||||
}
|
||||
|
||||
function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) {
|
||||
|
@ -462,13 +472,9 @@ function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) {
|
|||
if ( $post->post_type == 'page' ) {
|
||||
if ( !current_user_can( 'edit_page', $post->ID ) )
|
||||
return;
|
||||
|
||||
$file = 'page';
|
||||
} else {
|
||||
if ( !current_user_can( 'edit_post', $post->ID ) )
|
||||
return;
|
||||
|
||||
$file = 'post';
|
||||
}
|
||||
|
||||
$link = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . __( 'Edit post' ) . '">' . $link . '</a>';
|
||||
|
|
|
@ -41,13 +41,13 @@ class WP_Scripts {
|
|||
|
||||
$this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.6');
|
||||
|
||||
$this->add( 'wp-ajax-response', '/wp-includes/js/wp-ajax-response.js', array('jquery'), '20080229' . mt_rand() );
|
||||
$this->add( 'wp-ajax-response', '/wp-includes/js/wp-ajax-response.js', array('jquery'), '20080312' );
|
||||
$this->localize( 'wp-ajax-response', 'wpAjax', array(
|
||||
'noPerm' => 'You do not have permission to do that.',
|
||||
'broken' => 'AJAX is teh b0rked.'
|
||||
) );
|
||||
|
||||
$this->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20080221' . mt_rand());
|
||||
$this->add( 'autosave', '/wp-includes/js/autosave.js', array('schedule', 'wp-ajax-response'), '20080312' );
|
||||
|
||||
$this->add( 'wp-ajax', '/wp-includes/js/wp-ajax.js', array('prototype'), '20070306');
|
||||
$this->localize( 'wp-ajax', 'WPAjaxL10n', array(
|
||||
|
@ -57,7 +57,7 @@ class WP_Scripts {
|
|||
'whoaText' => __("Slow down, I'm still sending your data!")
|
||||
) );
|
||||
|
||||
$this->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('wp-ajax-response'), '20080228' . mt_rand());
|
||||
$this->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('wp-ajax-response'), '20080312' );
|
||||
$this->localize( 'wp-lists', 'wpListL10n', array(
|
||||
'url' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php'
|
||||
) );
|
||||
|
|
Loading…
Reference in New Issue