Redirect back to attachment permalink page after editing attachment via 'Edit This' link.

git-svn-id: http://svn.automattic.com/wordpress/trunk@7554 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-03-27 22:05:51 +00:00
parent f37928e5e5
commit 585f442ec5
2 changed files with 4 additions and 4 deletions

View File

@ -14,13 +14,13 @@ case 'editattachment' :
if ( empty($errors) ) {
$location = 'media.php';
if ( $referer = wp_get_original_referer() ) {
if ( false !== strpos($referer, 'upload.php') )
if ( false !== strpos($referer, 'upload.php') || ( url_to_postid($referer) == $attachment_id ) )
$location = $referer;
}
if ( false !== strpos($referer, 'upload.php') ) {
if ( false !== strpos($location, 'upload.php') ) {
$location = remove_query_arg('message', $location);
$location = add_query_arg('posted', $attachment_id, $location);
} else {
} elseif ( false !== strpos($location, 'media.php') ) {
$location = add_query_arg('message', 'updated', $location);
}
wp_redirect($location);

View File

@ -67,7 +67,7 @@ function url_to_postid($url) {
$url = apply_filters('url_to_postid', $url);
// First, check to see if there is a 'p=N' or 'page_id=N' to match against
if ( preg_match('#[?&](p|page_id)=(\d+)#', $url, $values) ) {
if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) ) {
$id = absint($values[2]);
if ($id)
return $id;