I was use to pass value to function for the below menu.

add_menu_page('Competition Manager 2013-2014', '2013-2014', 'manage_options', 'manager_2013_2014', 'manager_2013_2014', plugins_url( 'competition-manager/images/cup.png' ), 81 );
  • 1
    This is not clear. Please expand upon the description of the problem. – s_ha_dum Apr 30 '14 at 21:53

Don’t use a function for the callback, use a class. Something like this:

class Competition_Manager_Page
    private $extra;

    public function set_extra( $value )
        $this->extra = $value;

    public function render()
        // show you page content, then:
        print $this->extra;

You can extend the class’ functionality later.

Now, when you register the menu, create an instance of that class first, and add you extra data:

$page = new Competition_Manager_Page;
$page->set_extra( 'Test' );

    'Competition Manager 2013-2014',
    array( $page, 'render' ), // replacement for the former function
    plugins_url( 'competition-manager/images/cup.png' ), 81

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.