WordPress.org

Make WordPress Core

Opened 9 months ago

Closed 3 months ago

#24740 closed enhancement (invalid)

get_option does not respect WP_HOME, WP_SITEURL

Reported by: daveagp Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5.2
Component: Options, Meta APIs Keywords: has-patch
Focuses: Cc:

Description

I believe that get_option( $option ) in option.php should use WP_HOME and WP_SITEURL when they are available. This would involve adding 4 lines,

   // about 10 lines into the function
        if ($option == 'home' && defined('WP_HOME'))
          return WP_HOME;
        if ($option == 'siteurl' && defined('WP_SITEURL'))
          return WP_SITEURL;

        if ( defined( 'WP_SETUP_CONFIG' ) ) // old code continues here

The reason this is really important is that there is no way to run a development site and a live site without doing hacks to core code or a pseudo-hacky drop-in replacement for db.php. See the discussion of line numbers in http://codex.wordpress.org/Running_a_Development_Copy_of_WordPress#Using_a_Drop-In for the details of why no non-hacky solution (such as filters) can work. But if we make this enhancement, then it is a simple matter of development sites defining these values within their wp-config.php which to me is the most satisfying and non-hacky approach.

Feedback is welcome on the exact best location within get_option to place this logic.

Change History (2)

comment:1 nacin3 months ago

  • Component changed from General to Options and Meta

comment:2 nacin3 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Hi daveagp, get_option() is filtered to use WP_HOME and WP_SITEURL when they are defined. See _config_wp_siteurl() and _config_wp_home().

Note: See TracTickets for help on using tickets.