Use wp_redirect().

git-svn-id: http://svn.automattic.com/wordpress/branches/2.0@3937 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-06-27 23:10:02 +00:00
parent 928b059aa5
commit 443cfab1a3
18 changed files with 55 additions and 57 deletions

View File

@ -32,7 +32,7 @@ case 'addcat':
wp_insert_category($_POST); wp_insert_category($_POST);
header('Location: categories.php?message=1#addcat'); wp_redirect('categories.php?message=1#addcat');
break; break;
case 'delete': case 'delete':
@ -49,7 +49,7 @@ case 'delete':
wp_delete_category($cat_ID); wp_delete_category($cat_ID);
header('Location: categories.php?message=2'); wp_redirect('categories.php?message=2');
break; break;
@ -104,7 +104,7 @@ case 'editedcat':
wp_update_category($_POST); wp_update_category($_POST);
header('Location: categories.php?message=3'); wp_redirect('categories.php?message=3');
break; break;
default: default:

View File

@ -25,7 +25,7 @@ class Blogger_Import {
// Deletes saved data and redirect. // Deletes saved data and redirect.
function restart() { function restart() {
delete_option('import-blogger'); delete_option('import-blogger');
header("Location: admin.php?import=blogger"); wp_redirect("admin.php?import=blogger");
die(); die();
} }
@ -213,7 +213,7 @@ class Blogger_Import {
// Redirects to next step // Redirects to next step
function do_next_step() { function do_next_step() {
header("Location: admin.php?import=blogger&noheader=true&blog={$_GET['blog']}"); wp_redirect("admin.php?import=blogger&noheader=true&blog={$_GET['blog']}");
die(); die();
} }
@ -273,7 +273,7 @@ class Blogger_Import {
); );
} }
update_option('import-blogger', $this->import); update_option('import-blogger', $this->import);
header("Location: admin.php?import=blogger&noheader=true&step=1"); wp_redirect("admin.php?import=blogger&noheader=true&step=1");
} }
die(); die();
} }

View File

@ -41,7 +41,7 @@ if ( !current_user_can('edit_post', (int) $attachment) )
wp_delete_attachment($attachment); wp_delete_attachment($attachment);
header("Location: " . basename(__FILE__) ."?post=$post&all=$all&action=view&start=$start"); wp_redirect(basename(__FILE__) ."?post=$post&all=$all&action=view&start=$start");
die; die;
case 'save': case 'save':
@ -102,7 +102,7 @@ if ( preg_match('!^image/!', $attachment['post_mime_type']) ) {
add_post_meta($id, '_wp_attachment_metadata', array()); add_post_meta($id, '_wp_attachment_metadata', array());
} }
header("Location: " . basename(__FILE__) . "?post=$post&all=$all&action=view&start=0"); wp_redirect(basename(__FILE__) . "?post=$post&all=$all&action=view&start=0");
die(); die();
case 'upload': case 'upload':
@ -141,7 +141,7 @@ if ( '' == $sort )
$attachments = $wpdb->get_results("SELECT ID, post_date, post_title, post_mime_type, guid FROM $wpdb->posts WHERE post_status = 'attachment' $and_type $and_post $and_user ORDER BY $sort LIMIT $start, $double", ARRAY_A); $attachments = $wpdb->get_results("SELECT ID, post_date, post_title, post_mime_type, guid FROM $wpdb->posts WHERE post_status = 'attachment' $and_type $and_post $and_user ORDER BY $sort LIMIT $start, $double", ARRAY_A);
if ( count($attachments) == 0 ) { if ( count($attachments) == 0 ) {
header("Location: " . basename(__FILE__) ."?post=$post&action=upload" ); wp_redirect( basename(__FILE__) ."?post=$post&action=upload" );
die; die;
} elseif ( count($attachments) > $num ) { } elseif ( count($attachments) > $num ) {
$next = $start + count($attachments) - $num; $next = $start + count($attachments) - $num;

View File

@ -77,7 +77,7 @@ switch ($action) {
" '$show_rating', '$show_updated', '$sort_order', '$sort_desc', '$text_before_link', '$text_after_link', \n" . " '$show_rating', '$show_updated', '$sort_order', '$sort_desc', '$text_before_link', '$text_after_link', \n" .
" '$text_after_all', $list_limit)"); " '$text_after_all', $list_limit)");
header('Location: link-categories.php'); wp_redirect('link-categories.php');
break; break;
} // end addcat } // end addcat
case 'Delete': case 'Delete':
@ -96,7 +96,7 @@ switch ($action) {
$wpdb->query("DELETE FROM $wpdb->linkcategories WHERE cat_id='$cat_id'"); $wpdb->query("DELETE FROM $wpdb->linkcategories WHERE cat_id='$cat_id'");
$wpdb->query("UPDATE $wpdb->links SET link_category=1 WHERE link_category='$cat_id'"); $wpdb->query("UPDATE $wpdb->links SET link_category=1 WHERE link_category='$cat_id'");
header('Location: link-categories.php'); wp_redirect('link-categories.php');
break; break;
} // end delete } // end delete
case 'Edit': case 'Edit':
@ -271,7 +271,7 @@ switch ($action) {
} // end if save } // end if save
header("Location: link-categories.php"); wp_redirect("link-categories.php");
break; break;
} // end editcat } // end editcat
default: default:

View File

@ -49,7 +49,7 @@ switch ($action) {
//userlevel of the owner of the link then we can proceed. //userlevel of the owner of the link then we can proceed.
if (count($linkcheck) == 0) { if (count($linkcheck) == 0) {
header('Location: ' . $this_file); wp_redirect($this_file);
exit; exit;
} }
$all_links = join(',', $linkcheck); $all_links = join(',', $linkcheck);
@ -62,7 +62,7 @@ switch ($action) {
$all_links = join(',', $ids_to_change); $all_links = join(',', $ids_to_change);
$q = $wpdb->query("update $wpdb->links SET link_owner='$newowner' WHERE link_id IN ($all_links)"); $q = $wpdb->query("update $wpdb->links SET link_owner='$newowner' WHERE link_id IN ($all_links)");
header('Location: ' . $this_file); wp_redirect($this_file);
break; break;
} }
case 'visibility': case 'visibility':
@ -75,7 +75,7 @@ switch ($action) {
//for each link id (in $linkcheck[]): toggle the visibility //for each link id (in $linkcheck[]): toggle the visibility
if (count($linkcheck) == 0) { if (count($linkcheck) == 0) {
header('Location: ' . $this_file); wp_redirect($this_file);
exit; exit;
} }
$all_links = join(',', $linkcheck); $all_links = join(',', $linkcheck);
@ -99,7 +99,7 @@ switch ($action) {
$q = $wpdb->query("update $wpdb->links SET link_visible='Y' WHERE link_id IN ($all_linkson)"); $q = $wpdb->query("update $wpdb->links SET link_visible='Y' WHERE link_id IN ($all_linkson)");
} }
header('Location: ' . $this_file); wp_redirect($this_file);
break; break;
} }
case 'move': case 'move':
@ -112,14 +112,14 @@ switch ($action) {
//for each link id (in $linkcheck[]) change category to selected value //for each link id (in $linkcheck[]) change category to selected value
if (count($linkcheck) == 0) { if (count($linkcheck) == 0) {
header('Location: ' . $this_file); wp_redirect($this_file);
exit; exit;
} }
$all_links = join(',', $linkcheck); $all_links = join(',', $linkcheck);
// should now have an array of links we can change // should now have an array of links we can change
$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)"); $q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
header('Location: ' . $this_file); wp_redirect($this_file);
break; break;
} }
@ -129,7 +129,7 @@ switch ($action) {
add_link(); add_link();
header('Location: ' . wp_get_referer() . '?added=true'); wp_redirect(wp_get_referer() . '?added=true');
break; break;
} // end Add } // end Add

