Opened 11 years ago
Closed 9 years ago
#26818 closed enhancement (maybelater)
When plugins are loaded check for a class of the same name and autoload if exists
Reported by: | dwread | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Bootstrap/Load | Keywords: | |
Focuses: | Cc: |
Description
Had a good search but couldn't find any similar tickets, so sorry if I missed it.
When WordPress loads & includes plugins I think it would make sense / be a handy feature if once the plugin file was included it then tried to load a class of the same name. This would be a great step towards autoloading, help push towards more OOP plugins in the future and pave the way towards namespacing then we hit PHP 5.3.
Obviously it shouldn't be hard to do, a simple if( class_exists() ) etc. Happy to work up a patch if people agree.
Change History (3)
Note: See
TracTickets for help on using
tickets.
Hey @dwread, thanks for the suggestion!
I'm not sure I can see this working in the near term. There are likely several different design patterns at work in the WordPress plugin development community and auto-loading classes could cause unintentional effects. It could be interesting to see what some kind of opt-in system would look like.
It would probably be worth chiming in on #22316, which covers the idea of plugin dependencies in general. I think there would be more traction around an effort like that before core starts autoloading.