PDA

View Full Version : Multiple Plugins with Hook bbcode_fetch_tags


noox
05-08-2009, 11:57 PM
I wrote a plugin which changes some URLs. URLs are handeled in the callback function handle_bbcode_url(). With the hook "bbcode_fetch_tags" this function can be replaced by another one:

// [URL]
$tag_list['no_option']['url']['callback'] = 'handle_external';
$tag_list['no_option']['url']['external_callback'] = 'MyBbCodeFetchTags';
// [URL=XXX]
$tag_list['option']['url']['callback'] = 'handle_external';
$tag_list['option']['url']['external_callback'] = 'MyBbCodeFetchTags';

In MyBbCodeFetchTags I can call bbcode_fetch_tags and work with the result. I saw this strategy also in another addon I just downloaded.

The problem is now that I want to create another plugin which also modifies the links. So I would need some sort of chaining. Of course not all plugins would work together when they all modify the links. But some would if the chaining can be done.

I have not tried it yet, but I assume I could check if an external callback is already set. If it's already set I save this function and call it in my hook instead of bbcode_fetch_tags.

Is there some sort of best practice? Because I think most of the plugins which changes the callback functions should do something like this that they could work together.

Dismounted
05-10-2009, 07:21 AM
There is no "chaining" feature. Modifications that modify the same BB code definition will not be compatible.