View File

@ -70,7 +70,7 @@ case 'update':
} }
$file = basename(__FILE__); $file = basename(__FILE__);
header("Location: $file?ignored=$item_ignored&deleted=$item_deleted&approved=$item_approved&spam=$item_spam"); wp_redirect("$file?ignored=$item_ignored&deleted=$item_deleted&approved=$item_approved&spam=$item_spam");
exit(); exit();
break; break;

View File

@ -44,9 +44,9 @@ case 'update':
$f = fopen($real_file, 'w+'); $f = fopen($real_file, 'w+');
fwrite($f, $newcontent); fwrite($f, $newcontent);
fclose($f); fclose($f);
header("Location: plugin-editor.php?file=$file&a=te"); wp_redirect("plugin-editor.php?file=$file&a=te");
} else { } else {
header("Location: plugin-editor.php?file=$file"); wp_redirect("plugin-editor.php?file=$file");
} }
exit(); exit();

View File

@ -12,14 +12,14 @@ if ( isset($_GET['action']) ) {
include(ABSPATH . 'wp-content/plugins/' . trim( $_GET['plugin'] )); include(ABSPATH . 'wp-content/plugins/' . trim( $_GET['plugin'] ));
do_action('activate_' . trim( $_GET['plugin'] )); do_action('activate_' . trim( $_GET['plugin'] ));
} }
header('Location: plugins.php?activate=true'); wp_redirect('plugins.php?activate=true');
} else if ('deactivate' == $_GET['action']) { } else if ('deactivate' == $_GET['action']) {
check_admin_referer('deactivate-plugin_' . $_GET['plugin']); check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
$current = get_settings('active_plugins'); $current = get_settings('active_plugins');
array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu! array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu!
update_option('active_plugins', $current); update_option('active_plugins', $current);
do_action('deactivate_' . trim( $_GET['plugin'] )); do_action('deactivate_' . trim( $_GET['plugin'] ));
header('Location: plugins.php?deactivate=true'); wp_redirect('plugins.php?deactivate=true');
} }
exit; exit;
} }

View File

@ -57,7 +57,7 @@ case 'post':
if ( isset($_POST['save']) ) if ( isset($_POST['save']) )
$location = "post.php?action=edit&post=$post_ID"; $location = "post.php?action=edit&post=$post_ID";
header("Location: $location"); wp_redirect($location);
exit(); exit();
break; break;
@ -126,7 +126,7 @@ case 'editpost':
$location = 'post.php'; $location = 'post.php';
} }
header ('Location: ' . $location); // Send user on their way while we keep working wp_redirect($location); // Send user on their way while we keep working
exit(); exit();
break; break;
@ -152,7 +152,7 @@ case 'delete':
if (strstr($sendback, 'post.php')) $sendback = get_settings('siteurl') .'/wp-admin/post.php'; if (strstr($sendback, 'post.php')) $sendback = get_settings('siteurl') .'/wp-admin/post.php';
elseif (strstr($sendback, 'attachments.php')) $sendback = get_settings('siteurl') .'/wp-admin/attachments.php'; elseif (strstr($sendback, 'attachments.php')) $sendback = get_settings('siteurl') .'/wp-admin/attachments.php';
$sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
header ('Location: ' . $sendback); wp_redirect($sendback);
break; break;
case 'editcomment': case 'editcomment':
@ -236,9 +236,9 @@ case 'deletecomment':
do_action('delete_comment', $comment->comment_ID); do_action('delete_comment', $comment->comment_ID);
if ((wp_get_referer() != "") && (false == $noredir)) { if ((wp_get_referer() != "") && (false == $noredir)) {
header('Location: ' . wp_get_referer()); wp_redirect(wp_get_referer());
} else { } else {
header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments'); wp_redirect(get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
} }
break; break;
@ -263,9 +263,9 @@ case 'unapprovecomment':
wp_set_comment_status($comment->comment_ID, "hold"); wp_set_comment_status($comment->comment_ID, "hold");
if ((wp_get_referer() != "") && (false == $noredir)) { if ((wp_get_referer() != "") && (false == $noredir)) {
header('Location: ' . wp_get_referer()); wp_redirect(wp_get_referer());
} else { } else {
header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments'); wp_redirect(get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
} }
break; break;
@ -286,7 +286,7 @@ case 'mailapprovecomment':
wp_notify_postauthor($comment->comment_ID); wp_notify_postauthor($comment->comment_ID);
} }
header('Location: ' . get_option('siteurl') . '/wp-admin/moderation.php?approved=1'); wp_redirect(get_option('siteurl') . '/wp-admin/moderation.php?approved=1');
break; break;
@ -314,9 +314,9 @@ case 'approvecomment':
if ((wp_get_referer() != "") && (false == $noredir)) { if ((wp_get_referer() != "") && (false == $noredir)) {
header('Location: ' . wp_get_referer()); wp_redirect(wp_get_referer());
} else { } else {
header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments'); wp_redirect(get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
} }
break; break;
@ -332,9 +332,9 @@ case 'editedcomment':
$referredby = $_POST['referredby']; $referredby = $_POST['referredby'];
if (!empty($referredby)) { if (!empty($referredby)) {
header('Location: ' . $referredby); wp_redirect($referredby);
} else { } else {
header ("Location: edit.php?p=$comment_post_ID&c=1#comments"); wp_redirect("edit.php?p=$comment_post_ID&c=1#comments");
} }
break; break;

