Reputation: 306
I am adding a new page to wordpress-menu.But it is giving me the error:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'myplguin_admin_page' not found or invalid function name.
What is that I am missing?
plugin.php
add_action( 'admin_menu', 'my_admin_menu' );
function my_admin_menu() {
add_menu_page( 'My Top Level Menu Example', 'VENDOR RATE UPDATE LOG', 'administrator', 'tested.php', 'myplguin_admin_page', 'dashicons-tickets', 6 );
}
tested.php
function myplguin_admin_page(){
?>
<div class="wrap">
<h2>Welcome To My Plugin</h2>
</div>
<?php
}
Upvotes: 1
Views: 2882
Reputation: 987
I don't know if this answer will help you, but I'm putting it here for the community.
I had the same problem, and I fixed it by changing the name of the function with this code:
array(__CLASS__,'myplguin_admin_page')
So the line will be finally:
add_menu_page( 'My Top Level Menu Example', 'VENDOR RATE UPDATE LOG', 'administrator', 'tested.php', array(__CLASS__,'myplguin_admin_page'), 'dashicons-tickets', 6 );
Hope that helps anybody with that issue too.
Upvotes: 2
Reputation: 306
The solution is we have to include both files in plugin.php file separtely
require('top-level.php');
require ('simple-page.php');
Moreover there is syntax error in simple-page.php in the given link
Upvotes: -1