am puzzling why can't i access the global variable $menu
inside a php class function
class adminMenus {
public function getWPdefaultmenus(){
global $menu;
return $menu;
}
}
using this code in a plugin file and this function still return NULL
.
Edited what i am doing after @Will the Web Mechanic's answer
class adminMenus {
private $getWPdefaultmenus;
public function __construct(){
add_action( 'admin_menu', array( $this, 'getWPdefaultmenus' ) );
}
public function getWPdefaultmenus(){
global $menu;
$this->getWPdefaultmenus = $menu;
}
}
but this returns error:Fatal error: Cannot access empty property