View File

@ -47,12 +47,12 @@ case 'update':
if ( $f ) { if ( $f ) {
fwrite($f, $newcontent); fwrite($f, $newcontent);
fclose($f); fclose($f);
header("Location: templates.php?file=$file&a=te"); wp_redirect("templates.php?file=$file&a=te");
} else { } else {
header("Location: templates.php?file=$file&a=err"); wp_redirect("templates.php?file=$file&a=err");
} }
} else { } else {
header("Location: templates.php?file=$file&a=err"); wp_redirect("templates.php?file=$file&a=err");
} }
exit(); exit();

View File

@ -58,9 +58,9 @@ case 'update':
$f = fopen($real_file, 'w+'); $f = fopen($real_file, 'w+');
fwrite($f, $newcontent); fwrite($f, $newcontent);
fclose($f); fclose($f);
header("Location: theme-editor.php?file=$file&theme=$theme&a=te"); wp_redirect("theme-editor.php?file=$file&theme=$theme&a=te");
} else { } else {
header("Location: theme-editor.php?file=$file&theme=$theme"); wp_redirect("theme-editor.php?file=$file&theme=$theme");
} }
exit(); exit();

View File

@ -13,7 +13,7 @@ if ( isset($_GET['action']) ) {
do_action('switch_theme', get_current_theme()); do_action('switch_theme', get_current_theme());
header('Location: themes.php?activated=true'); wp_redirect('themes.php?activated=true');
exit; exit;
} }
} }

View File

@ -42,7 +42,7 @@ else
$errors = edit_user($user_id); $errors = edit_user($user_id);
if(count($errors) == 0) { if(count($errors) == 0) {
header("Location: user-edit.php?user_id=$user_id&updated=true"); wp_redirect("user-edit.php?user_id=$user_id&updated=true");
exit; exit;
} }

View File

