This is a simple example that what I’m trying to do:
class PageMake extends Controller {
static $foo;
public function generate(){
Make::setFoo('test');
}
static function setFoo($value){
self::$foo = $value;
}
static function create(){
var_dump(self::$foo);
}
}
I need to use the updated value if $foo inside create() method. I run an error_log() inside setFoo() and confirm that $foo was changed. But when I call it inside create() method, it return nothing.
I forgot to mention, create() is being used in filter.php:
add_action( 'wp_ajax_sendEmail', 'App\PageMake::create' );
add_action( 'wp_ajax_nopriv_sendEmail', 'App\PageMake::create' );
So maybe a was making a mistake. Because new $foo is not avaliable after page load, right?