Fix edit.php row action redirects when referrers are not sent. Return false from wp_get_referer() when no referrer found. Props mitchoyoshitaka. fixes #17628
git-svn-id: http://svn.automattic.com/wordpress/trunk@19272 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6566ac849d
commit
0ec7ae44ca
|
@ -51,6 +51,8 @@ if ( $doaction ) {
|
||||||
check_admin_referer('bulk-posts');
|
check_admin_referer('bulk-posts');
|
||||||
|
|
||||||
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
|
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() );
|
||||||
|
if ( ! $sendback )
|
||||||
|
$sendback = admin_url( $parent_file );
|
||||||
$sendback = add_query_arg( 'paged', $pagenum, $sendback );
|
$sendback = add_query_arg( 'paged', $pagenum, $sendback );
|
||||||
if ( strpos($sendback, 'post.php') !== false )
|
if ( strpos($sendback, 'post.php') !== false )
|
||||||
$sendback = admin_url($post_new_file);
|
$sendback = admin_url($post_new_file);
|
||||||
|
|
|
@ -82,9 +82,11 @@ elseif ( isset($_POST['wp-preview']) && 'dopreview' == $_POST['wp-preview'] )
|
||||||
$action = 'preview';
|
$action = 'preview';
|
||||||
|
|
||||||
$sendback = wp_get_referer();
|
$sendback = wp_get_referer();
|
||||||
if ( strpos($sendback, 'post.php') !== false || strpos($sendback, 'post-new.php') !== false ) {
|
if ( ! $sendback ||
|
||||||
$sendback = admin_url('edit.php');
|
strpos( $sendback, 'post.php' ) !== false ||
|
||||||
$sendback .= ( !empty( $post_type ) ) ? '?post_type=' . $post_type : '';
|
strpos( $sendback, 'post-new.php' ) !== false ) {
|
||||||
|
$sendback = admin_url( 'edit.php' );
|
||||||
|
$sendback .= ( ! empty( $post_type ) ) ? '?post_type=' . $post_type : '';
|
||||||
} else {
|
} else {
|
||||||
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), $sendback );
|
$sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), $sendback );
|
||||||
}
|
}
|
||||||
|
|
|
@ -2037,7 +2037,8 @@ function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve referer from '_wp_http_referer', HTTP referer, or current page respectively.
|
* Retrieve referer from '_wp_http_referer' or HTTP referer. If it's the same
|
||||||
|
* as the current request URL, will return false.
|
||||||
*
|
*
|
||||||
* @package WordPress
|
* @package WordPress
|
||||||
* @subpackage Security
|
* @subpackage Security
|
||||||
|
@ -2046,13 +2047,13 @@ function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
|
||||||
* @return string|bool False on failure. Referer URL on success.
|
* @return string|bool False on failure. Referer URL on success.
|
||||||
*/
|
*/
|
||||||
function wp_get_referer() {
|
function wp_get_referer() {
|
||||||
$ref = '';
|
$ref = false;
|
||||||
if ( ! empty( $_REQUEST['_wp_http_referer'] ) )
|
if ( ! empty( $_REQUEST['_wp_http_referer'] ) )
|
||||||
$ref = $_REQUEST['_wp_http_referer'];
|
$ref = $_REQUEST['_wp_http_referer'];
|
||||||
else if ( ! empty( $_SERVER['HTTP_REFERER'] ) )
|
else if ( ! empty( $_SERVER['HTTP_REFERER'] ) )
|
||||||
$ref = $_SERVER['HTTP_REFERER'];
|
$ref = $_SERVER['HTTP_REFERER'];
|
||||||
|
|
||||||
if ( $ref !== $_SERVER['REQUEST_URI'] )
|
if ( $ref && $ref !== $_SERVER['REQUEST_URI'] )
|
||||||
return $ref;
|
return $ref;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue