summaryrefslogtreecommitdiffstats
path: root/wp-admin/media.php
diff options
context:
space:
mode:
Diffstat (limited to 'wp-admin/media.php')
-rw-r--r--wp-admin/media.php29
1 files changed, 22 insertions, 7 deletions
diff --git a/wp-admin/media.php b/wp-admin/media.php
index bd64104..b280d3a 100644
--- a/wp-admin/media.php
+++ b/wp-admin/media.php
@@ -8,15 +8,25 @@ $submenu_file = 'upload.php';
wp_reset_vars(array('action'));
switch( $action ) :
-case 'upload' :
-case 'delete' : break; // stubs
case 'editattachment' :
$errors = media_upload_form_handler();
+ $attachment_id = (int) $_POST['attachment_id'];
if ( empty($errors) ) {
- wp_redirect( add_query_arg( 'message', 'updated' ) );
+ $location = 'media.php';
+ if ( $referer = wp_get_original_referer() ) {
+ if ( false !== strpos($referer, 'upload.php') || ( url_to_postid($referer) == $attachment_id ) )
+ $location = $referer;
+ }
+ if ( false !== strpos($location, 'upload.php') ) {
+ $location = remove_query_arg('message', $location);
+ $location = add_query_arg('posted', $attachment_id, $location);
+ } elseif ( false !== strpos($location, 'media.php') ) {
+ $location = add_query_arg('message', 'updated', $location);
+ }
+ wp_redirect($location);
exit;
- break;
}
+
// no break
case 'edit' :
$title = __('Edit Media');
@@ -67,7 +77,9 @@ case 'edit' :
<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="attachment_id" id="attachment_id" value="<?php echo $att_id; ?>" />
<input type="hidden" name="action" value="editattachment" />
+<?php wp_original_referer_field(true, 'previous'); ?>
<?php wp_nonce_field('media-form'); ?>
</p>
@@ -78,10 +90,13 @@ case 'edit' :
require( 'admin-footer.php' );
- break;
+ exit;
+
+default:
+ wp_redirect( 'upload.php' );
+ exit;
+
endswitch;
-wp_redirect( 'upload.php' );
-exit;
?>