I am learning about OOP, and I think I am getting the hang of it. My question is why the author of a wordpress boilerplate plugin wrote the add action function like this
According to the codex I understand the
hook, the paramaters to be passed are
"The name of the action to which $function_to_add is hooked", and the function that you want hooked
.
Well I understand the functions in OOP are methods, and I can see why that may change the syntax, but that is just a vague representation, I want a clear answer why the author uses an array, then uses
. I understand why one would use
but not so sure about
.
Is it just how you refer to the method? If so I still dont understand the array, why wouldnt it look something like
.
By the way the structure looks kind of like this
Code:
add_action('admin_init', array(&$this, 'admin_init'));
According to the codex I understand the
Code:
add_action
Code:
$tag
Code:
$function_to_add
Well I understand the functions in OOP are methods, and I can see why that may change the syntax, but that is just a vague representation, I want a clear answer why the author uses an array, then uses
Code:
&$this
Code:
$this->property
Code:
&$this
Is it just how you refer to the method? If so I still dont understand the array, why wouldnt it look something like
Code:
$this->admin_init
By the way the structure looks kind of like this
Code:
class my_plugin_settings {
public function __construct() {
// register actions
add_action('admin_init', array(&$this, 'admin_init'));
}
public function admin_init() {
//Settings here
}
}