mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-17 20:15:08 +00:00
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;
|
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;
|
color: #f00;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,7 +510,7 @@ input.readonly {
|
|||||||
color: #555;
|
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;
|
color: #f00;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,13 +36,16 @@ form {
|
|||||||
margin: 0 0 0.5em 0;
|
margin: 0 0 0.5em 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
th { position: relative; }
|
||||||
|
|
||||||
.media-upload-form label.form-help, td.help {
|
.media-upload-form label.form-help, td.help {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-upload-form p {
|
.media-upload-form p.help {
|
||||||
margin: 0 1em 1em 0;
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-upload-form fieldset {
|
.media-upload-form fieldset {
|
||||||
@ -57,12 +60,8 @@ form {
|
|||||||
.align .field label {
|
.align .field label {
|
||||||
display: inline;
|
display: inline;
|
||||||
padding: 0 0 0 28px;
|
padding: 0 0 0 28px;
|
||||||
margin: 0 0;
|
margin: 0 1em 0 0;
|
||||||
}
|
}
|
||||||
.align .field input {
|
|
||||||
margin-left: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.image-align-none-label {
|
.image-align-none-label {
|
||||||
background: url(../images/align-none.png) no-repeat center left;
|
background: url(../images/align-none.png) no-repeat center left;
|
||||||
}
|
}
|
||||||
@ -87,31 +86,13 @@ tr.image-size label {
|
|||||||
display: inline;
|
display: inline;
|
||||||
margin: 0 1em 0 0;
|
margin: 0 1em 0 0;
|
||||||
}
|
}
|
||||||
tr.image-size td.field {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
.pinkynail {
|
.pinkynail {
|
||||||
max-width: 40px;
|
max-width: 40px;
|
||||||
max-height: 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 {
|
.filename {
|
||||||
line-height: 36px;
|
display: none;
|
||||||
margin-left: 50px;
|
|
||||||
z-index: 2;
|
|
||||||
}
|
}
|
||||||
button.dismiss {
|
button.dismiss {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -148,21 +129,26 @@ button.dismiss {
|
|||||||
height: 32px;
|
height: 32px;
|
||||||
max-width: 40px;
|
max-width: 40px;
|
||||||
}
|
}
|
||||||
.describe {
|
|
||||||
border-top-width: 1px;
|
tbody.media-item-info tr {
|
||||||
border-top-style: solid;
|
background-color: transparent;
|
||||||
padding: 5px;
|
|
||||||
width: 100%;
|
|
||||||
clear: both;
|
|
||||||
}
|
}
|
||||||
|
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 {
|
.describe.startopen, .describe.startclosed {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.required abbr {
|
abbr.required {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
border: none;
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.describe label {
|
.describe label {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
@ -196,13 +182,57 @@ button.dismiss {
|
|||||||
z-index: 3;
|
z-index: 3;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
}
|
}
|
||||||
tr.align td.field {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hidden {
|
.hidden {
|
||||||
height: 0px;
|
height: 0px;
|
||||||
width: 0px;
|
width: 0px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border: none;
|
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':
|
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 echo strtoupper(preg_replace('/^.*?\.(\w+)$/', '$1', get_attached_file($post->ID))); ?>
|
||||||
<?php do_action('manage_media_media_column', $post->ID); ?>
|
<?php do_action('manage_media_media_column', $post->ID); ?>
|
||||||
</td>
|
</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);
|
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) {
|
function image_attachment_fields_to_save($post, $attachment) {
|
||||||
if ( substr($post['post_mime_type'], 0, 5) == 'image' ) {
|
if ( substr($post['post_mime_type'], 0, 5) == 'image' ) {
|
||||||
if ( strlen(trim($post['post_title'])) == 0 ) {
|
if ( strlen(trim($post['post_title'])) == 0 ) {
|
||||||
@ -548,7 +553,7 @@ function get_attachment_fields_to_edit($post, $errors = null) {
|
|||||||
'label' => __('Link URL'),
|
'label' => __('Link URL'),
|
||||||
'input' => 'html',
|
'input' => 'html',
|
||||||
'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=''>" . __('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($file) . "'>" . __('File URL') . "</button>
|
||||||
<button type='button' class='button url-$post->ID' value='" . attribute_escape($link) . "'>" . __('Post 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 '';
|
return '';
|
||||||
|
|
||||||
foreach ( $attachments as $id => $attachment )
|
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>";
|
$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;
|
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;
|
global $post_mime_types;
|
||||||
if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) )
|
if ( ( $attachment_id = intval($attachment_id) ) && $thumb_url = get_attachment_icon_src( $attachment_id ) )
|
||||||
$thumb_url = $thumb_url[0];
|
$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);
|
$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 = "
|
$item = "
|
||||||
$type
|
$type
|
||||||
<a class='toggle describe-toggle-on' href='#'>$toggle_on</a>
|
$toggle_links
|
||||||
<a class='toggle describe-toggle-off' href='#'>$toggle_off</a>
|
|
||||||
<div class='filename new'>$filename</div>
|
<div class='filename new'>$filename</div>
|
||||||
<table class='slidetoggle describe $class'><tbody>
|
<table class='slidetoggle describe $class'>
|
||||||
|
<tbody class='media-item-info'>
|
||||||
<tr>
|
<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>
|
<td>$filename</td>
|
||||||
</tr>
|
</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>" . 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(
|
$defaults = array(
|
||||||
'input' => 'text',
|
'input' => 'text',
|
||||||
@ -671,7 +691,7 @@ function get_media_item( $attachment_id, $errors = null, $send = true, $delete =
|
|||||||
if ( $delete )
|
if ( $delete )
|
||||||
$delete = "<a href='$delete_href' id='del[$attachment_id]' disabled='disabled' class='delete'>" . __('Delete') . "</button>";
|
$delete = "<a href='$delete_href' id='del[$attachment_id]' disabled='disabled' class='delete'>" . __('Delete') . "</button>";
|
||||||
if ( ( $send || $delete ) && !isset($form_fields['buttons']) )
|
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();
|
$hidden_fields = array();
|
||||||
|
|
||||||
@ -692,8 +712,11 @@ function get_media_item( $attachment_id, $errors = null, $send = true, $delete =
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$required = $field['required'] ? '<abbr title="required">*</abbr>' : '';
|
$required = $field['required'] ? '<abbr title="required" class="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'>";
|
$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']]) )
|
if ( !empty($field[$field['input']]) )
|
||||||
$item .= $field[$field['input']];
|
$item .= $field[$field['input']];
|
||||||
elseif ( $field['input'] == 'textarea' ) {
|
elseif ( $field['input'] == 'textarea' ) {
|
||||||
@ -701,6 +724,8 @@ function get_media_item( $attachment_id, $errors = null, $send = true, $delete =
|
|||||||
} else {
|
} else {
|
||||||
$item .= "<input type='text' id='$name' name='$name' value='" . wp_specialchars($field['value'], 1) . "' />";
|
$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";
|
$item .= "</td>\n\t\t</tr>\n";
|
||||||
|
|
||||||
$extra_rows = array();
|
$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 )
|
foreach ( array_unique((array) $field['errors']) as $error )
|
||||||
$extra_rows['error'][] = $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']) )
|
if ( !empty($field['extra_rows']) )
|
||||||
foreach ( $field['extra_rows'] as $class => $rows )
|
foreach ( $field['extra_rows'] as $class => $rows )
|
||||||
foreach ( (array) $rows as $html )
|
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 ( $extra_rows as $class => $rows )
|
||||||
foreach ( $rows as $html )
|
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']) )
|
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";
|
$item .= "\t</table>\n";
|
||||||
|
|
||||||
foreach ( $hidden_fields as $name => $value )
|
foreach ( $hidden_fields as $name => $value )
|
||||||
@ -1037,19 +1058,22 @@ function type_form_image() {
|
|||||||
return '
|
return '
|
||||||
<table class="describe"><tbody>
|
<table class="describe"><tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label"><label for="insertonly[src]">' . __('Image URL') . '</label></td>
|
<th valign="top" scope="row" class="label">
|
||||||
<td class="required"><abbr title="required">*</abbr></td>
|
<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>
|
<td class="field"><input id="insertonly[src]" name="insertonly[src]" value="" type="text"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label"><label for="insertonly[alt]">' . __('Description') . '</label></td>
|
<th valign="top" scope="row" class="label">
|
||||||
<td class="required"><abbr title="required">*</abbr></td>
|
<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>
|
<td class="field"><input id="insertonly[alt]" name="insertonly[alt]" value="" type="text"></td>
|
||||||
</tr>
|
</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">
|
<tr class="align">
|
||||||
<td class="label"><label for="insertonly[align]">' . __('Alignment') . '</label></td>
|
<th valign="top" scope="row" class="label"><label for="insertonly[align]">' . __('Alignment') . '</label></th>
|
||||||
<td class="required"></td>
|
|
||||||
<td class="field">
|
<td class="field">
|
||||||
<input name="insertonly[align]" id="image-align-none-0" value="none" type="radio">
|
<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>
|
<label for="image-align-none-0" class="align image-align-none-label">' . __('None') . '</label>
|
||||||
@ -1062,7 +1086,7 @@ function type_form_image() {
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"></td>
|
<td></td>
|
||||||
<td>
|
<td>
|
||||||
<input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" />
|
<input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" />
|
||||||
</td>
|
</td>
|
||||||
@ -1075,18 +1099,22 @@ function type_form_audio() {
|
|||||||
return '
|
return '
|
||||||
<table class="describe"><tbody>
|
<table class="describe"><tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label"><label for="insertonly[href]">' . __('Audio File URL') . '</label></td>
|
<th valign="top" scope="row" class="label">
|
||||||
<td class="required"><abbr title="required">*</abbr></td>
|
<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>
|
<td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label"><label for="insertonly[title]">' . __('Title') . '</label></td>
|
<th valign="top" scope="row" class="label">
|
||||||
<td class="required"><abbr title="required">*</abbr></td>
|
<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>
|
<td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text"></td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<td colspan="2"></td>
|
<td></td>
|
||||||
<td>
|
<td>
|
||||||
<input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" />
|
<input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" />
|
||||||
</td>
|
</td>
|
||||||
@ -1099,18 +1127,22 @@ function type_form_video() {
|
|||||||
return '
|
return '
|
||||||
<table class="describe"><tbody>
|
<table class="describe"><tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label"><label for="insertonly[href]">' . __('Video URL') . '</label></td>
|
<th valign="top" scope="row" class="label">
|
||||||
<td class="required"><abbr title="required">*</abbr></td>
|
<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>
|
<td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label"><label for="insertonly[title]">' . __('Title') . '</label></td>
|
<th valign="top" scope="row" class="label">
|
||||||
<td class="required"><abbr title="required">*</abbr></td>
|
<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>
|
<td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text"></td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<td colspan="2"></td>
|
<td></td>
|
||||||
<td>
|
<td>
|
||||||
<input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" />
|
<input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" />
|
||||||
</td>
|
</td>
|
||||||
@ -1123,18 +1155,22 @@ function type_form_file() {
|
|||||||
return '
|
return '
|
||||||
<table class="describe"><tbody>
|
<table class="describe"><tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label"><label for="insertonly[href]">' . __('URL') . '</label></td>
|
<th valign="top" scope="row" class="label">
|
||||||
<td class="required"><abbr title="required">*</abbr></td>
|
<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>
|
<td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="label"><label for="insertonly[title]">' . __('Title') . '</label></td>
|
<th valign="top" scope="row" class="label">
|
||||||
<td class="required"><abbr title="required">*</abbr></td>
|
<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>
|
<td class="field"><input id="insertonly[title]" name="insertonly[title]" value="" type="text"></td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<td colspan="2"></td>
|
<td></td>
|
||||||
<td>
|
<td>
|
||||||
<input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" />
|
<input type="submit" class="button" name="insertonlybutton" value="' . attribute_escape(__('Insert into Post')) . '" />
|
||||||
</td>
|
</td>
|
||||||
|
@ -4,4 +4,9 @@ addLoadEvent( function() {
|
|||||||
|
|
||||||
// Reveal
|
// Reveal
|
||||||
jQuery('.wp-no-js-hidden').removeClass( 'wp-no-js-hidden' );
|
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) ); } );
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
87
wp-admin/media.php
Normal file
87
wp-admin/media.php
Normal file
@ -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>'); }
|
else if ( 0 === x ) { return !re.html('<div class="error"><p>' + this.broken + '</p></div>'); }
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
invalidateForm: function( jQ ) {
|
validateForm: function( selector ) {
|
||||||
jQ.addClass( 'form-invalid' ).change( function() { jQuery(this).removeClass( 'form-invalid' ); } );
|
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.' } );
|
}, 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);
|
s.nonce = wpList.nonce(e,s);
|
||||||
|
|
||||||
var es = $('#' + s.element + ' :input').not('[name=_ajax_nonce], [name=_wpnonce], [name=action]');
|
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=""]');
|
var valid = wpAjax.validateForm( '#' + s.element );
|
||||||
if ( required.size() ) {
|
if ( !valid ) { return false; }
|
||||||
wpAjax.invalidateForm( required );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
s.data = $.param( $.extend( { _ajax_nonce: s.nonce, action: s.action }, wpAjax.unserialize( cls[4] || '' ) ) );
|
s.data = $.param( $.extend( { _ajax_nonce: s.nonce, action: s.action }, wpAjax.unserialize( cls[4] || '' ) ) );
|
||||||
var formData = $.isFunction(es.fieldSerialize) ? es.fieldSerialize() : es.serialize();
|
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 ) {
|
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 ) )
|
if ( !current_user_can( 'edit_page', $post->ID ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$file = 'page';
|
$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 ) )
|
if ( !current_user_can( 'edit_post', $post->ID ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$file = 'post';
|
$file = 'post';
|
||||||
}
|
$var = 'post';
|
||||||
|
break;
|
||||||
return apply_filters( 'get_edit_post_link', get_bloginfo( 'wpurl' ) . '/wp-admin/' . $file . '.php?action=edit&post=' . $post->ID, $post->ID );
|
endswitch;
|
||||||
|
|
||||||
|
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 = '' ) {
|
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 ( $post->post_type == 'page' ) {
|
||||||
if ( !current_user_can( 'edit_page', $post->ID ) )
|
if ( !current_user_can( 'edit_page', $post->ID ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$file = 'page';
|
|
||||||
} else {
|
} else {
|
||||||
if ( !current_user_can( 'edit_post', $post->ID ) )
|
if ( !current_user_can( 'edit_post', $post->ID ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$file = 'post';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$link = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . __( 'Edit post' ) . '">' . $link . '</a>';
|
$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( '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(
|
$this->localize( 'wp-ajax-response', 'wpAjax', array(
|
||||||
'noPerm' => 'You do not have permission to do that.',
|
'noPerm' => 'You do not have permission to do that.',
|
||||||
'broken' => 'AJAX is teh b0rked.'
|
'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->add( 'wp-ajax', '/wp-includes/js/wp-ajax.js', array('prototype'), '20070306');
|
||||||
$this->localize( 'wp-ajax', 'WPAjaxL10n', array(
|
$this->localize( 'wp-ajax', 'WPAjaxL10n', array(
|
||||||
@ -57,7 +57,7 @@ class WP_Scripts {
|
|||||||
'whoaText' => __("Slow down, I'm still sending your data!")
|
'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(
|
$this->localize( 'wp-lists', 'wpListL10n', array(
|
||||||
'url' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php'
|
'url' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php'
|
||||||
) );
|
) );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user