Reputation: 3517
In WordPress I'm adding a new menu page like this:
add_menu_page(
'Page Name',
'Page Name',
'manage_options',
'page-name',
array($this, 'page_function')
);
However, I want to pass some arguments when running the function page_function. Ideally, it would be something like this (but doesn't work):
add_menu_page(
'Page Name',
'Page Name',
'manage_options',
'page-name',
array($this, 'page_function("arg1", "arg2")')
);
How do I do this?
Upvotes: 0
Views: 1243
Reputation: 2125
In that context, you can't. The callback accepts only one parameter. You can, however, do something like:
<?php
function page_function($file) {
// logic here to set parameters $arg1 and $arg2
page_function_helper( $file, 1, 2 );
}
function page_function_helper($file, $arg1, $arg2) {
// do whatever you need to do
}
?>
Upvotes: 2