2

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?

1 Answer 1

6

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, '/');
}

Hope that's the info you're looking for... :)

4
  • Related ticket is #16884.
    – hakre
    Mar 18, 2011 at 20:38
  • @t3los -- There's not much room for improvement on your answer. Would you care to share any of the tools you used to look up this information? Maybe you did it manually, but I'm wondering if you have any tricks up your sleeve... Maybe it's worth it to figure out how to use phpdoc? Thanks in advance!
    – joelhaus
    Mar 19, 2011 at 8:43
  • 1
    Just did it by hand, me, notepad++ and 5 minutes of spare time. Notepad++ can scan through all the WordPress PHP files for a string of text within a minute(it's usually faster/easier to do that than it is to search the web/codex/other-sources). Sorry if you were expecting something more elaborate ... :)
    – t31os
    Mar 19, 2011 at 9:10
  • No need for an apology, it's a testament to your helpfulness. Unfortunately, my hardware seems to dislike Notepad++. Editing three characters in a MySQL dump of a single (but large -- 60MB) WordPress table, took about an hour while my (fairly well equiped) PC struggled to open and save the bytes.
    – joelhaus
    Mar 21, 2011 at 23:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.