Ticket #7001: admin_ssl.3.diff

File admin_ssl.3.diff, 22.8 KB (added by ryan, 5 years ago)

More use of admin_url() and site_url()

Line 
1Index: wp-login.php
2===================================================================
3--- wp-login.php        (revision 7994)
4+++ wp-login.php        (working copy)
5@@ -137,7 +137,7 @@
6        $message .= get_option('siteurl') . "\r\n\r\n";
7        $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
8        $message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
9-       $message .= get_option('siteurl') . "/wp-login.php?action=rp&key=$key\r\n";
10+       $message .= site_url("wp-login.php?action=rp&key=$key") . "\r\n";
11 
12        if ( !wp_mail($user_email, sprintf(__('[%s] Password Reset'), get_option('blogname')), $message) )
13                die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
14@@ -174,7 +174,7 @@
15        wp_set_password($new_pass, $user->ID);
16        $message  = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
17        $message .= sprintf(__('Password: %s'), $new_pass) . "\r\n";
18-       $message .= get_option('siteurl') . "/wp-login.php\r\n";
19+       $message .= site_url('wp-login.php') . "\r\n";
20 
21        if (  !wp_mail($user->user_email, sprintf(__('[%s] Your new password'), get_option('blogname')), $message) )
22                die('<p>' . __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') . '</p>');
23@@ -405,7 +405,7 @@
24        if ( !is_wp_error($user) ) {
25                // If the user can't edit posts, send them to their profile.
26                if ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' ) )
27-                       $redirect_to = get_option('siteurl') . '/wp-admin/profile.php';
28+                       $redirect_to = admin_url('profile.php');
29                wp_safe_redirect($redirect_to);
30                exit();
31        }
32Index: wp-includes/functions.php
33===================================================================
34--- wp-includes/functions.php   (revision 7994)
35+++ wp-includes/functions.php   (working copy)
36@@ -1765,4 +1765,7 @@
37        return 0;
38 }
39 
40+function is_ssl() {
41+       return ( 'on' == strtolower($_SERVER['HTTPS']) ) ? true : false;
42+}
43 ?>
44Index: wp-includes/media.php
45===================================================================
46--- wp-includes/media.php       (revision 7994)
47+++ wp-includes/media.php       (working copy)
48@@ -306,7 +306,7 @@
49                return $image;
50 
51        if ( $icon && $src = wp_mime_type_icon($attachment_id) ) {
52-               $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/crystal' );
53+               $icon_dir = apply_filters( 'icon_dir', includes_url('images/crystal') );
54                $src_file = $icon_dir . '/' . basename($src);
55                @list($width, $height) = getimagesize($src_file);
56        }
57Index: wp-includes/link-template.php
58===================================================================
59--- wp-includes/link-template.php       (revision 7994)
60+++ wp-includes/link-template.php       (working copy)
61@@ -774,4 +774,42 @@
62 
63        return apply_filters('shortcut_link', $link);
64 }
65+
66+// return the site_url option, using https if is_ssl() is true
67+// if $scheme is 'http' or 'https' it will override is_ssl()
68+function site_url($path = '', $scheme = null) {
69+       // should the list of allowed schemes be maintained elsewhere?
70+       if ( !in_array($scheme, array('http', 'https')) )
71+               $scheme = ( is_ssl() ? 'https' : 'http' );
72+
73+       $url = str_replace( 'http://', "{$scheme}://", get_option('siteurl') );
74+
75+       if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
76+               $url .= '/' . ltrim($path, '/');
77+
78+       return $url;
79+}
80+
81+function admin_url($path = '') {
82+       global $_wp_admin_url;
83+
84+       $url = site_url() . '/wp-admin/';
85+
86+       if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
87+               $url .= ltrim($path, '/');
88+
89+       return $url;
90+}
91+
92+function includes_url($path = '') {
93+       global $_wp_includes_url;
94+
95+       $url = site_url() . '/' . WPINC . '/';
96+
97+       if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
98+               $url .= ltrim($path, '/');
99+
100+       return $url;
101+}
102+
103 ?>
104Index: wp-includes/general-template.php
105===================================================================
106--- wp-includes/general-template.php    (revision 7994)
107+++ wp-includes/general-template.php    (working copy)
108@@ -1139,7 +1139,7 @@
109        if ( defined('WP_INSTALLING') ) {
110                $_file = "./$file.css";
111        } else {
112-               $_file = get_option( 'siteurl' ) . "/wp-admin/$file.css";
113+               $_file = admin_url("$file.css");
114        }
115        $_file = add_query_arg( 'version', get_bloginfo( 'version' ),  $_file );
116 
117Index: wp-includes/pluggable.php
118===================================================================
119--- wp-includes/pluggable.php   (revision 7996)
120+++ wp-includes/pluggable.php   (working copy)
121@@ -469,9 +469,14 @@
122  */
123 function wp_validate_auth_cookie($cookie = '') {
124        if ( empty($cookie) ) {
125-               if ( empty($_COOKIE[AUTH_COOKIE]) )
126+               if ( is_ssl() )
127+                       $cookie_name = SECURE_AUTH_COOKIE;
128+               else
129+                       $cookie_name = AUTH_COOKIE;
130+
131+               if ( empty($_COOKIE[$cookie_name]) )
132                        return false;
133-               $cookie = $_COOKIE[AUTH_COOKIE];
134+               $cookie = $_COOKIE[$cookie_name];
135        }
136 
137        $cookie_elements = explode('|', $cookie);
138@@ -514,9 +519,10 @@
139  *
140  * @param int $user_id User ID
141  * @param int $expiration Cookie expiration in seconds
142+ * @param bool $secure Whether the cookie is for https delivery only or not.  Not used by default.  For plugin use.
143  * @return string Authentication cookie contents
144  */
145-function wp_generate_auth_cookie($user_id, $expiration) {
146+function wp_generate_auth_cookie($user_id, $expiration, $secure = false) {
147        $user = get_userdata($user_id);
148 
149        $key = wp_hash($user->user_login . '|' . $expiration);
150@@ -524,7 +530,7 @@
151 
152        $cookie = $user->user_login . '|' . $expiration . '|' . $hash;
153 
154-       return apply_filters('auth_cookie', $cookie, $user_id, $expiration);
155+       return apply_filters('auth_cookie', $cookie, $user_id, $expiration, $secure);
156 }
157 endif;
158 
159@@ -550,13 +556,21 @@
160                $expire = 0;
161        }
162 
163-       $cookie = wp_generate_auth_cookie($user_id, $expiration);
164+       if ( is_ssl() ) {
165+               $secure = true;
166+               $cookie_name = SECURE_AUTH_COOKIE;
167+       } else {
168+               $secure = false;
169+               $cookie_name = AUTH_COOKIE;
170+       }
171 
172-       do_action('set_auth_cookie', $cookie, $expire);
173+       $cookie = wp_generate_auth_cookie($user_id, $expiration, $secure);
174 
175-       setcookie(AUTH_COOKIE, $cookie, $expire, COOKIEPATH, COOKIE_DOMAIN);
176+       do_action('set_auth_cookie', $cookie, $expire, $secure);
177+
178+       setcookie($cookie_name, $cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure);
179        if ( COOKIEPATH != SITECOOKIEPATH )
180-               setcookie(AUTH_COOKIE, $cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN);
181+               setcookie($cookie_name, $cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure);
182 }
183 endif;
184 
185@@ -569,6 +583,8 @@
186 function wp_clear_auth_cookie() {
187        setcookie(AUTH_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
188        setcookie(AUTH_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
189+       setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
190+       setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
191 
192        // Old cookies
193        setcookie(USER_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
194@@ -604,14 +620,36 @@
195  */
196 function auth_redirect() {
197        // Checks if a user is logged in, if not redirects them to the login page
198-       if ( (!empty($_COOKIE[AUTH_COOKIE]) &&
199-                               !wp_validate_auth_cookie($_COOKIE[AUTH_COOKIE])) ||
200-                       (empty($_COOKIE[AUTH_COOKIE])) ) {
201-               nocache_headers();
202 
203-               wp_redirect(get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
204-               exit();
205+       if ( is_ssl() || (defined('FORCE_SSL_LOGIN') && FORCE_SSL_LOGIN) )
206+               $secure = true;
207+       else
208+               $secure = false;
209+
210+       // If https is required and request is http, redirect
211+       if ( $secure && !is_ssl() ) {
212+               if ( false !== strpos($_SERVER['REQUEST_URI'], 'http') ) {
213+                       wp_redirect(str_replace('http://', 'https://', $_SERVER['REQUEST_URI']));
214+                       exit();
215+               } else {
216+                       wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
217+                       exit();                 
218+               }
219        }
220+
221+       if ( wp_validate_auth_cookie() )
222+               return;  // The cookie is good so we're done
223+
224+       // The cookie is no good so force login
225+       nocache_headers();
226+
227+       $login_url = get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']);
228+
229+       //  Redirect to https if connection is secure
230+       if ( $secure )
231+               $login_url = str_replace('http://', 'https://', $login_url);
232+       wp_redirect($login_url);
233+       exit();
234 }
235 endif;
236 
237Index: wp-includes/script-loader.php
238===================================================================
239--- wp-includes/script-loader.php       (revision 7994)
240+++ wp-includes/script-loader.php       (working copy)
241@@ -7,7 +7,7 @@
242 require( ABSPATH . WPINC . '/functions.wp-styles.php' );
243 
244 function wp_default_scripts( &$scripts ) {
245-       $scripts->base_url = get_option( 'siteurl' );
246+       $scripts->base_url = site_url();
247        $scripts->default_version = get_bloginfo( 'version' );
248 
249        $scripts->add( 'common', '/wp-admin/js/common.js', array('jquery'), '20080318' );
250@@ -50,7 +50,7 @@
251 
252        $scripts->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('wp-ajax-response'), '20080411' );
253        $scripts->localize( 'wp-lists', 'wpListL10n', array(
254-               'url' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php'
255+               'url' => admin_url('admin-ajax.php')
256        ) );
257 
258        $scripts->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/scriptaculous.js', array('prototype'), '1.8.0');
259@@ -129,11 +129,11 @@
260                $scripts->add( 'upload', '/wp-admin/js/upload.js', array('jquery'), '20070518' );
261                $scripts->add( 'postbox', '/wp-admin/js/postbox.js', array('jquery'), '20080128' );
262                $scripts->localize( 'postbox', 'postboxL10n', array(
263-                       'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',
264+                       'requestFile' => admin_url('admin-ajax.php'),
265                ) );
266                $scripts->add( 'slug', '/wp-admin/js/slug.js', array('jquery'), '20080208' );
267                $scripts->localize( 'slug', 'slugL10n', array(
268-                       'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',
269+                       'requestFile' => admin_url('admin-ajax.php'),
270                        'save' => __('Save'),
271                        'cancel' => __('Cancel'),
272                ) );
273@@ -204,7 +204,7 @@
274 }
275 
276 function wp_default_styles( &$styles ) {
277-       $styles->base_url = get_option( 'siteurl' );
278+       $styles->base_url = site_url();
279        $styles->default_version = get_bloginfo( 'version' );
280        $styles->text_direction = 'rtl' == get_bloginfo( 'text_direction' ) ? 'rtl' : 'ltr';
281 
282@@ -258,7 +258,7 @@
283                'autosaveInterval' => AUTOSAVE_INTERVAL,
284                'previewPageText' => __('Preview this Page'),
285                'previewPostText' => __('Preview this Post'),
286-               'requestFile' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php',
287+               'requestFile' => admin_url('admin-ajax.php'),
288                'savingText' => __('Saving Draft&#8230;')
289        ) );
290 }
291Index: wp-settings.php
292===================================================================
293--- wp-settings.php     (revision 7994)
294+++ wp-settings.php     (working copy)
295@@ -311,6 +311,13 @@
296 
297 /**
298  * It is possible to define this in wp-config.php
299+ * @since 2.6
300+ */
301+if ( !defined('SECURE_AUTH_COOKIE') )
302+       define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
303+
304+/**
305+ * It is possible to define this in wp-config.php
306  * @since 2.3.0
307  */
308 if ( !defined('TEST_COOKIE') )
309Index: wp-admin/users.php
310===================================================================
311--- wp-admin/users.php  (revision 7994)
312+++ wp-admin/users.php  (working copy)
313@@ -396,9 +396,9 @@
314 
315 <?php
316        if ( get_option('users_can_register') )
317-               echo '<p>' . sprintf(__('Users can <a href="%1$s">register themselves</a> or you can manually create users here.'), get_option('siteurl').'/wp-register.php') . '</p>';
318+               echo '<p>' . sprintf(__('Users can <a href="%1$s">register themselves</a> or you can manually create users here.'), site_url('wp-register.php')) . '</p>';
319        else
320-               echo '<p>' . sprintf(__('Users cannot currently <a href="%1$s">register themselves</a>, but you can manually create users here.'), get_option('siteurl').'/wp-admin/options-general.php#users_can_register') . '</p>';
321+               echo '<p>' . sprintf(__('Users cannot currently <a href="%1$s">register themselves</a>, but you can manually create users here.'), admin_url('options-general.php#users_can_register')) . '</p>';
322 ?>
323 <form action="#add-new-user" method="post" name="adduser" id="adduser" class="add:users: validate">
324 <?php wp_nonce_field('add-user') ?>
325Index: wp-admin/includes/dashboard.php
326===================================================================
327--- wp-admin/includes/dashboard.php     (revision 7994)
328+++ wp-admin/includes/dashboard.php     (working copy)
329@@ -225,7 +225,7 @@
330        }
331 
332        if ( $widget_feed_link )
333-               $links[] = '<img class="rss-icon" src="' . get_option( 'siteurl' ) . '/' . WPINC . '/images/rss.png" alt="' . __( 'rss icon' ) . '" /> <a href="' . clean_url( $widget_feed_link ) . '">' . __( 'RSS' ) . '</a>';
334+               $links[] = '<img class="rss-icon" src="' . includes_url('images/rss.png') . '" alt="' . __( 'rss icon' ) . '" /> <a href="' . clean_url( $widget_feed_link ) . '">' . __( 'RSS' ) . '</a>';
335 
336        $links = apply_filters( "wp_dashboard_widget_links_$widget_id", $links );
337 
338Index: wp-admin/post.php
339===================================================================
340--- wp-admin/post.php   (revision 7994)
341+++ wp-admin/post.php   (working copy)
342@@ -159,8 +159,8 @@
343        }
344 
345        $sendback = wp_get_referer();
346-       if (strpos($sendback, 'post.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/post-new.php';
347-       elseif (strpos($sendback, 'attachments.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/attachments.php';
348+       if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('post-new.php');
349+       elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
350        $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
351        wp_redirect($sendback);
352        exit();
353Index: wp-admin/admin.php
354===================================================================
355--- wp-admin/admin.php  (revision 7994)
356+++ wp-admin/admin.php  (working copy)
357@@ -26,8 +26,8 @@
358 
359 wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'popuptitle', 'popupurl', 'text', 'trackback', 'pingback'));
360 
361-wp_admin_css_color('classic', __('Classic'), get_option( 'siteurl' ) . "/wp-admin/css/colors-classic.css", array('#07273E', '#14568A', '#D54E21', '#2683AE'));
362-wp_admin_css_color('fresh', __('Fresh'), get_option( 'siteurl' ) . "/wp-admin/css/colors-fresh.css", array('#464646', '#CEE1EF', '#D54E21', '#2683AE'));
363+wp_admin_css_color('classic', __('Classic'), admin_url("css/colors-classic.css"), array('#07273E', '#14568A', '#D54E21', '#2683AE'));
364+wp_admin_css_color('fresh', __('Fresh'), admin_url("css/colors-fresh.css"), array('#464646', '#CEE1EF', '#D54E21', '#2683AE'));
365 
366 wp_enqueue_script( 'common' );
367 wp_enqueue_script( 'jquery-color' );
368Index: wp-admin/custom-header.php
369===================================================================
370--- wp-admin/custom-header.php  (revision 7994)
371+++ wp-admin/custom-header.php  (working copy)
372@@ -189,7 +189,7 @@
373 <div id="desc"><?php bloginfo('description');?></div>
374 </div>
375 <?php if ( !defined( 'NO_HEADER_TEXT' ) ) { ?>
376-<form method="post" action="<?php echo get_option('siteurl') ?>/wp-admin/themes.php?page=custom-header&amp;updated=true">
377+<form method="post" action="<?php echo admin_url('themes.php?page=custom-header&amp;updated=true') ?>">
378 <input type="button" value="<?php _e('Hide Text'); ?>" onclick="hide_text()" id="hidetext" />
379 <input type="button" value="<?php _e('Select a Text Color'); ?>" onclick="colorSelect($('textcolor'), 'pickcolor')" id="pickcolor" /><input type="button" value="<?php _e('Use Original Color'); ?>" onclick="colorDefault()" id="defaultcolor" />
380 <?php wp_nonce_field('custom-header') ?>
381Index: wp-admin/comment.php
382===================================================================
383--- wp-admin/comment.php        (revision 7994)
384+++ wp-admin/comment.php        (working copy)
385@@ -78,7 +78,7 @@
386 
387 <table width="100%">
388 <tr>
389-<td><input type='button' class="button" value='<?php _e('No'); ?>' onclick="self.location='<?php echo get_option('siteurl'); ?>/wp-admin/edit-comments.php';" /></td>
390+<td><input type='button' class="button" value='<?php _e('No'); ?>' onclick="self.location='<?php echo admin_url('edit-comments.php'); ?>" /></td>
391 <td class="textright"><input type='submit' class="button" value='<?php echo $button; ?>' /></td>
392 </tr>
393 </table>
394@@ -146,7 +146,7 @@
395        else if ( '' != wp_get_original_referer() && false == $noredir )
396                wp_redirect( wp_get_original_referer() );
397        else
398-               wp_redirect( get_option('siteurl') . '/wp-admin/edit-comments.php' );
399+               wp_redirect( admin_url('edit-comments.php') );
400 
401        die;
402        break;
403@@ -171,7 +171,7 @@
404        if ( '' != wp_get_referer() && false == $noredir )
405                wp_redirect( wp_get_referer() );
406        else
407-               wp_redirect( get_option('siteurl') . '/wp-admin/edit.php?p=' . absint( $comment->comment_post_ID ) . '#comments' );
408+               wp_redirect( admin_url('edit.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );
409 
410        exit();
411        break;
412@@ -200,7 +200,7 @@
413        if ( '' != wp_get_referer() && false == $noredir )
414                wp_redirect( wp_get_referer() );
415        else
416-               wp_redirect( get_option('siteurl') . '/wp-admin/edit.php?p=' . absint( $comment->comment_post_ID ) . '#comments' );
417+               wp_redirect( admin_url('edit.php?p=' . absint( $comment->comment_post_ID ) . '#comments') );
418 
419        exit();
420        break;
421Index: wp-admin/admin-header.php
422===================================================================
423--- wp-admin/admin-header.php   (revision 7994)
424+++ wp-admin/admin-header.php   (working copy)
425@@ -85,7 +85,7 @@
426        <a href="http://gears.google.com/" target="_blank" style="font-weight:normal;"><?php _e('More information...'); ?></a></p>
427        <p><?php _e('After installing and enabling it, most of the WordPress images, scripts and CSS files will be stored on this computer. This will speed up page loading.'); ?></p>
428        <p><strong><?php _e('Please make sure you are not using a public or shared computer.'); ?></strong></p>
429-       <div class="submit"><button onclick="window.location = 'http://gears.google.com/?action=install&return=<?php echo get_option('siteurl') . '/wp-admin/'; ?>';" class="button"><?php _e('Install Now'); ?></button>
430+       <div class="submit"><button onclick="window.location = 'http://gears.google.com/?action=install&return=<?php echo admin_url() ?>';" class="button"><?php _e('Install Now'); ?></button>
431        <button class="button" style="margin-left:10px;" onclick="document.getElementById('gears-info-box').style.display='none';">Cancel</button></div>
432        </div>
433 
434@@ -109,7 +109,7 @@
435 
436 <?php } ?>
437 
438-<div id="user_info"><p><?php printf(__('Howdy, <a href="%1$s">%2$s</a>!'), 'profile.php', $user_identity) ?> | <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log Out') ?>"><?php _e('Log Out'); ?></a> | <?php _e('<a href="http://codex.wordpress.org/">Help</a>') ?> | <?php _e('<a href="http://wordpress.org/support/">Forums</a>') ?> | <?php if ( $gears_compat ) { ?><span id="gears-menu"><a href="#" onclick="wpGears.message(1);return false;"><?php _e('Speed up!') ?></a></span><?php } ?></p></div>
439+<div id="user_info"><p><?php printf(__('Howdy, <a href="%1$s">%2$s</a>!'), 'profile.php', $user_identity) ?> | <a href="<?php echo site_url('wp-login.php?action=logout') ?>" title="<?php _e('Log Out') ?>"><?php _e('Log Out'); ?></a> | <?php _e('<a href="http://codex.wordpress.org/">Help</a>') ?> | <?php _e('<a href="http://wordpress.org/support/">Forums</a>') ?> | <?php if ( $gears_compat ) { ?><span id="gears-menu"><a href="#" onclick="wpGears.message(1);return false;"><?php _e('Speed up!') ?></a></span><?php } ?></p></div>
440 
441 <?php
442 require(ABSPATH . 'wp-admin/menu-header.php');
443Index: wp-admin/edit.php
444===================================================================
445--- wp-admin/edit.php   (revision 7994)
446+++ wp-admin/edit.php   (working copy)
447@@ -20,8 +20,8 @@
448        }
449 
450        $sendback = wp_get_referer();
451-       if (strpos($sendback, 'post.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/post-new.php';
452-       elseif (strpos($sendback, 'attachments.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/attachments.php';
453+       if (strpos($sendback, 'post.php') !== false) $sendback = admin_url('post-new.php');
454+       elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
455        $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
456 
457        wp_redirect($sendback);
458Index: wp-admin/page.php
459===================================================================
460--- wp-admin/page.php   (revision 7994)
461+++ wp-admin/page.php   (working copy)
462@@ -148,8 +148,8 @@
463        }
464 
465        $sendback = wp_get_referer();
466-       if (strpos($sendback, 'page.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/page.php';
467-       elseif (strpos($sendback, 'attachments.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/attachments.php';
468+       if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('page.php');
469+       elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
470        $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
471        wp_redirect($sendback);
472        exit();
473Index: wp-admin/edit-pages.php
474===================================================================
475--- wp-admin/edit-pages.php     (revision 7994)
476+++ wp-admin/edit-pages.php     (working copy)
477@@ -20,8 +20,8 @@
478        }
479 
480        $sendback = wp_get_referer();
481-       if (strpos($sendback, 'page.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/page-new.php';
482-       elseif (strpos($sendback, 'attachments.php') !== false) $sendback = get_option('siteurl') .'/wp-admin/attachments.php';
483+       if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('page-new.php');
484+       elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php');
485        $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
486 
487        wp_redirect($sendback);
488Index: wp-admin/themes.php
489===================================================================
490--- wp-admin/themes.php (revision 7994)
491+++ wp-admin/themes.php (working copy)
492@@ -57,7 +57,7 @@
493 <h2><?php _e('Current Theme'); ?></h2>
494 <div id="current-theme">
495 <?php if ( $ct->screenshot ) : ?>
496-<img src="<?php echo get_option('siteurl') . '/' . $ct->stylesheet_dir . '/' . $ct->screenshot; ?>" alt="<?php _e('Current theme preview'); ?>" />
497+<img src="<?php echo site_url($ct->stylesheet_dir . '/' . $ct->screenshot); ?>" alt="<?php _e('Current theme preview'); ?>" />
498 <?php endif; ?>
499 <h3><?php printf(_c('%1$s %2$s by %3$s|1: theme title, 2: theme version, 3: theme author'), $ct->title, $ct->version, $ct->author) ; ?></h3>
500 <p class="description"><?php echo $ct->description; ?></p>
501@@ -126,7 +126,7 @@
502 ?>
503                <a href="<?php echo $activate_link; ?>" class="<?php echo $thickbox_class; ?> screenshot">
504 <?php if ( $screenshot ) : ?>
505-                       <img src="<?php echo ( $tpage == 'stage' ) ? $screenshot : get_option('siteurl') . '/' . $stylesheet_dir . '/' . $screenshot; ?>" alt="" />
506+                       <img src="<?php echo ( $tpage == 'stage' ) ? $screenshot : site_url($stylesheet_dir . '/' . $screenshot); ?>" alt="" />
507 <?php endif; ?>
508                </a>
509                <h3><a class="<?php echo $thickbox_class; ?>" href="<?php echo $activate_link; ?>"><?php echo $title; ?></a></h3>