Missing hooks in the "Developer's Plugin Hook List"
4 posts by 3 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: August 9, 2011 (RSS)
By ITI - August 7, 2011 - edited: August 7, 2011
The "Developer's Plugin Hook List" only lists actions and filters that have been enclosed in "single quotes".
eg. The following will appear in the list
addAction('admin_postlogin','_admin_postlogin');
where as this will not appear in the list:
addAction("admin_postlogin","_admin_postlogin");
The reason is that your array of hookTypes is only looking for single quotes.
// top of lib/menus/admin/pluginHooks.php
$hookTypes = array(
'filter' => array( 'callerRegex' => "|applyFilters\(\s*'(.*?)'|",
'pluginRegex' => "|addAction\('(.*?)'|" ), << in wrong array
'action' => array( 'callerRegex' => "|doAction\(\s*'(.*?)'|",
'pluginRegex' => "|addFilter\('(.*?)'|" ), << in wrong array
);
The following modification will find either single or double quotes and add the correct "type" to custom hooks:
$hookTypes = array(
'filter' => array( 'callerRegex' => "|applyFilters\(\s*['\"](.*?)['\"]|",
'pluginRegex' => "|addFilter\(['\"](.*?)['\"]|" ),
'action' => array( 'callerRegex' => "|doAction\(\s*['\"](.*?)['\"]|",
'pluginRegex' => "|addAction\(['\"](.*?)['\"]|" ),
);
This feature is very useful and I can't imagine having to edit all existing plugins just to have them appear in the list.
Item 2.
While your at it, could you add the counter value to the beginning of the line since the $counter variable is set anyway.
//Line 126 in cmsb ver 2.11:
<?php echo htmlspecialchars($hookName); ?>
// changed to this;
<?php echo htmlspecialchars("[".$counter."] ".$hookName); ?>
And would appear as:
Hook Name .....
[1] admin_footer
[2] admin_head
[3] admin_postlogin
... etc
It would make references to hooks a little easier since the list can be quite lengthy.
http://www.CanadianDomainRegistry.ca
ITI Internetworking Technologies Inc.
Re: [ITI] Missing hooks in the "Developer's Plugin Hook List"
By Jason - August 8, 2011
Thank you for posting. We'll look into this and see about getting it fixed for a future release.
Thanks
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Missing hooks in the "Developer's Plugin Hook List"
By Chris - August 8, 2011
Good catches, and thanks for the feedback!
I've made both fixes from your first item to our development branch and they'll show up in the next release of CMSB.
I've also added line numbers, as requested, but experimentally: I'm not sure what value they add; I'm worried that people may think that the numbers will stay the same when new hooks are added, while the list is actually alphabetized. Can you explain why they might make references to hooks any easier?
Thanks!
Chris
Re: [Chris] Missing hooks in the "Developer's Plugin Hook List"
By ITI - August 9, 2011 - edited: August 9, 2011
There are at least two reason why I like the numbers.
The main one is as an additional reference when collaborating with colleagues.
The other, a side from knowing how many there are it gives you a sense of where you are in the list.
I realize that they will change with every new CMS update and with changes to or additions of plugins. But here again it gives you an idea what the net affect the update, change or addition has made.
http://www.CanadianDomainRegistry.ca
ITI Internetworking Technologies Inc.