WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#4003 closed enhancement (fixed)

Set 'home' and 'siteurl' options in wp-config.php

Reported by: filosofo Owned by: charleshooper
Milestone: 2.2 Priority: low
Severity: normal Version:
Component: Administration Keywords: home siteurl wp-config has-patch
Focuses: Cc:

Description

I can't tell you how often I end up editing the database just to change the 'siteurl' and 'home' options.

Recently on the hackers list Matt suggested that it might have been a good thing to have put the those options in wp-config.php, and I agree.

My patch allows you to set the constants "WP_HOME" and "WP_SITEURL" in wp-config.php, in which case they will override the db settings (and gray out those fields in the admin options page).

As far as I can tell, this is something that would have to be done with a core change like this, because plugins are read too late after 'home' and 'siteurl' have already been used in wp-settings.php.

Attachments (2)

patch.diff (2.6 KB) - added by filosofo 8 years ago.
trunk-4003.diff (4.0 KB) - added by charleshooper 8 years ago.
Updated version of patch.diff to check WP_SITEURL value during install and also change is_blog_installed to return boolean value

Download all attachments as: .zip

Change History (14)

@filosofo8 years ago

comment:2 @westi8 years ago

+100

This is the most requested feature I have seen when considering using WordPress in a staged environment.

Now we just need the facility (plugin) to fix all the absolute urls in page content that are broken when this is changed ;-)

comment:3 @Dickie8 years ago

Agreed, this would be MORE than useful, and is also the subject of at least 2 ideas in the ideas section.

http://wordpress.org/extend/ideas/topic.php?id=70&page&replies=9
http://wordpress.org/extend/ideas/topic.php?id=142&page&replies=4

comment:5 @Sewar8 years ago

+1 googol

This will help fixing a lot of bugs.

comment:6 @charleshooper8 years ago

+1, should we also update is_blog_installed() to use this new constant?

comment:7 @ryan8 years ago

is_blog_installed is more of a DB check. Since we always create a siteurl option during install, I think we can leave it as is. We might want to change it to return true/false so that no one is tempted to use the return value as anything other than a bool.

comment:8 @charleshooper8 years ago

+1 for the boolean return, I'll submit the patch here in a few. I did notice that in wp_install() we do a update_option('siteurl', $guessurl), I think it's a good idea to override $guessurl if WP_SITEURL is already definied

comment:9 @ryan8 years ago

Checking WP_SITEURL during install sounds good.

@charleshooper8 years ago

Updated version of patch.diff to check WP_SITEURL value during install and also change is_blog_installed to return boolean value

comment:10 @charleshooper8 years ago

  • Owner changed from anonymous to charleshooper
  • Status changed from new to assigned

I've added a new patch, although I'm not sure why I can't preview it :-/

comment:11 @ryan8 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

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

comment:12 @Nazgul8 years ago

  • Milestone changed from 2.3 to 2.2
Note: See TracTickets for help on using tickets.