From eed1eedc5fcb225759f1b53f7f22d650ef950fe9 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 23 Mar 2007 17:45:40 +0000 Subject: [PATCH] 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 --- wp-admin/options-general.php | 4 ++-- wp-admin/upgrade-functions.php | 7 ++++++- wp-includes/default-filters.php | 4 +++- wp-includes/functions.php | 18 ++++++++++++++++-- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php index a4dab0306..9e3643196 100644 --- a/wp-admin/options-general.php +++ b/wp-admin/options-general.php @@ -25,11 +25,11 @@ include('./admin-header.php'); - +" /> -
to be different than the directory you installed WordPress in, enter that address here.'); ?> +" />
to be different than the directory you installed WordPress in, enter that address here.'); ?> diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php index 065b722c1..168a7c3c2 100644 --- a/wp-admin/upgrade-functions.php +++ b/wp-admin/upgrade-functions.php @@ -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. diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 31cac9cac..cda3cc96d 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -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); -?> \ No newline at end of file +?> diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 6917958ff..1b9ad20c2 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -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() { } } -?> \ No newline at end of file +?>