[wp-hackers] [help] sink plugin hooks for $this

Niels Hackius niels.hackius at gmail.com
Fri Jan 13 23:38:12 GMT 2006


Owen Winkler wrote:
>Apparently, you're not supposed to use add_action() for that one at all:
>
>http://wphooks.flatearth.org/hooks/activate_plugin-filename/<http://wphooks.flatearth.org/hooks/activate_plugin-filename/>

Yes,thats correct. In fact me using the add_action is just a shortcut, since
register_activation_hook<http://codex.wordpress.org/Template_Tags/register_activation_hook>()
basically just strips the filename of the plugin. However the function
plugin_basename() that register_activation_hook() utilizes returns a wrong
slash on my system. (It actually returns "samba\loadbalancer.php" where it
should be "samba/loadbalancer.php" - but this might me okay, since it is a
testsystem on windows xp)

My problem isn't really that the hook doesn't work its more that I can't
pass a classvariable by reference

This way it works:
add_action('activate_samba/loadbalancer.php', array('loadbalancer',
'installer'));

this way however it doesn't:
$test = new loadbalancer();
add_action('activate_samba/loadbalancer.php', array(&$test, 'installer'));

it also doesn't work this way:
$test = new loadbalancer();
register_activation_hook(__FILE__, array(&$test, 'installer'));
...as the website you pointed to suggested.

So it appears that what I am trying to do is just not possible? I was just
wondering.

Thanks for all the help.


More information about the wp-hackers mailing list