How to remove a WordPress action which uses the current object - $this?

后端 未结 3 1412
面向向阳花
面向向阳花 2021-02-06 14:42

I\'m familiar with remove_action when removing an action in WordPress.

To create the action: add_action( \'action_hook\', \'function_name\', 10, 3 );<

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-06 14:47

    Inside class

    add_action( 'some_action_hook', array( $this, 'some_function' ) );
    

    Outside class,

    With use of global vairable:

    global $my_class;
    remove_action( 'some_action_hook', array( $my_class, 'some_function' ) );
    

    Using class name:

    remove_action( 'some_action_hook', array( 'MyClass', 'some_function' ) );
    

    Reference.

提交回复
热议问题