class MyClass {
function my_init_method() {
// do something here
}
}
$obj = new MyClass();
add_action( 'init', array( $obj, 'my_init_method' ) );
Using a method of an object to hook a set of instructions. With the init
hook, the set of instructions will be executed right after wordpress has finished loading the necessary components.