@ -14,7 +14,7 @@ case 'promote':
check_admin_referer('bulk-users'); check_admin_referer('bulk-users');
if (empty($_POST['users'])) { if (empty($_POST['users'])) {
header('Location: users.php'); wp_redirect('users.php');
} }
if ( !current_user_can('edit_users') ) if ( !current_user_can('edit_users') )
@ -33,7 +33,7 @@ case 'promote':
$user->set_role($_POST['new_role']); $user->set_role($_POST['new_role']);
} }
header('Location: users.php?update=' . $update); wp_redirect('users.php?update=' . $update);
break; break;
@ -42,7 +42,7 @@ case 'dodelete':
check_admin_referer('delete-users'); check_admin_referer('delete-users');
if ( empty($_POST['users']) ) { if ( empty($_POST['users']) ) {
header('Location: users.php'); wp_redirect('users.php');
} }
if ( !current_user_can('edit_users') ) if ( !current_user_can('edit_users') )
@ -66,7 +66,7 @@ case 'dodelete':
} }
} }
header('Location: users.php?update=' . $update); wp_redirect('users.php?update=' . $update);
break; break;
@ -74,9 +74,8 @@ case 'delete':
check_admin_referer('bulk-users'); check_admin_referer('bulk-users');
if (empty($_POST['users'])) { if ( empty($_POST['users']) )
header('Location: users.php'); wp_redirect('users.php');
}
if ( !current_user_can('edit_users') ) if ( !current_user_can('edit_users') )
$error['edit_users'] = __('You can’t delete users.'); $error['edit_users'] = __('You can’t delete users.');
@ -137,7 +136,7 @@ case 'adduser':
$errors = add_user(); $errors = add_user();
if(count($errors) == 0) { if(count($errors) == 0) {
header('Location: users.php?update=add'); wp_redirect('users.php?update=add');
die(); die();
} }

View File

@ -123,7 +123,7 @@ function kubrick_add_theme_page() {
} }
} }
//print_r($_REQUEST); //print_r($_REQUEST);
header("Location: themes.php?page=functions.php&saved=true"); wp_redirect("themes.php?page=functions.php&saved=true");
die; die;
} }
add_action('admin_head', 'kubrick_theme_page_head'); add_action('admin_head', 'kubrick_theme_page_head');

View File

@ -221,7 +221,7 @@ function auth_redirect() {
(empty($_COOKIE[USER_COOKIE])) ) { (empty($_COOKIE[USER_COOKIE])) ) {
nocache_headers(); nocache_headers();
header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI'])); wp_redirect(get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
exit(); exit();
} }
} }

View File

@ -27,7 +27,7 @@ case 'logout':
$redirect_to = 'wp-login.php'; $redirect_to = 'wp-login.php';
if ( isset($_REQUEST['redirect_to']) ) if ( isset($_REQUEST['redirect_to']) )
$redirect_to = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $_REQUEST['redirect_to']); $redirect_to = $_REQUEST['redirect_to'];
wp_redirect($redirect_to); wp_redirect($redirect_to);
exit(); exit();
@ -170,7 +170,6 @@ default:
$redirect_to = 'wp-admin/'; $redirect_to = 'wp-admin/';
else else
$redirect_to = $_REQUEST['redirect_to']; $redirect_to = $_REQUEST['redirect_to'];
$redirect_to = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $redirect_to);
if( $_POST ) { if( $_POST ) {
$user_login = $_POST['log']; $user_login = $_POST['log'];
@ -237,7 +236,7 @@ if ( $error )
<?php _e('Remember me'); ?></label></p> <?php _e('Remember me'); ?></label></p>
<p class="submit"> <p class="submit">
<input type="submit" name="submit" id="submit" value="<?php _e('Login'); ?> &raquo;" tabindex="4" /> <input type="submit" name="submit" id="submit" value="<?php _e('Login'); ?> &raquo;" tabindex="4" />
<input type="hidden" name="redirect_to" value="<?php echo $redirect_to; ?>" /> <input type="hidden" name="redirect_to" value="<?php echo wp_specialchars($redirect_to); ?>" />
</p> </p>
</form> </form>
<ul> <ul>

View File

@ -55,7 +55,7 @@ if ( !intval( $tb_id ) )
if (empty($title) && empty($tb_url) && empty($blog_name)) { if (empty($title) && empty($tb_url) && empty($blog_name)) {
// If it doesn't look like a trackback at all... // If it doesn't look like a trackback at all...
header('Location: ' . get_permalink($tb_id)); wp_redirect(get_permalink($tb_id));
exit; exit;
} }