Ticket #2525 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Restructure wp-includes

Reported by: ryan Assigned to: ryan
Priority: normal Milestone: 2.1
Component: Administration Version: 2.0.1
Severity: normal Keywords: includes
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

theme-funcs.diff (24.1 kB) - added by ryan on 04/18/06 00:40:14.
Moves template, stylesheet, theme fxns to theme.php
comment-funcs.diff (76.8 kB) - added by ryan on 04/18/06 06:02:55.
Move comment functions into comment.php and comment-template.php
wp-settings.php.diff (0.7 kB) - added by filosofo on 06/04/06 22:36:39.

Change History

03/02/06 12:33:38 changed by westi

+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.

03/02/06 22:21:22 changed by ryan

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.

03/03/06 01:38:26 changed by skeltoac

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.

03/03/06 04:02:07 changed by ryan

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.

03/03/06 11:24:56 changed by davidhouse

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.

03/03/06 17:42:58 changed by ryan

Sounds good. A simple split between domain and presentation is sufficient.

03/05/06 04:36:07 changed by markjaquith

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.

03/05/06 21:13:19 changed by ryan

Agreed.

03/13/06 01:40:13 changed by ryan

[3638] moves WP_Rewrite and its wrapper functions to rewrite.php. See #2433.

03/13/06 01:45:41 changed by ryan

[3639] moves WP_Query and its wrapper functions to query.php Now I can actually find them. :-)

04/18/06 00:40:14 changed by ryan

  • attachment theme-funcs.diff added.

Moves template, stylesheet, theme fxns to theme.php

04/18/06 00:41:50 changed by ryan

Attached diff moves all of the theme related functions to theme.php.

04/18/06 04:44:55 changed by ryan

[3711] moves theme functions to theme.php.

04/18/06 06:02:55 changed by ryan

  • attachment comment-funcs.diff added.

Move comment functions into comment.php and comment-template.php

04/18/06 06:04:10 changed by ryan

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.

04/19/06 02:32:41 changed by ryan

[3714] reorgs comment functions.

06/04/06 21:37:16 changed by ryan

[3843] reorgs category functions.

06/04/06 22:07:06 changed by filosofo

You deleted template-functions-category.php but wp-settings.php still includes it.

06/04/06 22:36:39 changed by filosofo

  • attachment wp-settings.php.diff added.

06/04/06 22:41:31 changed by ryan

Oops. I checked in from wp-includes instead of trunk. Fixed.

06/05/06 02:13:25 changed by ryan

[3845] reorgs bookmark functions.

06/07/06 23:18:35 changed by ryan

[3851] reorgs post/page/attachment functions.

06/08/06 02:23:01 changed by ryan

[3854] moves user functions to user.php.

06/11/06 06:44:30 changed by ryan

[3862] finishes up the file renaming.

06/20/06 02:03:49 changed by ryan

[3893] moves plugin API to plugin.php.

11/14/06 04:13:24 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.