Opened 13 years ago
Closed 12 years ago
#21412 closed enhancement (maybelater)
Hookable dropins
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Cache API | Keywords: | has-patch dev-feedback |
| Focuses: | Cc: |
Description
This ticket is the result of a discussion on the wp-hackers list where I proposed the idea in 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 "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.phpinto another file which I called/wp-includes/hooks.phpand include/wp-includes/hooks.phpin/wp-settings.phpclose to the top after/wp-includes/versions.phpis included. - Include another new file
/wp-includes/dropsin.phpin/wp-settings.phpafter/wp-includes/hooks.phpwhich contains awp_load_dropins()function thatinclude()s all.phpfiles found in/wp-includes/dropins/. - Lastly add the following two (2) lines before
advanced-cache.phpis 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}" ).
Attachments (3)
Change History (12)
#4
follow-up:
↓ 7
@
13 years ago
Move the hooks-related function out of /wp-includes/plugin.php into another file which I called /wp-includes/hooks.php
If you do that, the plugin.php file is left with just a handful of functions (198 lines, mostly docs).
#7
in reply to:
↑ 4
@
13 years ago
Replying to scribu:
If you do that, the plugin.php file is left with just a handful of functions (198 lines, mostly docs).
So what's your suggestion, just move where plugin.php is included?
#9
@
12 years ago
- Milestone Awaiting Review deleted
- Resolution set to maybelater
- Status changed from new to closed
19 months of silence. Most people just alter advanced-cache.php to suit their needs. Most widely-used dropins change infrequently and are flexible enough to allow changes without causing painful merges when a new version is released.
hookable-dropins.diff