Media edit and delete redirect fixes. WIP.
git-svn-id: http://svn.automattic.com/wordpress/trunk@7542 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
efef565261
commit
b9fff33927
|
@ -10,11 +10,23 @@ wp_reset_vars(array('action'));
|
|||
switch( $action ) :
|
||||
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') )
|
||||
$location = $referer;
|
||||
}
|
||||
if ( false !== strpos($referer, 'upload.php') ) {
|
||||
$location = remove_query_arg('message', $location);
|
||||
$location = add_query_arg('posted', $attachment_id, $location);
|
||||
} else {
|
||||
$location = add_query_arg('message', 'updated', $location);
|
||||
}
|
||||
wp_redirect($location);
|
||||
exit;
|
||||
break;
|
||||
}
|
||||
|
||||
// no break
|
||||
case 'edit' :
|
||||
$title = __('Edit Media');
|
||||
|
@ -65,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>
|
||||
|
||||
|
|
|
@ -18,12 +18,16 @@ if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) {
|
|||
wp_die( __('Error in deleting...') );
|
||||
}
|
||||
|
||||
$sendback = wp_get_referer();
|
||||
if (strpos($sendback, 'media.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/media.php';
|
||||
$sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
|
||||
$location = 'upload.php';
|
||||
if ( $referer = wp_get_referer() ) {
|
||||
if ( false !== strpos($referer, 'upload.php') )
|
||||
$location = $referer;
|
||||
}
|
||||
|
||||
wp_redirect($sendback);
|
||||
exit();
|
||||
$location = add_query_arg('message', 2, $location);
|
||||
$location = remove_query_arg('posted', $location);
|
||||
wp_redirect($location);
|
||||
exit;
|
||||
} elseif ( !empty($_GET['_wp_http_referer']) ) {
|
||||
wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
|
||||
exit;
|
||||
|
@ -107,9 +111,17 @@ unset($type_links);
|
|||
|
||||
<?php
|
||||
if ( isset($_GET['posted']) && $_GET['posted'] ) : $_GET['posted'] = (int) $_GET['posted']; ?>
|
||||
<div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View post'); ?></a> | <a href="post.php?action=edit&post=<?php echo $_GET['posted']; ?>"><?php _e('Edit post'); ?></a></p></div>
|
||||
<div id="message" class="updated fade"><p><strong><?php _e('Your media has been saved.'); ?></strong> <a href="<?php echo get_permalink( $_GET['posted'] ); ?>"><?php _e('View media'); ?></a> | <a href="media.php?action=edit&attachment_id=<?php echo $_GET['posted']; ?>"><?php _e('Edit media'); ?></a></p></div>
|
||||
<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
|
||||
endif;
|
||||
|
||||
$messages[1] = __('Media updated.');
|
||||
$messages[2] = __('Media deleted.');
|
||||
|
||||
if (isset($_GET['message'])) : ?>
|
||||
<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
|
||||
<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
|
||||
endif;
|
||||
?>
|
||||
|
||||
<p id="post-search">
|
||||
|
|
Loading…
Reference in New Issue