Hi,
I've set my plugin up to operate with Objects / Classes.
It works fine until I try to add the register_activation_hook() function. When I do this, it is causing my initial class to be redefined and I get an error on activation:
Plugin could not be activated because it triggered a fatal error. Fatal error: Cannot redeclare class
My digging around has led me to believe that the above function must reload my file somehow... i'm not sure.
How do I use this properly if I've already defined my class. I've tried placing the function inside the class, outside the class, inside/outside isset() functions... Could someone point me in the correct direction? The code for my file is below. Again, if I were to comment out the register_activation_hook, it works correctly
Class ClassName {
//this method sets the plugin up upon activation
function wpClassSetup(){
update_option('test','test');
}
}
if( class_exists('ClassName') ){
if( !isset($wpClassName) ) {
$wpClassName = new ClassName;
}
}
if( isset($wpClassName) ){
//Register plugin
register_activation_hook(__FILE__, array(&$wpClassName,'wpClassSetup') );