• I have a plugin which is class based,
    I have the __constructor call a few functions, one of the functions must make a database table when the plugin is activated, so I have a make_table() method for that, and of course when the plugin is deactivae I would like the tables to be dropped.
    Can someone please explain how to use

    register_activation_hook(
    __FILE__,
    ‘make_table’
    );

    inside the class.

    Obviously if the plugin were not a class I could just call

    register_activation_hook(
    __FILE__,
    ‘make_table’
    );

    but I cannot use
    register_activation_hook(
    __FILE__,
    $this->make_table()
    );
    register_deactivation_hook(
    __FILE__,
    $this->delete_table()
    );

    or both methods will be called.

    It must be something simple. I just cannot see it.
    thanks for any help

Viewing 1 replies (of 1 total)
  • Thread Starter shimmyshack

    (@shimmyshack)

    my bad – kinda – I used

    register_activation_hook(
    str_replace(‘\\’,’/’,__FILE__),
    array(&$this, ‘make_table’)
    );

    str_replace(‘\\’,’/’,
    was needed on my windows test box, and
    array(&$this,
    was needed to reference themethod that would be run.

    Ta.

Viewing 1 replies (of 1 total)
  • The topic ‘activation of a plugin class’ is closed to new replies.