2006-10-25 18:55:05 -04:00
|
|
|
<?php
|
2007-05-25 03:16:21 -04:00
|
|
|
|
2006-10-25 18:55:05 -04:00
|
|
|
function wp_upload_display( $dims = false, $href = '' ) {
|
|
|
|
global $post;
|
|
|
|
$id = get_the_ID();
|
2006-12-05 17:37:19 -05:00
|
|
|
$attachment_data = wp_get_attachment_metadata( $id );
|
2007-01-18 19:19:03 -05:00
|
|
|
$is_image = (int) wp_attachment_is_image();
|
2007-07-15 13:52:50 -04:00
|
|
|
$filesystem_path = get_attached_file( $id );
|
2007-01-18 19:19:03 -05:00
|
|
|
if ( !isset($attachment_data['width']) && $is_image ) {
|
2007-07-15 13:52:50 -04:00
|
|
|
if ( $image_data = getimagesize( $filesystem_path ) ) {
|
2007-01-18 19:19:03 -05:00
|
|
|
$attachment_data['width'] = $image_data[0];
|
|
|
|
$attachment_data['height'] = $image_data[1];
|
|
|
|
wp_update_attachment_metadata( $id, $attachment_data );
|
|
|
|
}
|
|
|
|
}
|
2006-10-25 18:55:05 -04:00
|
|
|
if ( isset($attachment_data['width']) )
|
|
|
|
list($width,$height) = wp_shrink_dimensions($attachment_data['width'], $attachment_data['height'], 171, 128);
|
2007-11-04 19:01:26 -05:00
|
|
|
// check for extended metadata from exif/iptc
|
|
|
|
if ( !isset($attachment_data['image_meta']) && $is_image ) {
|
2007-11-06 15:14:52 -05:00
|
|
|
$image_meta = wp_read_image_metadata( $filesystem_path );
|
2007-11-04 19:01:26 -05:00
|
|
|
$attachment_data['image_meta'] = $image_meta;
|
|
|
|
wp_update_attachment_metadata( $id, $attachment_data );
|
|
|
|
}
|
2007-02-27 10:24:54 -05:00
|
|
|
|
2007-06-01 19:16:50 -04:00
|
|
|
$post_title = attribute_escape( the_title( '', '', false ) );
|
2007-03-06 23:29:45 -05:00
|
|
|
$post_content = attribute_escape(apply_filters( 'content_edit_pre', $post->post_content ));
|
2007-02-27 10:24:54 -05:00
|
|
|
|
2006-10-25 18:55:05 -04:00
|
|
|
$class = 'text';
|
|
|
|
$innerHTML = get_attachment_innerHTML( $id, false, $dims );
|
2007-01-02 14:28:30 -05:00
|
|
|
if ( $image_src = get_attachment_icon_src() ) {
|
2006-10-25 18:55:05 -04:00
|
|
|
$image_rel = wp_make_link_relative($image_src);
|
|
|
|
$innerHTML = ' ' . str_replace($image_src, $image_rel, $innerHTML);
|
2007-01-02 14:28:30 -05:00
|
|
|
$class = 'image';
|
2006-10-25 18:55:05 -04:00
|
|
|
}
|
|
|
|
|
2007-01-02 14:28:30 -05:00
|
|
|
$src_base = wp_get_attachment_url();
|
2006-10-25 18:55:05 -04:00
|
|
|
$src = wp_make_link_relative( $src_base );
|
|
|
|
$src_base = str_replace($src, '', $src_base);
|
|
|
|
|
2007-10-12 18:15:54 -04:00
|
|
|
if ( !trim($post_title) )
|
|
|
|
$post_title = basename($src);
|
|
|
|
|
2006-10-25 18:55:05 -04:00
|
|
|
$r = '';
|
|
|
|
|
|
|
|
if ( $href )
|
|
|
|
$r .= "<a id='file-link-$id' href='$href' title='$post_title' class='file-link $class'>\n";
|
|
|
|
if ( $href || $image_src )
|
|
|
|
$r .= "\t\t\t$innerHTML";
|
|
|
|
if ( $href )
|
|
|
|
$r .= "</a>\n";
|
2007-10-05 12:27:48 -04:00
|
|
|
$size = @filesize($filesystem_path);
|
|
|
|
if ( !empty($size) )
|
|
|
|
$r .= "\t\t\t\t<span class='upload-file-size'>".size_format($size)."</span>\n";
|
2006-10-25 18:55:05 -04:00
|
|
|
$r .= "\n\t\t<div class='upload-file-data'>\n\t\t\t<p>\n";
|
|
|
|
$r .= "\t\t\t\t<input type='hidden' name='attachment-url-$id' id='attachment-url-$id' value='$src' />\n";
|
|
|
|
$r .= "\t\t\t\t<input type='hidden' name='attachment-url-base-$id' id='attachment-url-base-$id' value='$src_base' />\n";
|
|
|
|
|
2007-01-02 14:28:30 -05:00
|
|
|
if ( !$thumb_base = wp_get_attachment_thumb_url() )
|
|
|
|
$thumb_base = wp_mime_type_icon();
|
|
|
|
if ( $thumb_base ) {
|
|
|
|
$thumb_rel = wp_make_link_relative( $thumb_base );
|
|
|
|
$thumb_base = str_replace( $thumb_rel, '', $thumb_base );
|
|
|
|
$r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-$id' id='attachment-thumb-url-$id' value='$thumb_rel' />\n";
|
|
|
|
$r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-base-$id' id='attachment-thumb-url-base-$id' value='$thumb_base' />\n";
|
|
|
|
}
|
2007-01-18 19:19:03 -05:00
|
|
|
|
2007-01-02 14:28:30 -05:00
|
|
|
$r .= "\t\t\t\t<input type='hidden' name='attachment-is-image-$id' id='attachment-is-image-$id' value='$is_image' />\n";
|
2007-01-18 19:19:03 -05:00
|
|
|
|
2006-10-25 18:55:05 -04:00
|
|
|
if ( isset($width) ) {
|
|
|
|
$r .= "\t\t\t\t<input type='hidden' name='attachment-width-$id' id='attachment-width-$id' value='$width' />\n";
|
|
|
|
$r .= "\t\t\t\t<input type='hidden' name='attachment-height-$id' id='attachment-height-$id' value='$height' />\n";
|
|
|
|
}
|
|
|
|
$r .= "\t\t\t\t<input type='hidden' name='attachment-page-url-$id' id='attachment-page-url-$id' value='" . get_attachment_link( $id ) . "' />\n";
|
|
|
|
$r .= "\t\t\t\t<input type='hidden' name='attachment-title-$id' id='attachment-title-$id' value='$post_title' />\n";
|
|
|
|
$r .= "\t\t\t\t<input type='hidden' name='attachment-description-$id' id='attachment-description-$id' value='$post_content' />\n";
|
|
|
|
$r .= "\t\t\t</p>\n\t\t</div>\n";
|
|
|
|
return $r;
|
|
|
|
}
|
|
|
|
|
|
|
|
function wp_upload_view() {
|
2007-12-06 01:37:30 -05:00
|
|
|
global $style;
|
2006-10-25 18:55:05 -04:00
|
|
|
$id = get_the_ID();
|
2006-12-05 17:37:19 -05:00
|
|
|
$attachment_data = wp_get_attachment_metadata( $id );
|
2006-10-25 18:55:05 -04:00
|
|
|
?>
|
|
|
|
<div id="upload-file">
|
|
|
|
<div id="file-title">
|
|
|
|
<h2><?php if ( !isset($attachment_data['width']) && 'inline' != $style )
|
2007-01-02 14:28:30 -05:00
|
|
|
echo "<a href='" . wp_get_attachment_url() . "' title='" . __('Direct link to file') . "'>";
|
2006-10-25 18:55:05 -04:00
|
|
|
the_title();
|
|
|
|
if ( !isset($attachment_data['width']) && 'inline' != $style )
|
|
|
|
echo '</a>';
|
|
|
|
?></h2>
|
|
|
|
<span><?php
|
|
|
|
echo '[ ';
|
|
|
|
echo '<a href="' . get_permalink() . '">' . __('view') . '</a>';
|
|
|
|
echo ' | ';
|
2007-03-17 04:46:59 -04:00
|
|
|
echo '<a href="' . clean_url(add_query_arg('action', 'edit')) . '" title="' . __('Edit this file') . '">' . __('edit') . '</a>';
|
2006-10-25 18:55:05 -04:00
|
|
|
echo ' | ';
|
2007-03-17 04:46:59 -04:00
|
|
|
echo '<a href="' . clean_url(remove_query_arg(array('action', 'ID'))) . '" title="' . __('Browse your files') . '">' . __('cancel') . '</a>';
|
2006-10-25 18:55:05 -04:00
|
|
|
echo ' ]'; ?></span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="upload-file-view" class="alignleft">
|
|
|
|
<?php if ( isset($attachment_data['width']) && 'inline' != $style )
|
2007-01-02 14:28:30 -05:00
|
|
|
echo "<a href='" . wp_get_attachment_url() . "' title='" . __('Direct link to file') . "'>";
|
2006-10-25 18:55:05 -04:00
|
|
|
echo wp_upload_display( array(171, 128) );
|
|
|
|
if ( isset($attachment_data['width']) && 'inline' != $style )
|
|
|
|
echo '</a>'; ?>
|
|
|
|
</div>
|
|
|
|
<?php the_attachment_links( $id ); ?>
|
|
|
|
</div>
|
|
|
|
<?php echo "<form action='' id='browse-form'><input type='hidden' id='nonce-value' value='" . wp_create_nonce( 'inlineuploading' ) . "' /></form>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
function wp_upload_form() {
|
|
|
|
$id = get_the_ID();
|
|
|
|
global $post_id, $tab, $style;
|
|
|
|
$enctype = $id ? '' : ' enctype="multipart/form-data"';
|
2007-08-01 13:20:01 -04:00
|
|
|
$post_id = (int) $post_id;
|
2006-10-25 18:55:05 -04:00
|
|
|
?>
|
2007-08-01 16:58:19 -04:00
|
|
|
<form<?php echo $enctype; ?> id="upload-file" method="post" action="<?php echo get_option('siteurl') . '/wp-admin/upload.php?style=' . attribute_escape($style . '&tab=upload&post_id=' . $post_id); ?>">
|
2006-10-25 18:55:05 -04:00
|
|
|
<?php
|
|
|
|
if ( $id ) :
|
|
|
|
$attachment = get_post_to_edit( $id );
|
2006-12-05 17:37:19 -05:00
|
|
|
$attachment_data = wp_get_attachment_metadata( $id );
|
2006-10-25 18:55:05 -04:00
|
|
|
?>
|
|
|
|
<div id="file-title">
|
|
|
|
<h2><?php if ( !isset($attachment_data['width']) && 'inline' != $style )
|
2007-01-02 14:28:30 -05:00
|
|
|
echo "<a href='" . wp_get_attachment_url() . "' title='" . __('Direct link to file') . "'>";
|
2006-10-25 18:55:05 -04:00
|
|
|
the_title();
|
|
|
|
if ( !isset($attachment_data['width']) && 'inline' != $style )
|
|
|
|
echo '</a>';
|
|
|
|
?></h2>
|
|
|
|
<span><?php
|
|
|
|
echo '[ ';
|
|
|
|
echo '<a href="' . get_permalink() . '">' . __('view') . '</a>';
|
|
|
|
echo ' | ';
|
2007-03-17 04:46:59 -04:00
|
|
|
echo '<a href="' . clean_url(add_query_arg('action', 'view')) . '">' . __('links') . '</a>';
|
2006-10-25 18:55:05 -04:00
|
|
|
echo ' | ';
|
2007-03-17 04:46:59 -04:00
|
|
|
echo '<a href="' . clean_url(remove_query_arg(array('action','ID'))) . '" title="' . __('Browse your files') . '">' . __('cancel') . '</a>';
|
2006-10-25 18:55:05 -04:00
|
|
|
echo ' ]'; ?></span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="upload-file-view" class="alignleft">
|
|
|
|
<?php if ( isset($attachment_data['width']) && 'inline' != $style )
|
2007-01-02 14:28:30 -05:00
|
|
|
echo "<a href='" . wp_get_attachment_url() . "' title='" . __('Direct link to file') . "'>";
|
2006-10-25 18:55:05 -04:00
|
|
|
echo wp_upload_display( array(171, 128) );
|
|
|
|
if ( isset($attachment_data['width']) && 'inline' != $style )
|
|
|
|
echo '</a>'; ?>
|
|
|
|
</div>
|
|
|
|
<?php endif; ?>
|
|
|
|
<table><col /><col class="widefat" />
|
|
|
|
<?php if ( $id ): ?>
|
|
|
|
<tr>
|
|
|
|
<th scope="row"><label for="url"><?php _e('URL'); ?></label></th>
|
2007-01-02 14:28:30 -05:00
|
|
|
<td><input type="text" id="url" class="readonly" value="<?php echo wp_get_attachment_url(); ?>" readonly="readonly" /></td>
|
2006-10-25 18:55:05 -04:00
|
|
|
</tr>
|
|
|
|
<?php else : ?>
|
|
|
|
<tr>
|
|
|
|
<th scope="row"><label for="upload"><?php _e('File'); ?></label></th>
|
|
|
|
<td><input type="file" id="upload" name="image" /></td>
|
|
|
|
</tr>
|
|
|
|
<?php endif; ?>
|
|
|
|
<tr>
|
|
|
|
<th scope="row"><label for="post_title"><?php _e('Title'); ?></label></th>
|
|
|
|
<td><input type="text" id="post_title" name="post_title" value="<?php echo $attachment->post_title; ?>" /></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th scope="row"><label for="post_content"><?php _e('Description'); ?></label></th>
|
|
|
|
<td><textarea name="post_content" id="post_content"><?php echo $attachment->post_content; ?></textarea></td>
|
|
|
|
</tr>
|
2007-11-04 19:01:26 -05:00
|
|
|
<?php if (isset($attachment_data['image_meta'])) { ?>
|
|
|
|
<tr>
|
|
|
|
<th scope="row"><label for="url"><?php _e('Aperture'); ?></label></th>
|
|
|
|
<td>f/<?php echo $attachment_data['image_meta']['aperture']; ?></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th scope="row"><label for="url"><?php _e('Credit'); ?></label></th>
|
|
|
|
<td><?php echo $attachment_data['image_meta']['credit']; ?></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th scope="row"><label for="url"><?php _e('Camera'); ?></label></th>
|
|
|
|
<td><?php echo $attachment_data['image_meta']['camera']; ?></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th scope="row"><label for="url"><?php _e('Created'); ?></label></th>
|
|
|
|
<td><?php echo date_i18n(get_option('date_format').' '.get_option('time_format'), $attachment_data['image_meta']['created_timestamp']); ?></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th scope="row"><label for="url"><?php _e('Copyright'); ?></label></th>
|
|
|
|
<td><?php echo $attachment_data['image_meta']['copyright']; ?></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th scope="row"><label for="url"><?php _e('Focal Length'); ?></label></th>
|
|
|
|
<td><?php echo $attachment_data['image_meta']['focal_length']; ?>mm</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th scope="row"><label for="url"><?php _e('ISO'); ?></label></th>
|
|
|
|
<td><?php echo $attachment_data['image_meta']['iso']; ?></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th scope="row"><label for="url"><?php _e('Shutter Speed'); ?></label></th>
|
|
|
|
<td><?php $secs = $attachment_data['image_meta']['shutter_speed'];
|
|
|
|
echo ($secs > 0.0 and $secs < 1.0) ? ("1/" . round(1/$secs)) : ($secs); ?>s</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th scope="row"><label for="url"><?php _e('Title'); ?></label></th>
|
|
|
|
<td><?php echo $attachment_data['image_meta']['title']; ?></td>
|
|
|
|
</tr>
|
|
|
|
<?php } ?>
|
2006-10-25 18:55:05 -04:00
|
|
|
<tr id="buttons" class="submit">
|
|
|
|
<td colspan='2'>
|
|
|
|
<?php if ( $id ) : ?>
|
|
|
|
<input type="submit" name="delete" id="delete" class="delete alignleft" value="<?php _e('Delete File'); ?>" />
|
|
|
|
<?php endif; ?>
|
|
|
|
<input type="hidden" name="from_tab" value="<?php echo $tab; ?>" />
|
|
|
|
<input type="hidden" name="action" value="<?php echo $id ? 'save' : 'upload'; ?>" />
|
|
|
|
<?php if ( $post_id ) : ?>
|
|
|
|
<input type="hidden" name="post_id" value="<?php echo $post_id; ?>" />
|
|
|
|
<?php endif; if ( $id ) : ?>
|
|
|
|
<input type="hidden" name="ID" value="<?php echo $id; ?>" />
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php wp_nonce_field( 'inlineuploading' ); ?>
|
|
|
|
<div class="submit">
|
2008-02-20 14:30:55 -05:00
|
|
|
<input type="submit" value="<?php $id ? _e('Save') : _e('Upload'); ?>" />
|
2006-10-25 18:55:05 -04:00
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
function wp_upload_tab_upload() {
|
|
|
|
wp_upload_form();
|
|
|
|
}
|
|
|
|
|
|
|
|
function wp_upload_tab_upload_action() {
|
|
|
|
global $action;
|
|
|
|
if ( isset($_POST['delete']) )
|
|
|
|
$action = 'delete';
|
|
|
|
|
|
|
|
switch ( $action ) :
|
|
|
|
case 'upload' :
|
|
|
|
global $from_tab, $post_id, $style;
|
|
|
|
if ( !$from_tab )
|
|
|
|
$from_tab = 'upload';
|
|
|
|
|
|
|
|
check_admin_referer( 'inlineuploading' );
|
|
|
|
|
|
|
|
global $post_id, $post_title, $post_content;
|
|
|
|
|
|
|
|
if ( !current_user_can( 'upload_files' ) )
|
|
|
|
wp_die( __('You are not allowed to upload files.')
|
2007-08-01 16:58:19 -04:00
|
|
|
. " <a href='" . get_option('siteurl') . "/wp-admin/upload.php?style=" . attribute_escape($style . "&tab=browse-all&post_id=$post_id") . "'>"
|
2006-10-25 18:55:05 -04:00
|
|
|
. __('Browse Files') . '</a>'
|
|
|
|
);
|
|
|
|
|
|
|
|
$overrides = array('action'=>'upload');
|
|
|
|
|
|
|
|
$file = wp_handle_upload($_FILES['image'], $overrides);
|
|
|
|
|
|
|
|
if ( isset($file['error']) )
|
|
|
|
wp_die($file['error'] . "<br /><a href='" . get_option('siteurl')
|
2007-08-01 16:58:19 -04:00
|
|
|
. "/wp-admin/upload.php?style=" . attribute_escape($style . "&tab=$from_tab&post_id=$post_id") . "'>" . __('Back to Image Uploading') . '</a>'
|
2006-10-25 18:55:05 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
$url = $file['url'];
|
|
|
|
$type = $file['type'];
|
|
|
|
$file = $file['file'];
|
|
|
|
|
|
|
|
// Construct the attachment array
|
|
|
|
$attachment = array(
|
2007-06-05 00:40:10 -04:00
|
|
|
'post_title' => $post_title,
|
2006-10-25 18:55:05 -04:00
|
|
|
'post_content' => $post_content,
|
|
|
|
'post_type' => 'attachment',
|
|
|
|
'post_parent' => $post_id,
|
|
|
|
'post_mime_type' => $type,
|
|
|
|
'guid' => $url
|
|
|
|
);
|
|
|
|
|
|
|
|
// Save the data
|
|
|
|
$id = wp_insert_attachment($attachment, $file, $post_id);
|
|
|
|
|
2006-12-07 17:42:22 -05:00
|
|
|
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
|
2006-10-25 18:55:05 -04:00
|
|
|
|
|
|
|
wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=browse&action=view&ID=$id&post_id=$post_id");
|
|
|
|
die;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'save' :
|
|
|
|
global $from_tab, $post_id, $style;
|
|
|
|
if ( !$from_tab )
|
|
|
|
$from_tab = 'upload';
|
|
|
|
check_admin_referer( 'inlineuploading' );
|
|
|
|
|
|
|
|
wp_update_post($_POST);
|
|
|
|
wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=$from_tab&post_id=$post_id");
|
|
|
|
die;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'delete' :
|
|
|
|
global $ID, $post_id, $from_tab, $style;
|
|
|
|
if ( !$from_tab )
|
|
|
|
$from_tab = 'upload';
|
|
|
|
|
|
|
|
check_admin_referer( 'inlineuploading' );
|
|
|
|
|
|
|
|
if ( !current_user_can('edit_post', (int) $ID) )
|
|
|
|
wp_die( __('You are not allowed to delete this attachment.')
|
2007-08-01 16:58:19 -04:00
|
|
|
. " <a href='" . get_option('siteurl') . "/wp-admin/upload.php?style=" . attribute_escape($style . "&tab=$from_tab&post_id=$post_id") . "'>"
|
2006-10-25 18:55:05 -04:00
|
|
|
. __('Go back') . '</a>'
|
|
|
|
);
|
|
|
|
|
|
|
|
wp_delete_attachment($ID);
|
|
|
|
|
|
|
|
wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=$from_tab&post_id=$post_id" );
|
|
|
|
die;
|
|
|
|
break;
|
|
|
|
|
|
|
|
endswitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
add_action( 'upload_files_upload', 'wp_upload_tab_upload_action' );
|
|
|
|
|
|
|
|
function wp_upload_grab_attachments( $obj ) {
|
|
|
|
$obj->is_attachment = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function wp_upload_posts_where( $where ) {
|
|
|
|
global $post_id;
|
|
|
|
return $where . " AND post_parent = '" . (int) $post_id . "'";
|
|
|
|
}
|
|
|
|
|
|
|
|
function wp_upload_tab_browse() {
|
2007-05-29 00:28:10 -04:00
|
|
|
global $action, $paged;
|
2006-10-25 18:55:05 -04:00
|
|
|
$old_vars = compact( 'paged' );
|
2007-02-27 10:24:54 -05:00
|
|
|
|
2006-10-25 18:55:05 -04:00
|
|
|
switch ( $action ) :
|
|
|
|
case 'edit' :
|
|
|
|
case 'view' :
|
|
|
|
global $ID;
|
|
|
|
$attachments = query_posts("attachment_id=$ID");
|
|
|
|
if ( have_posts() ) : while ( have_posts() ) : the_post();
|
|
|
|
'edit' == $action ? wp_upload_form() : wp_upload_view();
|
|
|
|
endwhile; endif;
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
global $tab, $post_id, $style;
|
|
|
|
add_action( 'pre_get_posts', 'wp_upload_grab_attachments' );
|
|
|
|
if ( 'browse' == $tab && $post_id )
|
|
|
|
add_filter( 'posts_where', 'wp_upload_posts_where' );
|
2007-05-29 00:28:10 -04:00
|
|
|
$attachments = query_posts("what_to_show=posts&post_status=any&posts_per_page=10&paged=$paged");
|
2006-10-25 18:55:05 -04:00
|
|
|
|
|
|
|
echo "<ul id='upload-files'>\n";
|
|
|
|
if ( have_posts() ) : while ( have_posts() ) : the_post();
|
|
|
|
$href = wp_specialchars( add_query_arg( array(
|
|
|
|
'action' => 'inline' == $style ? 'view' : 'edit',
|
|
|
|
'ID' => get_the_ID())
|
|
|
|
), 1 );
|
|
|
|
|
|
|
|
echo "\t<li id='file-";
|
|
|
|
the_ID();
|
|
|
|
echo "' class='alignleft'>\n";
|
|
|
|
echo wp_upload_display( array(128,128), $href );
|
|
|
|
echo "\t</li>\n";
|
|
|
|
endwhile;
|
|
|
|
else :
|
|
|
|
echo "\t<li>" . __('There are no attachments to show.') . "</li>\n";
|
|
|
|
endif;
|
|
|
|
echo "</ul>\n\n";
|
|
|
|
|
|
|
|
echo "<form action='' id='browse-form'><input type='hidden' id='nonce-value' value='" . wp_create_nonce( 'inlineuploading' ) . "' /></form>\n";
|
|
|
|
break;
|
|
|
|
endswitch;
|
|
|
|
|
|
|
|
extract($old_vars);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function wp_upload_tab_browse_action() {
|
|
|
|
global $style;
|
|
|
|
if ( 'inline' == $style )
|
|
|
|
wp_enqueue_script('upload');
|
|
|
|
}
|
|
|
|
|
|
|
|
add_action( 'upload_files_browse', 'wp_upload_tab_browse_action' );
|
|
|
|
add_action( 'upload_files_browse-all', 'wp_upload_tab_browse_action' );
|
|
|
|
|
|
|
|
function wp_upload_admin_head() {
|
2007-08-28 19:23:38 -04:00
|
|
|
wp_admin_css( 'css/upload' );
|
2006-10-25 18:55:05 -04:00
|
|
|
if ( 'inline' == @$_GET['style'] ) {
|
2006-11-14 18:18:20 -05:00
|
|
|
echo "<style type='text/css' media='screen'>\n";
|
|
|
|
echo "\t#upload-menu { position: absolute; z-index: 2; }\n";
|
|
|
|
echo "\tbody > #upload-menu { position: fixed; }\n";
|
|
|
|
echo "\t#upload-content { top: 2em; }\n";
|
|
|
|
echo "\t#upload-file { position: absolute; top: 15px; }\n";
|
2006-10-25 18:55:05 -04:00
|
|
|
echo "</style>";
|
|
|
|
}
|
|
|
|
}
|
2007-04-13 20:11:47 -04:00
|
|
|
|
2007-05-29 00:28:10 -04:00
|
|
|
?>
|