[wp-trac] [WordPress Trac] #20731: Split wp-settings.php in two

WordPress Trac wp-trac at lists.automattic.com
Tue May 22 19:12:48 UTC 2012


#20731: Split wp-settings.php in two
-------------------------+-----------------------------
 Reporter:  scribu       |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:
 Severity:  normal       |   Keywords:  dev-feedback
-------------------------+-----------------------------
 In wp-settings.php, we have these lines:

 {{{
 // Stop most of WordPress from being loaded if we just want the basics.
 if ( SHORTINIT )
         return false;
 }}}

 What I'm suggesting is that we move everything that follows into a
 separate file.

 Use-case: setting up a unit-testing environment without changing the
 database:

 https://github.com/nb/wordpress-tests/pull/19

 Here's the gist of how it's currently done:

 {{{
 // Define the options to be short-circuited
 $GLOBALS['wp_tests_options'] = array(
   'active_plugins' => array( 'akismet.php' ),
   'template' => 'twentyeleven'
 );

 // Load the essential parts of WordPress.
 define('SHORTINIT', true);
 require_once ABSPATH . '/wp-settings.php';

 // Short-circuit the options
 function wp_tests_options( $value ) {
         $key = substr( current_filter(), strlen( 'pre_option_' ) );
         return $GLOBALS['wp_tests_options'][$key];
 }

 foreach ( array_keys( $GLOBALS['wp_tests_options'] ) as $key ) {
         add_filter( 'pre_option_'.$key, 'wp_tests_options' );
 }

 // Load the rest of wp-settings.php (start from where we left off)
 $wp_settings_content = file_get_contents(ABSPATH.'/wp-settings.php');
 $offset = strpos($wp_settings_content, '// Load the l18n library.');
 eval(substr($wp_settings_content, $offset));
 unset($wp_settings_content, $offset);
 }}}

 As you can see, that last part is really ugly and fragile. It would be
 awesome if we could just do:

 {{{
 require(ABSPATH.'/wp-settings-2.php');
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20731>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list