"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: http://svn.automattic.com/wordpress/trunk@7438 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ef8ff2324c
commit
62642cb9fe
|
@ -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 ?>
|
||||
|
||||
|
|
|
@ -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">
|
||||
|
||||
|
|
|
@ -123,6 +123,9 @@ case 'editpost':
|
|||
$referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer());
|
||||
|
||||
if ( isset($_POST['save']) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) {
|
||||
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() );
|
||||
|
|
|
@ -136,6 +136,9 @@ case 'editpost':
|
|||
$referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer());
|
||||
|
||||
if ( isset($_POST['save']) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) {
|
||||
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() );
|
||||
|
|
|
@ -981,42 +981,39 @@ function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $ec
|
|||
echo $nonce_field;
|
||||
|
||||
if ( $referer )
|
||||
wp_referer_field( $echo );
|
||||
wp_referer_field( $echo, 'previous' );
|
||||
|
||||
return $nonce_field;
|
||||
}
|
||||
|
||||
|
||||
function wp_referer_field( $echo = true ) {
|
||||
function wp_referer_field( $echo = true) {
|
||||
$ref = attribute_escape( $_SERVER['REQUEST_URI'] );
|
||||
$referer_field = '<input type="hidden" name="_wp_http_referer" value="'. $ref . '" />';
|
||||
|
||||
if ( wp_get_original_referer() ) {
|
||||
$original_ref = attribute_escape( stripslashes( wp_get_original_referer() ) );
|
||||
$referer_field .= "\n".'<input type="hidden" name="_wp_original_http_referer" value="'. $original_ref . '" />';
|
||||
}
|
||||
|
||||
if ( $echo )
|
||||
echo $referer_field;
|
||||
|
||||
return $referer_field;
|
||||
}
|
||||
|
||||
|
||||
function wp_original_referer_field( $echo = true ) {
|
||||
$orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . attribute_escape( stripslashes( $_SERVER['REQUEST_URI'] ) ) . '" />';
|
||||
function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
|
||||
$jump_back_to = ( 'previous' == $jump_back_to ) ? wp_get_referer() : $_SERVER['REQUEST_URI'];
|
||||
$ref = ( wp_get_original_referer() ) ? wp_get_original_referer() : $jump_back_to;
|
||||
$orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . attribute_escape( stripslashes( $ref ) ) . '" />';
|
||||
if ( $echo )
|
||||
echo $orig_referer_field;
|
||||
|
||||
return $orig_referer_field;
|
||||
}
|
||||
|
||||
|
||||
function wp_get_referer() {
|
||||
if ( ! empty( $_REQUEST['_wp_http_referer'] ) )
|
||||
return $_REQUEST['_wp_http_referer'];
|
||||
$ref = $_REQUEST['_wp_http_referer'];
|
||||
else if ( ! empty( $_SERVER['HTTP_REFERER'] ) )
|
||||
return $_SERVER['HTTP_REFERER'];
|
||||
$ref = $_SERVER['HTTP_REFERER'];
|
||||
|
||||
if ( $ref !== $_SERVER['REQUEST_URI'] )
|
||||
return $ref;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue