[wp-trac] [WordPress Trac] #21412: Hookable dropins
WordPress Trac
wp-trac at lists.automattic.com
Sun Jul 29 03:59:34 UTC 2012
#21412: Hookable dropins
--------------------------+------------------------------------
Reporter: mikeschinkel | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Cache | Version:
Severity: normal | Keywords: has-patch dev-feedback
--------------------------+------------------------------------
This ticket is the result of a discussion on the wp-hackers list where I
proposed the idea in [http://lists.automattic.com/pipermail/wp-
hackers/2012-July/043772.html this message].
Currently for dropins there can be only one[1] per install which means
that, especially for `advanced-cache.php` where multiple plugins cannot
easily:
- Cache different mime types with different plugins
- Provide basic functionality and leave the complexity to other plugins
because hooks are not available ''(this is likely needed for a good page
caching API to ever emerge from the work of plugins.)''
For caching this results in plugins like WP Super Cache and WP Total Cache
that significantly violate a sancrosact WordPress philosophy of
''"[http://wordpress.org/about/philosophy/#decisions Decisions, not
Options]''". To see what I mean, just visit the settings page for either
of these plugins. ''(Note: I'm not criticizing the plugins or their
developers, instead saying that WordPress doesn't give them much of a
choice.)''
It turns out however that fixing this is really lightweight and easy, at
least for `advanced-cache.php`. I will attach the following files but here
is the short list of changes to core required:
- Move the hooks-related function out of `/wp-includes/plugin.php` into
another file which I called `/wp-includes/hooks.php` and include `/wp-
includes/hooks.php` in `/wp-settings.php` close to the top after `/wp-
includes/versions.php` is included.
- Include another new file `/wp-includes/dropsin.php` in `/wp-
settings.php` after `/wp-includes/hooks.php` which contains a
`wp_load_dropins()` function that `include()`s all `.php` files found in
`/wp-includes/dropins/`.
- Lastly add the following two (2) lines before `advanced-cache.php` is
included:
{{{
// Load any potential dropins found /wp-content/dropins/
wp_load_dropins();
// Run the hook-based page cache.
do_action( 'page_cache' );
}}}
With this future caching plugins can implement the page_cache hook by
dropping a file into `/wp-content/cache/` instead of adding an `/wp-
content/advanced-cache.php`.
If this idea is blessed then we could add a deprecation notice for `/wp-
content/advanced-cache.php` and also potentially replace (some of) the
other dropins with `do_actions( "{$dropin_hook}" )`.
[1]
[http://www.urbandictionary.com/define.php?term=%22there%20can%20only%20be%20one%22%20
Gratuitous Highlander reference].
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21412>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list