对象方法回调

class MyClass {
    function my_init_method() {
        // do something here
    }
}

$obj = new MyClass();

add_action( 'init', array( $obj, 'my_init_method' ) );

使用对象的方法来挂钩一组指令。使用 init 钩子,在 wordpress 完成加载必要组件后立即执行指令集。