I have added some custom tables to a wordpress and trying to add wp-admin section to manage them. By using following code I have successfully added a menu item in wp-admin but I'm unable to call the php page that resides into my theme folder
add_menu_page('Private Messages', 'Private Messages', 'manage_options',
'message_admin', 'message-admin.php',
get_bloginfo('stylesheet_directory').'/style/images/message.png');
in error_log it gives me this error
PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'message-admin.php' not found or invalid function name in /var/www/idon.dev/wp-includes/plugin.php on line 470, referer: http://idon.dev/wp-admin/admin.php?page=message_admin
Update:
The wordpress says
$function
(string) (optional) The function that displays the page content for the menu page. Default: None. Technically, the function parameter is optional, but if it is not supplied, then WordPress will assume that including the PHP file will generate the administration screen, without calling a function. Most plugin authors choose to put the page-generating code in a function within their main plugin file. In the event that the function parameter is specified, it is possible to use any string for the file parameter. This allows usage of pages such as ?page=my_super_plugin_page instead of ?page=my-super-plugin/admin-options.php.
I know what does it mean
PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, function
but what I'm trying to achieve is to call a page rather of function. what is according to wordpress is possible, or guide me if I'm wrong.
Please note that I don't want to include page in functions, I will rather be happy to add my code into function.
'message-admin.php'
to the full pathmessage-admin.php
argument should be a callback function, not a file. Seeadd_menu_page
on the codex