I’m just doing some wordpress development and wondered for a brand new install, which code within core is generating the first value that get’s filled into the home
option?
I’m looking for the code in core, e.g. the filename and the line where this happens.
Does someone remembers from mind?
When the installer runs it calls wp_install()
, that in turn calls populate_options()
defined in wp-admin/includes/schema.php
, which runs the following..
if ( !__get_option('home') ) update_option('home', $guessurl);
Prior to that $guessurl
is defined by..
$guessurl = wp_guess_url();
The guess URL function is defined in wp-includes/functions.php
and looks like this.
function wp_guess_url() {
if ( defined('WP_SITEURL') && '' != WP_SITEURL ) {
$url = WP_SITEURL;
} else {
$schema = is_ssl() ? 'https://' : 'http://';
$url = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
return rtrim($url, "https://wordpress.stackexchange.com/");
}
- wp_install()
http://core.trac.wordpress.org/browser/tags/3.1/wp-admin/includes/upgrade.php#L22
- populate_options()
http://core.trac.wordpress.org/browser/tags/3.1/wp-admin/includes/schema.php#L177
- guess_url()
http://core.trac.wordpress.org/browser/tags/3.1/wp-includes/functions.php#L3585
Hope that’s the info you’re looking for… 🙂