Opened 19 years ago
Closed 18 years ago
#2525 closed defect (bug) (fixed)
Restructure wp-includes
Reported by: | ryan | Owned by: | ryan |
---|---|---|---|
Milestone: | 2.1 | Priority: | normal |
Severity: | normal | Version: | 2.0.1 |
Component: | Administration | Keywords: | includes |
Focuses: | Cc: |
Description
Our includes are rather chaotic. functions.php has turned into a dumping ground for everything. Let's impose some structure.
- Database Query - Move get, set, update, add, delete functions together into one db.php file or break them into category-db.php, option-db.php, post-db.php, bookmark-db.php, etc.
- WP Query - Move WP_Query class and all of the functions that wrap the wp_query object (is_*() and the loop functions) into query.php.
- Theme, Stylesheet, Template - Move all of the theming related functions to theme.php.
- Plugin - Move action and filter functions to plugin.php.
- Rewrite/Link - Move WP_Rewrite and supporting functions into rewrite.php.
- Misc - Leave what's left in functions.php.
I'd like to rename existing files while we're at it. The "-functions" suffix and "functions-" prefix aren't necessary. Let's try a three tier naming approach for the bookmark, category, option, post, page, and user functions.
- object-template.php - Template functions
- object-helper.php - Helper funcs for the template funcs
- object-db.php - DB functions that do the get and the set.
We'd have these for each of our objects (bookmarks, categories, ...). Helper functions would be the middle men between the template and db functions. We may not need separate files for helper funcs.
Attachments (3)
Change History (26)
#2
@
19 years ago
The problem is we don't know what any given plugin will require to do its thing. We pretty much have to load up everything just in case a plugin needs it.
#3
@
19 years ago
Masquerade and I developed a load-on-demand system that has been proven to work but we don't have benchmarks proving its value.
Regarding the rearranging of includes, I believe it should be done but with effort to keep the file count low. For example, bookmarks.php could be internally organized into DB, Helpers, Template Tags without splitting it into three files.
#4
@
19 years ago
Either way is fine by me, although I kinda like separating the template functions out from everything else so that theme authors can go looking through the template functions without having to wade through the other stuff.
#5
@
19 years ago
I'd say two-tier: DB and DB helper funcs (as the latter are likely to be DB-specific anyway) in object-db.php, then template and template helper in object-template.php. Also make everything in *-template.php pluggable.
#7
@
19 years ago
Recommend we hold off on this until after 2.0.2, as it make it hard to put changes into 2.0.2 and 2.1 simultaneously.
#10
@
19 years ago
[3639] moves WP_Query and its wrapper functions to query.php Now I can actually find them. :-)
#13
@
19 years ago
Path renames comment-functions.php to comment.php, moves template functions to comment-template.php, and moves comment functions in functions.php to comment.php.
+1
Should we not also look at when things are included to ensure we don't pull in a particular file until absolutely necessary to reduce the amount of code loaded.