[wp-hackers] PHP Lazy Loading in WordPress 3.2

Jonathon Byrd jon at 5twentystudios.com
Tue Apr 26 05:56:51 UTC 2011


I did a lot of work with this last year. To answer your question, YES, if
Wordpress, or any other plugin, is using the __autoload function then errors
will fly.

function __autoload($class_name) {
    include $class_name . '.php';
}

$obj  = new MyClass1();

There can obviously only be one of these classes declared in the rendered
structure. But there is a way around this that will still allow you to
autoload. It's called special autoload or spl_autoload_register. But be
careful, because the special autoloader will override the __autoload class.
So you'd have to write some conditional code like this:

function b ($c) {
  require_once "path-to-your-class-dir/$c.php";
}
spl_autoload_register('b');
if (function_exists('__autoload'))
{
  spl_autoload_register('__autoload');
}

Hopefully that helps.

Sincerely,

Jonathon Byrd | Partner | Senior Software Engineer
5 Twenty Studios, LLC

C: (360) 747-7401 | O: (503) 268-1177 | F: (954) 867-1177
jon at 5twentystudios.com | www.5TwentyStudios.com<http://www.5twentystudios.com/>



On Mon, Apr 25, 2011 at 9:12 PM, Philip Walton <philip at philipwalton.com>wrote:

> I've heard rumors <
> http://wpdevel.wordpress.com/2011/03/18/wordpress-3-2-the-plan-faster-lighter/>
> that WordPress 3.2 will implement lazy loading of PHP classes. Is any of
> this currently incorporated into the latest development version?
>
> I'm writing an MVC plugin framework for my own development projects and I
> wanted to implement lazy loading for my framework, but now I'm worried that
> I might do something that the release of 3.2 will break.
>
> Can anyone shed any light on where this is at or point me in the direction
> of some code in progress so I can see how it's being implemented? I've
> looked around on Trac but haven't seen much. Should I wait for 3.2 to
> incorporate lazy loading or is it still far away?
>
> Philip
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list