[wp-trac] [WordPress Trac] #36335: Next generation: core autoloader proposal
WordPress Trac
noreply at wordpress.org
Mon Sep 5 01:55:04 UTC 2016
#36335: Next generation: core autoloader proposal
-----------------------------+------------------
Reporter: dnaber-de | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: 4.7
Component: General | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
-----------------------------+------------------
Comment (by MikeSchinkel):
I've attached a strawman classmap generator and example output showing how
classmaps can easily be generated without the need for Composer.
The next step would be to implement a simple classmap autoloader to be
required at the beginning of `wp-settings`.
I would propose as another strawman that we create `wp-includes/classes`
and `wp-admin/classes` directories and slowly start moving classes that we
want to autoload into those two directories, renaming their files to match
their classname.
So for example:
{{{
/wp-includes/class-wp-editor.php
}}}
Would be moved to:
{{{
/wp-includes/classes/_WP_Editors.php
}}}
Once all classes were moved into those directories then classmap
generation could be handled automatically ''(if desired)'' in a
`'shutdown'` hook when a constant was set to true, e.g.
`WP_GENERATE_CLASSMAP`
In addition I would envision adding a `register_autoload_dir()` that would
allow plugins and themes to register their own autoload directories and
this would allow WordPress to auto-generate their classmaps as well.
I intend to work on this after I finish some other time-critical projects.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36335#comment:177>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list