From 585f442ec549ff9873684e8ce37e598a9f9a9119 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 27 Mar 2008 22:05:51 +0000 Subject: [PATCH] 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 --- wp-admin/media.php | 6 +++--- wp-includes/rewrite.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/wp-admin/media.php b/wp-admin/media.php index da087614c..b280d3ab0 100644 --- a/wp-admin/media.php +++ b/wp-admin/media.php @@ -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); diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index cb5819068..c984e5096 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -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;