Hello,
I have a few questions about an object.
So i have a checkbox which is supposed to turn on an object if checked.
I have something like this:
class my_object {
public__construct {
add_action ('init' , 'my_action_function' ); // wordpress hook
add_filter('filter_name' , 'my_filter_function') ; // wordpress hook
}
function my_action_function() {
// function stuff
}
function my_filter_function() {
// function stuff
}
functions...
}
// check if checkbox is checked
if ($checkbox == 'checked') {
$object_a_test = new my_object;
} else {
return;
}
so my question is, says it's checked..the object gets instantiated, right? Then say the user decides to uncheck and turn it off...are the action which are used in the construct automatically removed/destroyed? It seems to be working like I expect but i just want to make sure these functions/hooks aren't there in the background.
I was thinking i should maybe handle this in the destructor - which is only called when the object is destroyed right? Or make sure this are explicitly removed another way? Or is this done automatically just by unchecking the checkbox (b/c it fails the if statement above) ?
also, this object (when turned on) is essentially persisting until the user turns it off (through the checkbox), right?
hope this make sense...
thanks