[wp-hackers] [help] sink plugin hooks for $this
Mark Jaquith
mark.wordpress at txfx.net
Sat Jan 14 11:53:25 GMT 2006
On Jan 14, 2006, at 5:34 AM, Jamie Talbot wrote:
> If you're still having problems you could try adding the action
> using just a call to
> LoadBalancerClass::installer like this:
>
> add_action('activate_samba/loadbalancer.php', array
> ('LoadBalancerClass', 'installer'));
>
> installer() {
> global $test;
> // Install Here
> }
>
> It's a hack, not particularly pretty and of course you have to
> declare $test global because you can't use $this
> inside the 'installer' function, but it might work for you.
If you use add_action() from within the class, $this is perfectly fine:
<?php
class myTestClass() {
function myTestClass() { // constructor
add_action('activate_samba/loadbalancer.php', array(&$this,
'install');
}
function install() {
// do install stuff here
}
}
$singleton = new myTestClass;
?>
--
Mark Jaquith
http://txfx.net/
More information about the wp-hackers
mailing list