The problem is that you’re trying to callback the process_action_heb
method from $this
(aka class A) and it’s not a method of the A class – it’s a method of B.
I’d use dependency injection to solve this, though you could use a method like you’re using.
//* plugin.php
include_once PATH_TO . '/classA.php';
include_once PATH_TO . '/classB.php';
$classB = new classB();
$classA = new classA( $classB );
add_action( 'hookA', [ $classA, 'some_method' ], 20 );
//* class-a.php
class A {
protected $classB;
public function __construct( $classB ) {
$this->classB = $classB;
}
public function some_method() {
//* Do something
//* And add action to classB::some_method
add_action( 'hookB', [ $this->classB, 'some_method' ] );
}
}
//* class-b.php
class B {
public function some_method() {
//* This code will run on the hookB hook
}
}