Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Customer asks if a specific carousel plugin he uses can be widgetized. That means i should create a widget inside functions.php which calls the plugin's function. That means that the plugin's code has to be loaded first so taht the function be available to wordpress when the functions.php file is loaded, right? Would that work?

share|improve this question
add comment

2 Answers

up vote 51 down vote accepted

The plugins are loaded right before theme (yes, I've been looking for excuse to use this):

enter image description here

However it is wrong to think about either as point of code execution. For most cases everything should be hooked and executed no earlier than init hook. According to Codex widget registration with register_widget() should be hooked to widget_init.

Because of that order of load doesn't matter for this case, you will have everything loaded by the time widget needs it in any case.

share|improve this answer
    
Pretty image FTW! –  Chip Bennett Aug 23 '11 at 1:42
    
Incredible. Great work. –  Foxinni Aug 14 '12 at 11:43
add comment

You can have a widget inside the plugin's .php file (and have a shared global variable which they can both use), if that's what you're asking. Here's a tutorial with sample code I stumbled upon a while back.

Also, here's a list of actions run during a typical request, in order of execution. #2 and #10 suggest that plugins load first; not sure about functions.php.

share|improve this answer
1  
Correct, plugins are loaded before theme files. If the plugin includes code, but not the widget you want, it is possible to define the widget in your theme's functions.php. –  goldenapples Aug 22 '11 at 23:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.