Make WordPress Core

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's profile 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)

#1 @nacin
11 years ago

  • Component changed from General to Bootstrap/Load

#2 @jeremyfelt
11 years ago

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.

#3 @chriscct7
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to maybelater
  • Status changed from new to closed

Closing as maybelater. Complete lack of interest on the feature on the ticket over the last 2 years. Feel free to reopen when more interest re-emerges (particularly if there's a patch).

Note: See TracTickets for help on using tickets.