Allow siteurl and home to be defined as constants in wp-config, bypassing the DB. Props filosofo and charleshooper. fixes #4003

git-svn-id: http://svn.automattic.com/wordpress/trunk@5093 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-03-23 17:45:40 +00:00
parent e9e3e0787d
commit eed1eedc5f
4 changed files with 27 additions and 6 deletions

View File

@ -25,11 +25,11 @@ include('./admin-header.php');
</tr>
<tr valign="top">
<th scope="row"><?php _e('WordPress address (URL):') ?></th>
<td><input name="siteurl" type="text" id="siteurl" value="<?php form_option('siteurl'); ?>" size="40" class="code" /></td>
<td><input name="siteurl" type="text" id="siteurl" value="<?php form_option('siteurl'); ?>" size="40" class="code<?php if ( defined( 'WP_SITEURL' ) ) : ?> disabled" disabled="disabled"<?php else: ?>"<?php endif; ?> /></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Blog address (URL):') ?></th>
<td><input name="home" type="text" id="home" value="<?php form_option('home'); ?>" size="40" class="code" /><br /><?php _e('If you want your blog homepage <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">to be different than the directory</a> you installed WordPress in, enter that address here.'); ?></td>
<td><input name="home" type="text" id="home" value="<?php form_option('home'); ?>" size="40" class="code<?php if ( defined( 'WP_HOME' ) ) : ?> disabled" disabled="disabled"<?php else: ?>"<?php endif; ?> /><br /><?php _e('If you want your blog homepage <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">to be different than the directory</a> you installed WordPress in, enter that address here.'); ?></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('E-mail address:') ?> </th>

View File

@ -21,7 +21,12 @@ function wp_install($blog_title, $user_name, $user_email, $public, $meta='') {
update_option('admin_email', $user_email);
update_option('blog_public', $public);
$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
$guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
if ( defined('WP_SITEURL') && '' != WP_SITEURL )
$guessurl = WP_SITEURL;
else
$guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
update_option('siteurl', $guessurl);
// If not a public blog, don't ping.

View File

@ -145,6 +145,8 @@ add_filter('the_author', 'ent2ncr', 8);
// Misc filters
add_filter('option_ping_sites', 'privacy_ping_filter');
add_filter('option_blog_charset', 'wp_specialchars');
add_filter('option_home', '_config_wp_home');
add_filter('option_siteurl', '_config_wp_siteurl');
add_filter('mce_plugins', '_mce_load_rtl_plugin');
add_filter('mce_buttons', '_mce_add_direction_buttons');
@ -171,4 +173,4 @@ add_action('sanitize_comment_cookies', 'sanitize_comment_cookies');
add_action('admin_print_scripts', 'wp_print_scripts', 20);
add_action('mce_options', '_mce_set_direction');
add_action('init', 'smilies_init', 5);
?>
?>

View File

@ -993,7 +993,9 @@ function is_blog_installed() {
$wpdb->hide_errors();
$installed = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'");
$wpdb->show_errors();
return $installed;
$install_status = !empty( $installed ) ? TRUE : FALSE;
return $install_status;
}
function wp_nonce_url($actionurl, $action = -1) {
@ -1351,6 +1353,18 @@ function wp_die( $message, $title = '' ) {
die();
}
function _config_wp_home($url = '') {
if ( defined( 'WP_HOME' ) )
return WP_HOME;
else return $url;
}
function _config_wp_siteurl($url = '') {
if ( defined( 'WP_SITEURL' ) )
return WP_SITEURL;
else return $url;
}
function _mce_set_direction() {
global $wp_locale;
@ -1443,4 +1457,4 @@ function smilies_init() {
}
}
?>
?>