Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Load a library plugin function first
I have the same function in two places, surrounded by a !function_exists()
to avoid clashes; one nestling at the bottom of a plugin and one in a library (type=2).
I’m in the process of migrating said function out of the plugin, updating it and moving it into the library, but cannot guarantee that people will upgrade all my plugins at once. What is the best mechanism for me to force a plugin to use the library function over any other one already defined? (aside from renaming the function!)
I’ve tried the load order of both the plugin and library but it doesn’t make a difference because libraries are only loaded on-demand, hence by the time the tag is called, the function has already been defined by one or more of my other plugins and thus the library version is ignored.
The only way I can see out of this is to move the require_plugin()
call outside of the plugin function that uses it, so it is seen as ‘required’ at load time and gets swept in with all the others. As long as the load order is a higher priority (or the plugin name is alphabetically higher — luckily it is in this case) I should be ok and it’ll see the lib first.
Is that a valid thing to do, or is that going to cause problems? Is there a better way to approach this? I guess what I’m asking is: should libraries be loaded only when a tag is called, or can they be loaded ahead of time from publish.php’s load_plugins()
? Does it matter? And if it matters, does it matter that it matters? ;-)
Thanks for any pointers.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#2 2008-12-02 16:18:58
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Load a library plugin function first
Is it OK if I move this here?
Offline
Re: Load a library plugin function first
Els wrote:
Is it OK if I move this here?
Sure, I couldn’t decide the best place for it.
Last edited by Bloke (2008-12-02 16:25:01)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline