call function from external class in add_menu_page
-
Hello everyone!! I need a little explanation if possible… let’s see this example:
file one.php <?php require_once( PLUGIN_DIR . 'two.php' ); require_once( PLUGIN_DIR . 'three.php' ); ?> file two.php <?php class static one { public static $three; public static function init() { $three = new init_three(); add_menu_page('...', '...', 'manage_options', 'two-plugin', array(&$three, 'init_three')); } } ?> file three.php <?php public static function init_three() { echo "<h1>Just a new dashboard!</h1>"; } ?>
why using array(&$three, ‘init_three’) returns to me this error :
Warning: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object
indeed if I call directly ‘three::init_three’ it works?… I am asking because also on Stackoverflow I saw samples using array(<class variable>, ‘<class function’s>’)…..
Thanks a lot in advance!
Cheers
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘call function from external class in add_menu_page’ is closed to new replies.