[wp-hackers] Dynamic Includes
Andy Skelton
skeltoac at gmail.com
Fri Oct 7 00:10:14 GMT 2005
This may or may not be a bright idea, which is why I'm sending it
'round. WP might be sped up by reducing the number of includes and/or
leaving big functions out of the core. Here's a possibililty:
--- begin wp-functions.php
<?php
// Functions and the files that declare them, next on Jerry
$wp_functions = array(
'_wp_simple_function' => '/functions-meta.php',
'_wp_passref_function' => '/comment-functions.php',
'_wp_returnref_function' => '/comment-functions.php',
...
);
// Function includer for... including functions.
function wp_include_function($func) {
if ( ! function_exists($func) )
require_once(ABSPATH . WPINC . $wp_functions["$func"]);
}
// function wrapper for no-reference function (args are copies)
function wp_simple_function() {
wp_include_function('_wp_simple_function');
$args = func_get_args();
return call_user_func_array('_wp_simple_function', $args);
}
// Function wrapper for pass-by-reference function (args are references)
function wp_passref_function(&$arg1, &$arg2) {
wp_include_function('_wp_passref_function');
return _wp_passref_function($arg1, $arg2);
}
// Function wrapper for return-reference function (returns a reference)
function &wp_returnref_function() {
wp_include_function('_wp_returnref_function');
$args = func_get_args();
return call_user_func_array('_wp_returnref_function', $args);
}
--- end wp-functions.php
The files in wp-includes would then declare the functions with an
underscore prepended to the name. This might be worthwhile for some of
the less-used core includes, but certainly not the entire set. It
would be a heluvan overhaul, so methinks 1.6 would be out of the
question. Let fly the opinions.
Andy Skelton
More information about the wp-hackers
mailing list