[wp-hackers] Streamlining Includes
Ryan Boren
ryan at boren.nu
Mon Mar 3 05:35:44 GMT 2008
On Sun, Mar 2, 2008 at 6:18 PM, Aaron Harun <admin at anthologyoi.com> wrote:
> The major problem I see is that for blogs with a lot of plugins,
> everything would be defined anyway because all activated plugins would
> still be loaded by default, so the only time this would have any real
> benefit is when just code that is rarely used by the core as well as
> plugins is removed.
Not everyone uses a bunch of plugins. I use only one.
> Even if each plugin only included what it needed, the entirety of the
> core would be included because on or another plugin would have needed
> it regardless of whether the plugin is actually useful. (For example,
> an Admin panel add-on is included no matter what page you are on.)
Plugins shouldn't load their admin code in a non-admin context.
> Part of optimizing the core may require that plugins "announce" what
> they do, so WordPress knows how to respond: when plugins are
> activated, they should define their functionality to WordPress. This
> could be as simple as adding a list of functionality in the header of
> each file that WordPress can store as part of the plugin data.
> That AJAX plugin might have "Functions: posts, comments" while the
> Simple Tags plugin might use "Functions: tagging, admin."
That's pretty much what I'm proposing. Define groups of
functionality, such as 'edit-posts', and the necessary files are
included. Plugins already have a way of knowing if they are in an
admin context. if (is_admin())
require_once('my-admin-functions.php'). Plugins should take care of
organizing their includes so that only the necessary stuff is loaded
for a given context.
More information about the wp-hackers
mailing list