Changeset 7527 for trunk/wp-admin/post.php
- Timestamp:
- 03/26/2008 06:55:24 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/post.php
r7438 r7527 6 6 7 7 wp_reset_vars(array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder')); 8 9 function redirect_post($post_ID = '') { 10 global $action; 11 12 $referredby = ''; 13 if ( !empty($_POST['referredby']) ) 14 $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']); 15 $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer()); 16 17 if ( 'post' == $_POST['originalaction'] && !empty($_POST['mode']) && 'bookmarklet' == $_POST['mode'] ) { 18 $location = $_POST['referredby']; 19 } elseif ( 'post' == $_POST['originalaction'] && !empty($_POST['mode']) && 'sidebar' == $_POST['mode'] ) { 20 $location = 'sidebar.php?a=b'; 21 } elseif ( isset($_POST['save']) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) { 22 if ( $_POST['_wp_original_http_referer'] && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post.php') === false ) 23 $location = add_query_arg( '_wp_original_http_referer', urlencode( stripslashes( $_POST['_wp_original_http_referer'] ) ), "post.php?action=edit&post=$post_ID&message=1" ); 24 else 25 $location = "post.php?action=edit&post=$post_ID&message=4"; 26 } elseif (isset($_POST['addmeta']) && $_POST['addmeta']) { 27 $location = add_query_arg( 'message', 2, wp_get_referer() ); 28 $location = explode('#', $location); 29 $location = $location[0] . '#postcustom'; 30 } elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) { 31 $location = add_query_arg( 'message', 3, wp_get_referer() ); 32 $location = explode('#', $location); 33 $location = $location[0] . '#postcustom'; 34 } elseif (!empty($referredby) && $referredby != $referer) { 35 $location = $_POST['referredby']; 36 if ( $_POST['referredby'] == 'redo' ) 37 $location = get_permalink( $post_ID ); 38 elseif ( false !== strpos($location, 'edit.php') ) 39 $location = add_query_arg('posted', $post_ID, $location); 40 elseif ( false !== strpos($location, 'wp-admin') ) 41 $location = "post-new.php?posted=$post_ID"; 42 } elseif ( isset($_POST['publish']) ) { 43 $location = "post-new.php?posted=$post_ID"; 44 } elseif ($action == 'editattachment') { 45 $location = 'attachments.php'; 46 } else { 47 $location = "post.php?action=edit&post=$post_ID&message=4"; 48 } 49 50 wp_redirect( $location ); 51 } 8 52 9 53 if ( isset( $_POST['deletepost'] ) ) … … 17 61 $post_ID = 'post' == $action ? write_post() : edit_post(); 18 62 19 // Redirect. 20 if ( !empty( $_POST['mode'] ) ) { 21 switch($_POST['mode']) { 22 case 'bookmarklet': 23 $location = $_POST['referredby']; 24 break; 25 case 'sidebar': 26 $location = 'sidebar.php?a=b'; 27 break; 28 default: 29 $location = 'post-new.php'; 30 break; 31 } 32 } else { 33 $location = "post-new.php?posted=$post_ID"; 34 } 35 36 if ( isset( $_POST['save'] ) ) 37 $location = "post.php?action=edit&post=$post_ID"; 38 39 if ( empty( $post_ID ) ) 40 $location = 'post-new.php'; 41 42 wp_redirect( $location ); 63 redirect_post($post_ID); 43 64 exit(); 44 65 break; … … 109 130 110 131 $post_ID = edit_post(); 111 $post = get_post($post_ID);112 132 113 if ( 'post' == $_POST['originalaction'] ) { 114 if (!empty($_POST['mode'])) { 115 switch($_POST['mode']) { 116 case 'bookmarklet': 117 $location = $_POST['referredby']; 118 break; 119 case 'sidebar': 120 $location = 'sidebar.php?a=b'; 121 break; 122 default: 123 $location = 'post-new.php'; 124 break; 125 } 126 } else { 127 $location = "post-new.php?posted=$post_ID"; 128 } 129 130 if ( isset($_POST['save']) ) 131 $location = "post.php?action=edit&post=$post_ID"; 132 } else { 133 $referredby = ''; 134 if ( !empty($_POST['referredby']) ) 135 $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']); 136 $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer()); 137 138 if ( isset($_POST['save']) && ( empty($referredby) || $referredby == $referer || 'redo' != $referredby ) ) { 139 if ( $_POST['_wp_original_http_referer'] && strpos( $_POST['_wp_original_http_referer'], '/wp-admin/post.php') === false ) 140 $location = add_query_arg( '_wp_original_http_referer', urlencode( stripslashes( $_POST['_wp_original_http_referer'] ) ), "post.php?action=edit&post=$post_ID&message=1" ); 141 else 142 $location = "post.php?action=edit&post=$post_ID"; 143 } elseif (isset($_POST['addmeta']) && $_POST['addmeta']) { 144 $location = add_query_arg( 'message', 2, wp_get_referer() ); 145 $location = explode('#', $location); 146 $location = $location[0] . '#postcustom'; 147 } elseif (isset($_POST['deletemeta']) && $_POST['deletemeta']) { 148 $location = add_query_arg( 'message', 3, wp_get_referer() ); 149 $location = explode('#', $location); 150 $location = $location[0] . '#postcustom'; 151 } elseif (!empty($referredby) && $referredby != $referer) { 152 $location = $_POST['referredby']; 153 if ( $_POST['referredby'] == 'redo' ) 154 $location = get_permalink( $post_ID ); 155 if (false !== strpos($location, 'edit.php') ) 156 $location = add_query_arg('posted', $post_ID, $location); 157 } elseif ( isset($_POST['publish']) ) { 158 $location = "post-new.php?posted=$post_ID"; 159 } elseif ($action == 'editattachment') { 160 $location = 'attachments.php'; 161 } else { 162 $location = "post.php?action=edit&post=$post_ID"; 163 } 164 } 165 166 wp_redirect($location); // Send user on their way while we keep working 133 redirect_post($post_ID); // Send user on their way while we keep working 167 134 168 135 exit();
Note: See TracChangeset
for help on using the changeset viewer.