Reputation: 129
I have to perform this action:
add_action('admin_menu', function(){
add_options_page(
'Submissions of MAIN page contact form',
'Submissions of MAIN page contact form',
'manage_options',
'ea_submissions2',
news()
);
});
In PHP 5.2 anonymous functions are not supported, so I made the following:
function news_opt(){
add_options_page(
'Submissions of MAIN page contact form',
'Submissions of MAIN page contact form',
'manage_options',
'ea_submissions2',
news()
);
}
add_action('admin_menu', news_opt());
And after that I got Fatal error: Call to undefined function add_options_page() error. What is the issue?
Upvotes: 1
Views: 722
Reputation: 26065
If you append ()
, you're calling the execution of a function. And it has to be passed as a string:
add_action( 'admin_menu', 'news_opt' );
And
add_options_page( ..., ..., 'news' );
The documentation for add_options_page
and admin_menu
would have shown that. When some WordPress function or hook doesn't work, always check if the Codex has useful information.
Upvotes: 1