"Go back" link for admin-initiated post/page edits. e.g. do a search, edit a post, click the link to go back to the search.

git-svn-id: https://develop.svn.wordpress.org/trunk@7438 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith
2008-03-21 03:31:12 +00:00
parent f99aa53f68
commit 29475bd4be
5 changed files with 34 additions and 22 deletions
+6 -5
View File
@@ -1,13 +1,13 @@
<?php
$action = isset($action)? $action : '';
if ( isset($_GET['message']) )
$_GET['message'] = (int) $_GET['message'];
$messages[1] = __('Post updated');
$messages[2] = __('Custom field updated');
$_GET['message'] = absint( $_GET['message'] );
$messages[1] = sprintf( __( 'Post updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( $_GET['_wp_original_http_referer'] ) ) );
$messages[2] = __('Custom field updated.');
$messages[3] = __('Custom field deleted.');
?>
<?php if (isset($_GET['message'])) : ?>
<div id="message" class="updated fade"><p><?php echo wp_specialchars($messages[$_GET['message']]); ?></p></div>
<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
<?php endif; ?>
<form name="post" action="post.php" method="post" id="post">
@@ -59,11 +59,12 @@ $saveasdraft = '<input name="save" type="submit" id="save" class="button" tabind
<input name="referredby" type="hidden" id="referredby" value="<?php
if ( !empty($_REQUEST['popupurl']) )
echo clean_url(stripslashes($_REQUEST['popupurl']));
else if ( url_to_postid(wp_get_referer()) == $post_ID )
else if ( url_to_postid(wp_get_referer()) == $post_ID && strpos( wp_get_referer(), '/wp-admin/' ) === false )
echo 'redo';
else
echo clean_url(stripslashes(wp_get_referer()));
?>" />
<?php wp_original_referer_field(true, 'previous'); ?>
<?php echo $form_extra ?>
+9 -1
View File
@@ -1,4 +1,11 @@
<?php
if ( isset($_GET['message']) )
$_GET['message'] = absint( $_GET['message'] );
$messages[1] = sprintf( __( 'Page updated. Continue editing below or <a href="%s">go back</a>.' ), attribute_escape( stripslashes( $_GET['_wp_original_http_referer'] ) ) );
?>
<?php if (isset($_GET['message'])) : ?>
<div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
<?php endif;
if (!isset($post_ID) || 0 == $post_ID) {
$form_action = 'post';
@@ -38,11 +45,12 @@ if (isset($mode) && 'bookmarklet' == $mode)
<input type="hidden" id="post_type" name="post_type" value="<?php echo $post->post_type ?>" />
<input type="hidden" id="original_post_status" name="original_post_status" value="<?php echo $post->post_status ?>" />
<input name="referredby" type="hidden" id="referredby" value="<?php
if ( url_to_postid(wp_get_referer()) == $post_ID )
if ( url_to_postid(wp_get_referer()) == $post_ID && strpos( wp_get_referer(), '/wp-admin/' ) === false )
echo 'redo';
else
echo clean_url(stripslashes(wp_get_referer()));
?>" />
<?php wp_original_referer_field(true, 'previous'); ?>
<div id="poststuff">
+4 -1
View File
@@ -123,7 +123,10 @@ case 'editpost':
$referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer());
if ( isset($_POST['save']) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) {
$location = "page.php?action=edit&post=$page_ID";
if ( $_POST['_wp_original_http_referer'] && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post.php') === false )
$location = add_query_arg( '_wp_original_http_referer', urlencode( stripslashes( $_POST['_wp_original_http_referer'] ) ), "page.php?action=edit&post=$page_ID&message=1" );
else
$location = "page.php?action=edit&post=$page_ID";
} elseif ($_POST['addmeta']) {
$location = add_query_arg( 'message', 2, wp_get_referer() );
$location = explode('#', $location);
+4 -1
View File
@@ -136,7 +136,10 @@ case 'editpost':
$referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer());
if ( isset($_POST['save']) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) {
$location = "post.php?action=edit&post=$post_ID";
if ( $_POST['_wp_original_http_referer'] && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post.php') === false )
$location = add_query_arg( '_wp_original_http_referer', urlencode( stripslashes( $_POST['_wp_original_http_referer'] ) ), "post.php?action=edit&post=$post_ID&message=1" );
else
$location = "post.php?action=edit&post=$post_ID";
} elseif (isset($_POST['addmeta']) && $_POST['addmeta']) {
$location = add_query_arg( 'message', 2, wp_get_referer() );
$location = explode('#', $location);