I want to save the time that the user activates a plugin. So I need to set the value within the function that the registration hook fires:
function ucme_reg_func () {
//------------other functions-------------
global $sega;
$sega = new setTime();
$sega->theTimeis = time();}
setTime is a simple class that should hold the timestamp:
class setTime{
public $theTimeis;
public function settingTime($theTimeis) {
$this->theTimeis = $theTimeis;
}
public function getTime() {
return $this->theTimeis;
}
}
I try to access the value $sega from a shortcode function:
function new_func() {
global $post;
global $sega;
$now = $sega->getTime();
//-------------------------
var_dump($now);
}
The error is : FATAL ERROR: CALL TO A MEMBER FUNCTION GETTIME() ON A NON-OBJECT IN ...
The same logic I applied in a pure php environment and it worked. I will welcome any help regarding how to set the timestamp right, as well as somebody to point me out what is my error in understanding the differences between Wordpress and PHP, which I suppose is the actual cause of this issue.